diff --git a/Jakefile.js b/Jakefile.js index a073949af68..f45e6b11ee2 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -119,7 +119,7 @@ var languageServiceLibrarySources = [ return path.join(serverDirectory, f); }).concat(servicesSources); -var harnessSources = [ +var harnessCoreSources = [ "harness.ts", "sourceMapRecorder.ts", "harnessLanguageService.ts", @@ -135,7 +135,9 @@ var harnessSources = [ "runner.ts" ].map(function (f) { return path.join(harnessDirectory, f); -}).concat([ +}); + +var harnessSources = harnessCoreSources.concat([ "incrementalParser.ts", "jsDocParsing.ts", "services/colorization.ts", @@ -622,7 +624,7 @@ task("runtests", ["tests", builtLocalDirectory], function() { var colors = process.env.colors || process.env.color; colors = colors ? ' --no-colors ' : ' --colors '; tests = tests ? ' -g ' + tests : ''; - var reporter = process.env.reporter || process.env.r || 'dot'; + var reporter = process.env.reporter || process.env.r || 'mocha-fivemat-progress-reporter'; // timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally // default timeout is 2sec which really should be enough, but maybe we just need a small amount longer var cmd = host + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run; @@ -796,12 +798,13 @@ task("update-sublime", ["local", serverFile], function() { // run this task automatically desc("Runs tslint on the compiler sources"); task("lint", [], function() { - for(var i in compilerSources) { - var f = compilerSources[i]; + function success(f) { return function() { console.log('SUCCESS: No linter errors in ' + f + '\n'); }}; + function failure(f) { return function() { console.log('FAILURE: Please fix linting errors in ' + f + '\n') }}; + + var lintTargets = compilerSources.concat(harnessCoreSources); + for(var i in lintTargets) { + var f = lintTargets[i]; var cmd = 'tslint -f ' + f; - exec(cmd, - function() { console.log('SUCCESS: No linter errors'); }, - function() { console.log('FAILURE: Please fix linting errors in ' + f + '\n'); - }); + exec(cmd, success(f), failure(f)); } }, { async: true }); diff --git a/README.md b/README.md index 31b1a21f64d..57dfe06c67c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,4 @@ [![Build Status](https://travis-ci.org/Microsoft/TypeScript.svg?branch=master)](https://travis-ci.org/Microsoft/TypeScript) -[![Issue Stats](http://issuestats.com/github/Microsoft/TypeScript/badge/pr)](http://issuestats.com/github/microsoft/typescript) -[![Issue Stats](http://issuestats.com/github/Microsoft/TypeScript/badge/issue)](http://issuestats.com/github/microsoft/typescript) [![npm version](https://badge.fury.io/js/typescript.svg)](http://badge.fury.io/js/typescript) [![Downloads](http://img.shields.io/npm/dm/TypeScript.svg)](https://npmjs.org/package/typescript) diff --git a/bin/lib.core.d.ts b/bin/lib.core.d.ts index af876765ab4..a265b5c2a95 100644 --- a/bin/lib.core.d.ts +++ b/bin/lib.core.d.ts @@ -1184,3 +1184,16 @@ declare type ClassDecorator = (target: TFunction) => declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void; declare type MethodDecorator = (target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor | void; declare type ParameterDecorator = (target: Object, propertyKey: string | symbol, parameterIndex: number) => void; + +declare type PromiseConstructorLike = new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void) => PromiseLike; + +interface PromiseLike { + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; +} diff --git a/bin/lib.core.es6.d.ts b/bin/lib.core.es6.d.ts index 50c7fcc9017..48d02ec1465 100644 --- a/bin/lib.core.es6.d.ts +++ b/bin/lib.core.es6.d.ts @@ -1184,6 +1184,19 @@ declare type ClassDecorator = (target: TFunction) => declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void; declare type MethodDecorator = (target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor | void; declare type ParameterDecorator = (target: Object, propertyKey: string | symbol, parameterIndex: number) => void; + +declare type PromiseConstructorLike = new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void) => PromiseLike; + +interface PromiseLike { + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; +} declare type PropertyKey = string | number | symbol; interface Symbol { @@ -4759,17 +4772,6 @@ declare module Reflect { function setPrototypeOf(target: any, proto: any): boolean; } -interface PromiseLike { - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. - */ - then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; - then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; -} - /** * Represents the completion of an asynchronous operation */ @@ -4789,6 +4791,7 @@ interface Promise { * @returns A Promise for the completion of the callback. */ catch(onrejected?: (reason: any) => T | PromiseLike): Promise; + catch(onrejected?: (reason: any) => void): Promise; [Symbol.toStringTag]: string; } diff --git a/bin/lib.d.ts b/bin/lib.d.ts index 63a8adbeda4..430d8279de4 100644 --- a/bin/lib.d.ts +++ b/bin/lib.d.ts @@ -1185,6 +1185,19 @@ declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) declare type MethodDecorator = (target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor | void; declare type ParameterDecorator = (target: Object, propertyKey: string | symbol, parameterIndex: number) => void; +declare type PromiseConstructorLike = new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void) => PromiseLike; + +interface PromiseLike { + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; +} + ///////////////////////////// /// IE10 ECMAScript Extensions ///////////////////////////// @@ -4755,16 +4768,11 @@ interface CanvasRenderingContext2D { clearRect(x: number, y: number, w: number, h: number): void; clip(fillRule?: string): void; closePath(): void; - createImageData(imageDataOrSw: number, sh?: number): ImageData; - createImageData(imageDataOrSw: ImageData, sh?: number): ImageData; + createImageData(imageDataOrSw: number | ImageData, sh?: number): ImageData; createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient; - createPattern(image: HTMLImageElement, repetition: string): CanvasPattern; - createPattern(image: HTMLCanvasElement, repetition: string): CanvasPattern; - createPattern(image: HTMLVideoElement, repetition: string): CanvasPattern; + createPattern(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, repetition: string): CanvasPattern; createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; - drawImage(image: HTMLImageElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; - drawImage(image: HTMLCanvasElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; - drawImage(image: HTMLVideoElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; + drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; fill(fillRule?: string): void; fillRect(x: number, y: number, w: number, h: number): void; fillText(text: string, x: number, y: number, maxWidth?: number): void; @@ -5922,12 +5930,12 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * @param elementId String that specifies the ID value. Case-insensitive. */ getElementById(elementId: string): HTMLElement; - getElementsByClassName(classNames: string): NodeList; + getElementsByClassName(classNames: string): NodeListOf; /** * Gets a collection of objects based on the value of the NAME or ID attribute. * @param elementName Gets a collection of objects based on the value of the NAME or ID attribute. */ - getElementsByName(elementName: string): NodeList; + getElementsByName(elementName: string): NodeListOf; /** * Retrieves a collection of objects based on the specified element name. * @param name Specifies the name of an element. @@ -6105,8 +6113,8 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven getElementsByTagName(tagname: "wbr"): NodeListOf; getElementsByTagName(tagname: "x-ms-webview"): NodeListOf; getElementsByTagName(tagname: "xmp"): NodeListOf; - getElementsByTagName(tagname: string): NodeList; - getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList; + getElementsByTagName(tagname: string): NodeListOf; + getElementsByTagNameNS(namespaceURI: string, localName: string): NodeListOf; /** * Returns an object representing the current selection of the document that is loaded into the object displaying a webpage. */ @@ -6379,6 +6387,8 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec scrollTop: number; scrollWidth: number; tagName: string; + id: string; + className: string; getAttribute(name?: string): string; getAttributeNS(namespaceURI: string, localName: string): string; getAttributeNode(name: string): Attr; @@ -6558,8 +6568,8 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec getElementsByTagName(name: "wbr"): NodeListOf; getElementsByTagName(name: "x-ms-webview"): NodeListOf; getElementsByTagName(name: "xmp"): NodeListOf; - getElementsByTagName(name: string): NodeList; - getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList; + getElementsByTagName(name: string): NodeListOf; + getElementsByTagNameNS(namespaceURI: string, localName: string): NodeListOf; hasAttribute(name: string): boolean; hasAttributeNS(namespaceURI: string, localName: string): boolean; msGetRegionContent(): MSRangeCollection; @@ -6740,7 +6750,7 @@ interface FormData { declare var FormData: { prototype: FormData; - new(): FormData; + new (form?: HTMLFormElement): FormData; } interface GainNode extends AudioNode { @@ -7033,8 +7043,7 @@ interface HTMLAreasCollection extends HTMLCollection { /** * Adds an element to the areas, controlRange, or options collection. */ - add(element: HTMLElement, before?: HTMLElement): void; - add(element: HTMLElement, before?: number): void; + add(element: HTMLElement, before?: HTMLElement | number): void; /** * Removes an element from the collection. */ @@ -7478,14 +7487,12 @@ declare var HTMLDocument: { interface HTMLElement extends Element { accessKey: string; children: HTMLCollection; - className: string; contentEditable: string; dataset: DOMStringMap; dir: string; draggable: boolean; hidden: boolean; hideFocus: boolean; - id: string; innerHTML: string; innerText: string; isContentEditable: boolean; @@ -7572,7 +7579,7 @@ interface HTMLElement extends Element { contains(child: HTMLElement): boolean; dragDrop(): boolean; focus(): void; - getElementsByClassName(classNames: string): NodeList; + getElementsByClassName(classNames: string): NodeListOf; insertAdjacentElement(position: string, insertedElement: Element): Element; insertAdjacentHTML(where: string, html: string): void; insertAdjacentText(where: string, text: string): void; @@ -9782,8 +9789,7 @@ interface HTMLSelectElement extends HTMLElement { * @param element Variant of type Number that specifies the index position in the collection where the element is placed. If no value is given, the method places the element at the end of the collection. * @param before Variant of type Object that specifies an element to insert before, or null to append the object to the collection. */ - add(element: HTMLElement, before?: HTMLElement): void; - add(element: HTMLElement, before?: number): void; + add(element: HTMLElement, before?: HTMLElement | number): void; /** * Returns whether a form will validate when it is submitted, without having to submit it. */ @@ -12385,6 +12391,7 @@ declare var SVGDescElement: { interface SVGElement extends Element { id: string; + className: any; onclick: (ev: MouseEvent) => any; ondblclick: (ev: MouseEvent) => any; onfocusin: (ev: FocusEvent) => any; @@ -13944,8 +13951,7 @@ interface Screen extends EventTarget { systemXDPI: number; systemYDPI: number; width: number; - msLockOrientation(orientations: string): boolean; - msLockOrientation(orientations: string[]): boolean; + msLockOrientation(orientations: string | string[]): boolean; msUnlockOrientation(): void; addEventListener(type: "MSOrientationChange", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -14017,8 +14023,7 @@ interface SourceBuffer extends EventTarget { updating: boolean; videoTracks: VideoTrackList; abort(): void; - appendBuffer(data: ArrayBuffer): void; - appendBuffer(data: ArrayBufferView): void; + appendBuffer(data: ArrayBuffer | ArrayBufferView): void; appendStream(stream: MSStream, maxSize?: number): void; remove(start: number, end: number): void; } @@ -14126,33 +14131,18 @@ declare var StyleSheetPageList: { } interface SubtleCrypto { - decrypt(algorithm: string, key: CryptoKey, data: ArrayBufferView): any; - decrypt(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any; - deriveBits(algorithm: string, baseKey: CryptoKey, length: number): any; - deriveBits(algorithm: Algorithm, baseKey: CryptoKey, length: number): any; - deriveKey(algorithm: string, baseKey: CryptoKey, derivedKeyType: string, extractable: boolean, keyUsages: string[]): any; - deriveKey(algorithm: string, baseKey: CryptoKey, derivedKeyType: Algorithm, extractable: boolean, keyUsages: string[]): any; - deriveKey(algorithm: Algorithm, baseKey: CryptoKey, derivedKeyType: string, extractable: boolean, keyUsages: string[]): any; - deriveKey(algorithm: Algorithm, baseKey: CryptoKey, derivedKeyType: Algorithm, extractable: boolean, keyUsages: string[]): any; - digest(algorithm: string, data: ArrayBufferView): any; - digest(algorithm: Algorithm, data: ArrayBufferView): any; - encrypt(algorithm: string, key: CryptoKey, data: ArrayBufferView): any; - encrypt(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any; + decrypt(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any; + deriveBits(algorithm: string | Algorithm, baseKey: CryptoKey, length: number): any; + deriveKey(algorithm: string | Algorithm, baseKey: CryptoKey, derivedKeyType: string | Algorithm, extractable: boolean, keyUsages: string[]): any; + digest(algorithm: string | Algorithm, data: ArrayBufferView): any; + encrypt(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any; exportKey(format: string, key: CryptoKey): any; - generateKey(algorithm: string, extractable: boolean, keyUsages: string[]): any; - generateKey(algorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - importKey(format: string, keyData: ArrayBufferView, algorithm: string, extractable: boolean, keyUsages: string[]): any; - importKey(format: string, keyData: ArrayBufferView, algorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - sign(algorithm: string, key: CryptoKey, data: ArrayBufferView): any; - sign(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any; - unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string, unwrappedKeyAlgorithm: string, extractable: boolean, keyUsages: string[]): any; - unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string, unwrappedKeyAlgorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: string, extractable: boolean, keyUsages: string[]): any; - unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - verify(algorithm: string, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any; - verify(algorithm: Algorithm, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any; - wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string): any; - wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: Algorithm): any; + generateKey(algorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any; + importKey(format: string, keyData: ArrayBufferView, algorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any; + sign(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any; + unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string | Algorithm, unwrappedKeyAlgorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any; + verify(algorithm: string | Algorithm, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any; + wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string | Algorithm): any; } declare var SubtleCrypto: { @@ -14661,11 +14651,8 @@ interface WebGLRenderingContext { blendEquationSeparate(modeRGB: number, modeAlpha: number): void; blendFunc(sfactor: number, dfactor: number): void; blendFuncSeparate(srcRGB: number, dstRGB: number, srcAlpha: number, dstAlpha: number): void; - bufferData(target: number, size: number, usage: number): void; - bufferData(target: number, size: ArrayBufferView, usage: number): void; - bufferData(target: number, size: any, usage: number): void; - bufferSubData(target: number, offset: number, data: ArrayBufferView): void; - bufferSubData(target: number, offset: number, data: any): void; + bufferData(target: number, size: number | ArrayBufferView | ArrayBuffer, usage: number): void; + bufferSubData(target: number, offset: number, data: ArrayBufferView | ArrayBuffer): void; checkFramebufferStatus(target: number): number; clear(mask: number): void; clearColor(red: number, green: number, blue: number, alpha: number): void; @@ -15508,8 +15495,7 @@ interface WebSocket extends EventTarget { declare var WebSocket: { prototype: WebSocket; - new(url: string, protocols?: string): WebSocket; - new(url: string, protocols?: any): WebSocket; + new(url: string, protocols?: string | string[]): WebSocket; CLOSED: number; CLOSING: number; CONNECTING: number; @@ -15675,6 +15661,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window toolbar: BarProp; top: Window; window: Window; + URL: URL; alert(message?: any): void; blur(): void; cancelAnimationFrame(handle: number): void; @@ -16178,7 +16165,7 @@ interface NavigatorStorageUtils { interface NodeSelector { querySelector(selectors: string): Element; - querySelectorAll(selectors: string): NodeList; + querySelectorAll(selectors: string): NodeListOf; } interface RandomSource { @@ -16226,7 +16213,7 @@ interface SVGLocatable { } interface SVGStylable { - className: SVGAnimatedString; + className: any; style: CSSStyleDeclaration; } @@ -16313,8 +16300,7 @@ interface EventListenerObject { declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface ErrorEventHandler { - (event: Event, source?: string, fileno?: number, columnNumber?: number): void; - (event: string, source?: string, fileno?: number, columnNumber?: number): void; + (message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void; } interface PositionCallback { (position: Position): void; @@ -16490,6 +16476,7 @@ declare var styleMedia: StyleMedia; declare var toolbar: BarProp; declare var top: Window; declare var window: Window; +declare var URL: URL; declare function alert(message?: any): void; declare function blur(): void; declare function cancelAnimationFrame(handle: number): void; @@ -16642,7 +16629,6 @@ declare function addEventListener(type: "volumechange", listener: (ev: Event) => declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; - ///////////////////////////// /// WorkerGlobalScope APIs ///////////////////////////// diff --git a/bin/lib.dom.d.ts b/bin/lib.dom.d.ts index b05be6cbee8..5ec268b2fd5 100644 --- a/bin/lib.dom.d.ts +++ b/bin/lib.dom.d.ts @@ -3585,16 +3585,11 @@ interface CanvasRenderingContext2D { clearRect(x: number, y: number, w: number, h: number): void; clip(fillRule?: string): void; closePath(): void; - createImageData(imageDataOrSw: number, sh?: number): ImageData; - createImageData(imageDataOrSw: ImageData, sh?: number): ImageData; + createImageData(imageDataOrSw: number | ImageData, sh?: number): ImageData; createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient; - createPattern(image: HTMLImageElement, repetition: string): CanvasPattern; - createPattern(image: HTMLCanvasElement, repetition: string): CanvasPattern; - createPattern(image: HTMLVideoElement, repetition: string): CanvasPattern; + createPattern(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, repetition: string): CanvasPattern; createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; - drawImage(image: HTMLImageElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; - drawImage(image: HTMLCanvasElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; - drawImage(image: HTMLVideoElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; + drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; fill(fillRule?: string): void; fillRect(x: number, y: number, w: number, h: number): void; fillText(text: string, x: number, y: number, maxWidth?: number): void; @@ -4752,12 +4747,12 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * @param elementId String that specifies the ID value. Case-insensitive. */ getElementById(elementId: string): HTMLElement; - getElementsByClassName(classNames: string): NodeList; + getElementsByClassName(classNames: string): NodeListOf; /** * Gets a collection of objects based on the value of the NAME or ID attribute. * @param elementName Gets a collection of objects based on the value of the NAME or ID attribute. */ - getElementsByName(elementName: string): NodeList; + getElementsByName(elementName: string): NodeListOf; /** * Retrieves a collection of objects based on the specified element name. * @param name Specifies the name of an element. @@ -4935,8 +4930,8 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven getElementsByTagName(tagname: "wbr"): NodeListOf; getElementsByTagName(tagname: "x-ms-webview"): NodeListOf; getElementsByTagName(tagname: "xmp"): NodeListOf; - getElementsByTagName(tagname: string): NodeList; - getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList; + getElementsByTagName(tagname: string): NodeListOf; + getElementsByTagNameNS(namespaceURI: string, localName: string): NodeListOf; /** * Returns an object representing the current selection of the document that is loaded into the object displaying a webpage. */ @@ -5209,6 +5204,8 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec scrollTop: number; scrollWidth: number; tagName: string; + id: string; + className: string; getAttribute(name?: string): string; getAttributeNS(namespaceURI: string, localName: string): string; getAttributeNode(name: string): Attr; @@ -5388,8 +5385,8 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec getElementsByTagName(name: "wbr"): NodeListOf; getElementsByTagName(name: "x-ms-webview"): NodeListOf; getElementsByTagName(name: "xmp"): NodeListOf; - getElementsByTagName(name: string): NodeList; - getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList; + getElementsByTagName(name: string): NodeListOf; + getElementsByTagNameNS(namespaceURI: string, localName: string): NodeListOf; hasAttribute(name: string): boolean; hasAttributeNS(namespaceURI: string, localName: string): boolean; msGetRegionContent(): MSRangeCollection; @@ -5570,7 +5567,7 @@ interface FormData { declare var FormData: { prototype: FormData; - new(): FormData; + new (form?: HTMLFormElement): FormData; } interface GainNode extends AudioNode { @@ -5863,8 +5860,7 @@ interface HTMLAreasCollection extends HTMLCollection { /** * Adds an element to the areas, controlRange, or options collection. */ - add(element: HTMLElement, before?: HTMLElement): void; - add(element: HTMLElement, before?: number): void; + add(element: HTMLElement, before?: HTMLElement | number): void; /** * Removes an element from the collection. */ @@ -6308,14 +6304,12 @@ declare var HTMLDocument: { interface HTMLElement extends Element { accessKey: string; children: HTMLCollection; - className: string; contentEditable: string; dataset: DOMStringMap; dir: string; draggable: boolean; hidden: boolean; hideFocus: boolean; - id: string; innerHTML: string; innerText: string; isContentEditable: boolean; @@ -6402,7 +6396,7 @@ interface HTMLElement extends Element { contains(child: HTMLElement): boolean; dragDrop(): boolean; focus(): void; - getElementsByClassName(classNames: string): NodeList; + getElementsByClassName(classNames: string): NodeListOf; insertAdjacentElement(position: string, insertedElement: Element): Element; insertAdjacentHTML(where: string, html: string): void; insertAdjacentText(where: string, text: string): void; @@ -8612,8 +8606,7 @@ interface HTMLSelectElement extends HTMLElement { * @param element Variant of type Number that specifies the index position in the collection where the element is placed. If no value is given, the method places the element at the end of the collection. * @param before Variant of type Object that specifies an element to insert before, or null to append the object to the collection. */ - add(element: HTMLElement, before?: HTMLElement): void; - add(element: HTMLElement, before?: number): void; + add(element: HTMLElement, before?: HTMLElement | number): void; /** * Returns whether a form will validate when it is submitted, without having to submit it. */ @@ -11215,6 +11208,7 @@ declare var SVGDescElement: { interface SVGElement extends Element { id: string; + className: any; onclick: (ev: MouseEvent) => any; ondblclick: (ev: MouseEvent) => any; onfocusin: (ev: FocusEvent) => any; @@ -12774,8 +12768,7 @@ interface Screen extends EventTarget { systemXDPI: number; systemYDPI: number; width: number; - msLockOrientation(orientations: string): boolean; - msLockOrientation(orientations: string[]): boolean; + msLockOrientation(orientations: string | string[]): boolean; msUnlockOrientation(): void; addEventListener(type: "MSOrientationChange", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -12847,8 +12840,7 @@ interface SourceBuffer extends EventTarget { updating: boolean; videoTracks: VideoTrackList; abort(): void; - appendBuffer(data: ArrayBuffer): void; - appendBuffer(data: ArrayBufferView): void; + appendBuffer(data: ArrayBuffer | ArrayBufferView): void; appendStream(stream: MSStream, maxSize?: number): void; remove(start: number, end: number): void; } @@ -12956,33 +12948,18 @@ declare var StyleSheetPageList: { } interface SubtleCrypto { - decrypt(algorithm: string, key: CryptoKey, data: ArrayBufferView): any; - decrypt(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any; - deriveBits(algorithm: string, baseKey: CryptoKey, length: number): any; - deriveBits(algorithm: Algorithm, baseKey: CryptoKey, length: number): any; - deriveKey(algorithm: string, baseKey: CryptoKey, derivedKeyType: string, extractable: boolean, keyUsages: string[]): any; - deriveKey(algorithm: string, baseKey: CryptoKey, derivedKeyType: Algorithm, extractable: boolean, keyUsages: string[]): any; - deriveKey(algorithm: Algorithm, baseKey: CryptoKey, derivedKeyType: string, extractable: boolean, keyUsages: string[]): any; - deriveKey(algorithm: Algorithm, baseKey: CryptoKey, derivedKeyType: Algorithm, extractable: boolean, keyUsages: string[]): any; - digest(algorithm: string, data: ArrayBufferView): any; - digest(algorithm: Algorithm, data: ArrayBufferView): any; - encrypt(algorithm: string, key: CryptoKey, data: ArrayBufferView): any; - encrypt(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any; + decrypt(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any; + deriveBits(algorithm: string | Algorithm, baseKey: CryptoKey, length: number): any; + deriveKey(algorithm: string | Algorithm, baseKey: CryptoKey, derivedKeyType: string | Algorithm, extractable: boolean, keyUsages: string[]): any; + digest(algorithm: string | Algorithm, data: ArrayBufferView): any; + encrypt(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any; exportKey(format: string, key: CryptoKey): any; - generateKey(algorithm: string, extractable: boolean, keyUsages: string[]): any; - generateKey(algorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - importKey(format: string, keyData: ArrayBufferView, algorithm: string, extractable: boolean, keyUsages: string[]): any; - importKey(format: string, keyData: ArrayBufferView, algorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - sign(algorithm: string, key: CryptoKey, data: ArrayBufferView): any; - sign(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any; - unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string, unwrappedKeyAlgorithm: string, extractable: boolean, keyUsages: string[]): any; - unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string, unwrappedKeyAlgorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: string, extractable: boolean, keyUsages: string[]): any; - unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - verify(algorithm: string, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any; - verify(algorithm: Algorithm, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any; - wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string): any; - wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: Algorithm): any; + generateKey(algorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any; + importKey(format: string, keyData: ArrayBufferView, algorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any; + sign(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any; + unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string | Algorithm, unwrappedKeyAlgorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any; + verify(algorithm: string | Algorithm, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any; + wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string | Algorithm): any; } declare var SubtleCrypto: { @@ -13491,11 +13468,8 @@ interface WebGLRenderingContext { blendEquationSeparate(modeRGB: number, modeAlpha: number): void; blendFunc(sfactor: number, dfactor: number): void; blendFuncSeparate(srcRGB: number, dstRGB: number, srcAlpha: number, dstAlpha: number): void; - bufferData(target: number, size: number, usage: number): void; - bufferData(target: number, size: ArrayBufferView, usage: number): void; - bufferData(target: number, size: any, usage: number): void; - bufferSubData(target: number, offset: number, data: ArrayBufferView): void; - bufferSubData(target: number, offset: number, data: any): void; + bufferData(target: number, size: number | ArrayBufferView | ArrayBuffer, usage: number): void; + bufferSubData(target: number, offset: number, data: ArrayBufferView | ArrayBuffer): void; checkFramebufferStatus(target: number): number; clear(mask: number): void; clearColor(red: number, green: number, blue: number, alpha: number): void; @@ -14338,8 +14312,7 @@ interface WebSocket extends EventTarget { declare var WebSocket: { prototype: WebSocket; - new(url: string, protocols?: string): WebSocket; - new(url: string, protocols?: any): WebSocket; + new(url: string, protocols?: string | string[]): WebSocket; CLOSED: number; CLOSING: number; CONNECTING: number; @@ -14505,6 +14478,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window toolbar: BarProp; top: Window; window: Window; + URL: URL; alert(message?: any): void; blur(): void; cancelAnimationFrame(handle: number): void; @@ -15008,7 +14982,7 @@ interface NavigatorStorageUtils { interface NodeSelector { querySelector(selectors: string): Element; - querySelectorAll(selectors: string): NodeList; + querySelectorAll(selectors: string): NodeListOf; } interface RandomSource { @@ -15056,7 +15030,7 @@ interface SVGLocatable { } interface SVGStylable { - className: SVGAnimatedString; + className: any; style: CSSStyleDeclaration; } @@ -15143,8 +15117,7 @@ interface EventListenerObject { declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface ErrorEventHandler { - (event: Event, source?: string, fileno?: number, columnNumber?: number): void; - (event: string, source?: string, fileno?: number, columnNumber?: number): void; + (message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void; } interface PositionCallback { (position: Position): void; @@ -15320,6 +15293,7 @@ declare var styleMedia: StyleMedia; declare var toolbar: BarProp; declare var top: Window; declare var window: Window; +declare var URL: URL; declare function alert(message?: any): void; declare function blur(): void; declare function cancelAnimationFrame(handle: number): void; @@ -15471,4 +15445,4 @@ declare function addEventListener(type: "unload", listener: (ev: Event) => any, declare function addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; \ No newline at end of file diff --git a/bin/lib.es6.d.ts b/bin/lib.es6.d.ts index 931d60ec47a..6c06cc08dc7 100644 --- a/bin/lib.es6.d.ts +++ b/bin/lib.es6.d.ts @@ -1184,6 +1184,19 @@ declare type ClassDecorator = (target: TFunction) => declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void; declare type MethodDecorator = (target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor | void; declare type ParameterDecorator = (target: Object, propertyKey: string | symbol, parameterIndex: number) => void; + +declare type PromiseConstructorLike = new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void) => PromiseLike; + +interface PromiseLike { + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; +} declare type PropertyKey = string | number | symbol; interface Symbol { @@ -4759,17 +4772,6 @@ declare module Reflect { function setPrototypeOf(target: any, proto: any): boolean; } -interface PromiseLike { - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. - */ - then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; - then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; -} - /** * Represents the completion of an asynchronous operation */ @@ -4789,6 +4791,7 @@ interface Promise { * @returns A Promise for the completion of the callback. */ catch(onrejected?: (reason: any) => T | PromiseLike): Promise; + catch(onrejected?: (reason: any) => void): Promise; [Symbol.toStringTag]: string; } @@ -6137,16 +6140,11 @@ interface CanvasRenderingContext2D { clearRect(x: number, y: number, w: number, h: number): void; clip(fillRule?: string): void; closePath(): void; - createImageData(imageDataOrSw: number, sh?: number): ImageData; - createImageData(imageDataOrSw: ImageData, sh?: number): ImageData; + createImageData(imageDataOrSw: number | ImageData, sh?: number): ImageData; createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient; - createPattern(image: HTMLImageElement, repetition: string): CanvasPattern; - createPattern(image: HTMLCanvasElement, repetition: string): CanvasPattern; - createPattern(image: HTMLVideoElement, repetition: string): CanvasPattern; + createPattern(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, repetition: string): CanvasPattern; createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient; - drawImage(image: HTMLImageElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; - drawImage(image: HTMLCanvasElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; - drawImage(image: HTMLVideoElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; + drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, offsetX: number, offsetY: number, width?: number, height?: number, canvasOffsetX?: number, canvasOffsetY?: number, canvasImageWidth?: number, canvasImageHeight?: number): void; fill(fillRule?: string): void; fillRect(x: number, y: number, w: number, h: number): void; fillText(text: string, x: number, y: number, maxWidth?: number): void; @@ -7304,12 +7302,12 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * @param elementId String that specifies the ID value. Case-insensitive. */ getElementById(elementId: string): HTMLElement; - getElementsByClassName(classNames: string): NodeList; + getElementsByClassName(classNames: string): NodeListOf; /** * Gets a collection of objects based on the value of the NAME or ID attribute. * @param elementName Gets a collection of objects based on the value of the NAME or ID attribute. */ - getElementsByName(elementName: string): NodeList; + getElementsByName(elementName: string): NodeListOf; /** * Retrieves a collection of objects based on the specified element name. * @param name Specifies the name of an element. @@ -7487,8 +7485,8 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven getElementsByTagName(tagname: "wbr"): NodeListOf; getElementsByTagName(tagname: "x-ms-webview"): NodeListOf; getElementsByTagName(tagname: "xmp"): NodeListOf; - getElementsByTagName(tagname: string): NodeList; - getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList; + getElementsByTagName(tagname: string): NodeListOf; + getElementsByTagNameNS(namespaceURI: string, localName: string): NodeListOf; /** * Returns an object representing the current selection of the document that is loaded into the object displaying a webpage. */ @@ -7761,6 +7759,8 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec scrollTop: number; scrollWidth: number; tagName: string; + id: string; + className: string; getAttribute(name?: string): string; getAttributeNS(namespaceURI: string, localName: string): string; getAttributeNode(name: string): Attr; @@ -7940,8 +7940,8 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec getElementsByTagName(name: "wbr"): NodeListOf; getElementsByTagName(name: "x-ms-webview"): NodeListOf; getElementsByTagName(name: "xmp"): NodeListOf; - getElementsByTagName(name: string): NodeList; - getElementsByTagNameNS(namespaceURI: string, localName: string): NodeList; + getElementsByTagName(name: string): NodeListOf; + getElementsByTagNameNS(namespaceURI: string, localName: string): NodeListOf; hasAttribute(name: string): boolean; hasAttributeNS(namespaceURI: string, localName: string): boolean; msGetRegionContent(): MSRangeCollection; @@ -8122,7 +8122,7 @@ interface FormData { declare var FormData: { prototype: FormData; - new(): FormData; + new (form?: HTMLFormElement): FormData; } interface GainNode extends AudioNode { @@ -8415,8 +8415,7 @@ interface HTMLAreasCollection extends HTMLCollection { /** * Adds an element to the areas, controlRange, or options collection. */ - add(element: HTMLElement, before?: HTMLElement): void; - add(element: HTMLElement, before?: number): void; + add(element: HTMLElement, before?: HTMLElement | number): void; /** * Removes an element from the collection. */ @@ -8860,14 +8859,12 @@ declare var HTMLDocument: { interface HTMLElement extends Element { accessKey: string; children: HTMLCollection; - className: string; contentEditable: string; dataset: DOMStringMap; dir: string; draggable: boolean; hidden: boolean; hideFocus: boolean; - id: string; innerHTML: string; innerText: string; isContentEditable: boolean; @@ -8954,7 +8951,7 @@ interface HTMLElement extends Element { contains(child: HTMLElement): boolean; dragDrop(): boolean; focus(): void; - getElementsByClassName(classNames: string): NodeList; + getElementsByClassName(classNames: string): NodeListOf; insertAdjacentElement(position: string, insertedElement: Element): Element; insertAdjacentHTML(where: string, html: string): void; insertAdjacentText(where: string, text: string): void; @@ -11164,8 +11161,7 @@ interface HTMLSelectElement extends HTMLElement { * @param element Variant of type Number that specifies the index position in the collection where the element is placed. If no value is given, the method places the element at the end of the collection. * @param before Variant of type Object that specifies an element to insert before, or null to append the object to the collection. */ - add(element: HTMLElement, before?: HTMLElement): void; - add(element: HTMLElement, before?: number): void; + add(element: HTMLElement, before?: HTMLElement | number): void; /** * Returns whether a form will validate when it is submitted, without having to submit it. */ @@ -13767,6 +13763,7 @@ declare var SVGDescElement: { interface SVGElement extends Element { id: string; + className: any; onclick: (ev: MouseEvent) => any; ondblclick: (ev: MouseEvent) => any; onfocusin: (ev: FocusEvent) => any; @@ -15326,8 +15323,7 @@ interface Screen extends EventTarget { systemXDPI: number; systemYDPI: number; width: number; - msLockOrientation(orientations: string): boolean; - msLockOrientation(orientations: string[]): boolean; + msLockOrientation(orientations: string | string[]): boolean; msUnlockOrientation(): void; addEventListener(type: "MSOrientationChange", listener: (ev: Event) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -15399,8 +15395,7 @@ interface SourceBuffer extends EventTarget { updating: boolean; videoTracks: VideoTrackList; abort(): void; - appendBuffer(data: ArrayBuffer): void; - appendBuffer(data: ArrayBufferView): void; + appendBuffer(data: ArrayBuffer | ArrayBufferView): void; appendStream(stream: MSStream, maxSize?: number): void; remove(start: number, end: number): void; } @@ -15508,33 +15503,18 @@ declare var StyleSheetPageList: { } interface SubtleCrypto { - decrypt(algorithm: string, key: CryptoKey, data: ArrayBufferView): any; - decrypt(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any; - deriveBits(algorithm: string, baseKey: CryptoKey, length: number): any; - deriveBits(algorithm: Algorithm, baseKey: CryptoKey, length: number): any; - deriveKey(algorithm: string, baseKey: CryptoKey, derivedKeyType: string, extractable: boolean, keyUsages: string[]): any; - deriveKey(algorithm: string, baseKey: CryptoKey, derivedKeyType: Algorithm, extractable: boolean, keyUsages: string[]): any; - deriveKey(algorithm: Algorithm, baseKey: CryptoKey, derivedKeyType: string, extractable: boolean, keyUsages: string[]): any; - deriveKey(algorithm: Algorithm, baseKey: CryptoKey, derivedKeyType: Algorithm, extractable: boolean, keyUsages: string[]): any; - digest(algorithm: string, data: ArrayBufferView): any; - digest(algorithm: Algorithm, data: ArrayBufferView): any; - encrypt(algorithm: string, key: CryptoKey, data: ArrayBufferView): any; - encrypt(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any; + decrypt(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any; + deriveBits(algorithm: string | Algorithm, baseKey: CryptoKey, length: number): any; + deriveKey(algorithm: string | Algorithm, baseKey: CryptoKey, derivedKeyType: string | Algorithm, extractable: boolean, keyUsages: string[]): any; + digest(algorithm: string | Algorithm, data: ArrayBufferView): any; + encrypt(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any; exportKey(format: string, key: CryptoKey): any; - generateKey(algorithm: string, extractable: boolean, keyUsages: string[]): any; - generateKey(algorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - importKey(format: string, keyData: ArrayBufferView, algorithm: string, extractable: boolean, keyUsages: string[]): any; - importKey(format: string, keyData: ArrayBufferView, algorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - sign(algorithm: string, key: CryptoKey, data: ArrayBufferView): any; - sign(algorithm: Algorithm, key: CryptoKey, data: ArrayBufferView): any; - unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string, unwrappedKeyAlgorithm: string, extractable: boolean, keyUsages: string[]): any; - unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string, unwrappedKeyAlgorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: string, extractable: boolean, keyUsages: string[]): any; - unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: Algorithm, unwrappedKeyAlgorithm: Algorithm, extractable: boolean, keyUsages: string[]): any; - verify(algorithm: string, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any; - verify(algorithm: Algorithm, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any; - wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string): any; - wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: Algorithm): any; + generateKey(algorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any; + importKey(format: string, keyData: ArrayBufferView, algorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any; + sign(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): any; + unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string | Algorithm, unwrappedKeyAlgorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): any; + verify(algorithm: string | Algorithm, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): any; + wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string | Algorithm): any; } declare var SubtleCrypto: { @@ -16043,11 +16023,8 @@ interface WebGLRenderingContext { blendEquationSeparate(modeRGB: number, modeAlpha: number): void; blendFunc(sfactor: number, dfactor: number): void; blendFuncSeparate(srcRGB: number, dstRGB: number, srcAlpha: number, dstAlpha: number): void; - bufferData(target: number, size: number, usage: number): void; - bufferData(target: number, size: ArrayBufferView, usage: number): void; - bufferData(target: number, size: any, usage: number): void; - bufferSubData(target: number, offset: number, data: ArrayBufferView): void; - bufferSubData(target: number, offset: number, data: any): void; + bufferData(target: number, size: number | ArrayBufferView | ArrayBuffer, usage: number): void; + bufferSubData(target: number, offset: number, data: ArrayBufferView | ArrayBuffer): void; checkFramebufferStatus(target: number): number; clear(mask: number): void; clearColor(red: number, green: number, blue: number, alpha: number): void; @@ -16890,8 +16867,7 @@ interface WebSocket extends EventTarget { declare var WebSocket: { prototype: WebSocket; - new(url: string, protocols?: string): WebSocket; - new(url: string, protocols?: any): WebSocket; + new(url: string, protocols?: string | string[]): WebSocket; CLOSED: number; CLOSING: number; CONNECTING: number; @@ -17057,6 +17033,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window toolbar: BarProp; top: Window; window: Window; + URL: URL; alert(message?: any): void; blur(): void; cancelAnimationFrame(handle: number): void; @@ -17560,7 +17537,7 @@ interface NavigatorStorageUtils { interface NodeSelector { querySelector(selectors: string): Element; - querySelectorAll(selectors: string): NodeList; + querySelectorAll(selectors: string): NodeListOf; } interface RandomSource { @@ -17608,7 +17585,7 @@ interface SVGLocatable { } interface SVGStylable { - className: SVGAnimatedString; + className: any; style: CSSStyleDeclaration; } @@ -17695,8 +17672,7 @@ interface EventListenerObject { declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface ErrorEventHandler { - (event: Event, source?: string, fileno?: number, columnNumber?: number): void; - (event: string, source?: string, fileno?: number, columnNumber?: number): void; + (message: string, filename?: string, lineno?: number, colno?: number, error?:Error): void; } interface PositionCallback { (position: Position): void; @@ -17872,6 +17848,7 @@ declare var styleMedia: StyleMedia; declare var toolbar: BarProp; declare var top: Window; declare var window: Window; +declare var URL: URL; declare function alert(message?: any): void; declare function blur(): void; declare function cancelAnimationFrame(handle: number): void; @@ -18023,8 +18000,7 @@ declare function addEventListener(type: "unload", listener: (ev: Event) => any, declare function addEventListener(type: "volumechange", listener: (ev: Event) => any, useCapture?: boolean): void; declare function addEventListener(type: "waiting", listener: (ev: Event) => any, useCapture?: boolean): void; declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; -declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; -interface DOMTokenList { +declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;interface DOMTokenList { [Symbol.iterator](): IterableIterator; } diff --git a/bin/lib.webworker.d.ts b/bin/lib.webworker.d.ts index d0caeccff92..d9e8a2ab333 100644 --- a/bin/lib.webworker.d.ts +++ b/bin/lib.webworker.d.ts @@ -3064,8 +3064,7 @@ interface WebSocket extends EventTarget { declare var WebSocket: { prototype: WebSocket; - new(url: string, protocols?: string): WebSocket; - new(url: string, protocols?: any): WebSocket; + new(url: string, protocols?: string | string[]): WebSocket; CLOSED: number; CLOSING: number; CONNECTING: number; @@ -3300,8 +3299,7 @@ interface EventListenerObject { declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface ErrorEventHandler { - (event: Event, source?: string, fileno?: number, columnNumber?: number): void; - (event: string, source?: string, fileno?: number, columnNumber?: number): void; + (event: Event | string, source?: string, fileno?: number, columnNumber?: number): void; } interface PositionCallback { (position: Position): void; diff --git a/bin/tsc.js b/bin/tsc.js index 9e1d681e218..f5a780a390d 100644 --- a/bin/tsc.js +++ b/bin/tsc.js @@ -15,12 +15,31 @@ and limitations under the License. var ts; (function (ts) { + var OperationCanceledException = (function () { + function OperationCanceledException() { + } + return OperationCanceledException; + })(); + ts.OperationCanceledException = OperationCanceledException; (function (ExitStatus) { ExitStatus[ExitStatus["Success"] = 0] = "Success"; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsSkipped"] = 1] = "DiagnosticsPresent_OutputsSkipped"; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; })(ts.ExitStatus || (ts.ExitStatus = {})); var ExitStatus = ts.ExitStatus; + (function (TypeReferenceSerializationKind) { + TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidType"] = 2] = "VoidType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 4] = "StringLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 5] = "BooleanType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 6] = "ArrayLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 7] = "ESSymbolType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 8] = "TypeWithCallSignature"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 9] = "ObjectType"; + })(ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); + var TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind; (function (DiagnosticCategory) { DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; @@ -547,7 +566,7 @@ 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/ + // 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; @@ -630,8 +649,8 @@ var ts; return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension; } ts.fileExtensionIs = fileExtensionIs; - ts.supportedExtensions = [".ts", ".d.ts"]; - var extensionsToRemove = [".d.ts", ".ts", ".js"]; + ts.supportedExtensions = [".tsx", ".ts", ".d.ts"]; + var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { for (var _i = 0; _i < extensionsToRemove.length; _i++) { var ext = extensionsToRemove[_i]; @@ -674,8 +693,8 @@ var ts; } Node.prototype = { kind: kind, - pos: 0, - end: 0, + pos: -1, + end: -1, flags: 0, parent: undefined }; @@ -890,16 +909,16 @@ var ts; var directories = []; for (var _i = 0; _i < files.length; _i++) { var current = files[_i]; - var name = ts.combinePaths(path, current); - if (!ts.contains(exclude, getCanonicalPath(name))) { - var stat = _fs.statSync(name); + var name_3 = ts.combinePaths(path, current); + if (!ts.contains(exclude, getCanonicalPath(name_3))) { + var stat = _fs.statSync(name_3); if (stat.isFile()) { - if (!extension || ts.fileExtensionIs(name, extension)) { - result.push(name); + if (!extension || ts.fileExtensionIs(name_3, extension)) { + result.push(name_3); } } else if (stat.isDirectory()) { - directories.push(name); + directories.push(name_3); } } } @@ -995,22 +1014,21 @@ var ts; An_index_signature_must_have_a_type_annotation: { code: 1021, category: ts.DiagnosticCategory.Error, key: "An index signature must have a type annotation." }, An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: ts.DiagnosticCategory.Error, key: "An index signature parameter must have a type annotation." }, An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: ts.DiagnosticCategory.Error, key: "An index signature parameter type must be 'string' or 'number'." }, - A_class_or_interface_declaration_can_only_have_one_extends_clause: { code: 1024, category: ts.DiagnosticCategory.Error, key: "A class or interface declaration can only have one 'extends' clause." }, - An_extends_clause_must_precede_an_implements_clause: { code: 1025, category: ts.DiagnosticCategory.Error, key: "An 'extends' clause must precede an 'implements' clause." }, - A_class_can_only_extend_a_single_class: { code: 1026, category: ts.DiagnosticCategory.Error, key: "A class can only extend a single class." }, - A_class_declaration_can_only_have_one_implements_clause: { code: 1027, category: ts.DiagnosticCategory.Error, key: "A class declaration can only have one 'implements' clause." }, Accessibility_modifier_already_seen: { code: 1028, category: ts.DiagnosticCategory.Error, key: "Accessibility modifier already seen." }, _0_modifier_must_precede_1_modifier: { code: 1029, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier must precede '{1}' modifier." }, _0_modifier_already_seen: { code: 1030, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier already seen." }, _0_modifier_cannot_appear_on_a_class_element: { code: 1031, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a class element." }, - An_interface_declaration_cannot_have_an_implements_clause: { code: 1032, category: ts.DiagnosticCategory.Error, key: "An interface declaration cannot have an 'implements' clause." }, super_must_be_followed_by_an_argument_list_or_member_access: { code: 1034, category: ts.DiagnosticCategory.Error, key: "'super' must be followed by an argument list or member access." }, Only_ambient_modules_can_use_quoted_names: { code: 1035, category: ts.DiagnosticCategory.Error, key: "Only ambient modules can use quoted names." }, Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: ts.DiagnosticCategory.Error, key: "Statements are not allowed in ambient contexts." }, A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used in an already ambient context." }, Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: ts.DiagnosticCategory.Error, key: "Initializers are not allowed in ambient contexts." }, + _0_modifier_cannot_be_used_in_an_ambient_context: { code: 1040, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used in an ambient context." }, + _0_modifier_cannot_be_used_with_a_class_declaration: { code: 1041, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with a class declaration." }, + _0_modifier_cannot_be_used_here: { code: 1042, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used here." }, + _0_modifier_cannot_appear_on_a_data_property: { code: 1043, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a data property." }, _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a module element." }, - A_declare_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an interface declaration." }, + A_0_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: ts.DiagnosticCategory.Error, key: "A '{0}' modifier cannot be used with an interface declaration." }, A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, A_rest_parameter_cannot_be_optional: { code: 1047, category: ts.DiagnosticCategory.Error, key: "A rest parameter cannot be optional." }, A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: ts.DiagnosticCategory.Error, key: "A rest parameter cannot have an initializer." }, @@ -1019,12 +1037,18 @@ var ts; A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor parameter cannot have an initializer." }, A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor cannot have rest parameter." }, A_get_accessor_cannot_have_parameters: { code: 1054, category: ts.DiagnosticCategory.Error, key: "A 'get' accessor cannot have parameters." }, + Type_0_is_not_a_valid_async_function_return_type: { code: 1055, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not a valid async function return type." }, Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: ts.DiagnosticCategory.Error, key: "Accessors are only available when targeting ECMAScript 5 and higher." }, + An_async_function_or_method_must_have_a_valid_awaitable_return_type: { code: 1057, category: ts.DiagnosticCategory.Error, key: "An async function or method must have a valid awaitable return type." }, + Operand_for_await_does_not_have_a_valid_callable_then_member: { code: 1058, category: ts.DiagnosticCategory.Error, key: "Operand for 'await' does not have a valid callable 'then' member." }, + Return_expression_in_async_function_does_not_have_a_valid_callable_then_member: { code: 1059, category: ts.DiagnosticCategory.Error, key: "Return expression in async function does not have a valid callable 'then' member." }, + Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member: { code: 1060, category: ts.DiagnosticCategory.Error, key: "Expression body for async arrow function does not have a valid callable 'then' member." }, 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." }, 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_declare_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an import declaration." }, + 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." }, Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal literals are not available when targeting ECMAScript 5 and higher." }, An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: ts.DiagnosticCategory.Error, key: "An accessor cannot be declared in an ambient context." }, @@ -1069,7 +1093,6 @@ var ts; case_or_default_expected: { code: 1130, category: ts.DiagnosticCategory.Error, key: "'case' or 'default' expected." }, Property_or_signature_expected: { code: 1131, category: ts.DiagnosticCategory.Error, key: "Property or signature expected." }, Enum_member_expected: { code: 1132, category: ts.DiagnosticCategory.Error, key: "Enum member expected." }, - Type_reference_expected: { code: 1133, category: ts.DiagnosticCategory.Error, key: "Type reference expected." }, Variable_declaration_expected: { code: 1134, category: ts.DiagnosticCategory.Error, key: "Variable declaration expected." }, Argument_expression_expected: { code: 1135, category: ts.DiagnosticCategory.Error, key: "Argument expression expected." }, Property_assignment_expected: { code: 1136, category: ts.DiagnosticCategory.Error, key: "Property assignment expected." }, @@ -1086,9 +1109,6 @@ var ts; Cannot_compile_modules_unless_the_module_flag_is_provided: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules unless the '--module' flag is provided." }, File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: ts.DiagnosticCategory.Error, key: "File name '{0}' differs from already included file name '{1}' only in casing" }, new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: ts.DiagnosticCategory.Error, key: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, - var_let_or_const_expected: { code: 1152, category: ts.DiagnosticCategory.Error, key: "'var', 'let' or 'const' expected." }, - let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1153, category: ts.DiagnosticCategory.Error, key: "'let' declarations are only available when targeting ECMAScript 6 and higher." }, - const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1154, category: ts.DiagnosticCategory.Error, key: "'const' declarations are only available when targeting ECMAScript 6 and higher." }, const_declarations_must_be_initialized: { code: 1155, category: ts.DiagnosticCategory.Error, key: "'const' declarations must be initialized" }, const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: ts.DiagnosticCategory.Error, key: "'const' declarations can only be declared inside a block." }, let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: ts.DiagnosticCategory.Error, key: "'let' declarations can only be declared inside a block." }, @@ -1099,7 +1119,6 @@ var ts; Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: ts.DiagnosticCategory.Error, key: "Computed property names are not allowed in enums." }, A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { code: 1165, category: ts.DiagnosticCategory.Error, key: "A computed property name in an ambient context must directly refer to a built-in symbol." }, A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { code: 1166, category: ts.DiagnosticCategory.Error, key: "A computed property name in a class property declaration must directly refer to a built-in symbol." }, - Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1167, category: ts.DiagnosticCategory.Error, key: "Computed property names are only available when targeting ECMAScript 6 and higher." }, A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol: { code: 1168, category: ts.DiagnosticCategory.Error, key: "A computed property name in a method overload must directly refer to a built-in symbol." }, A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol: { code: 1169, category: ts.DiagnosticCategory.Error, key: "A computed property name in an interface must directly refer to a built-in symbol." }, A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol: { code: 1170, category: ts.DiagnosticCategory.Error, key: "A computed property name in a type literal must directly refer to a built-in symbol." }, @@ -1115,7 +1134,6 @@ 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." }, - Destructuring_declarations_are_not_allowed_in_ambient_contexts: { code: 1183, category: ts.DiagnosticCategory.Error, key: "Destructuring declarations are not allowed in ambient contexts." }, An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1184, 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." }, @@ -1166,12 +1184,20 @@ 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." }, Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { code: 1239, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of parameter decorator when called as an expression." }, Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { code: 1240, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of property decorator when called as an expression." }, Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { code: 1241, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of method decorator when called as an expression." }, + abstract_modifier_can_only_appear_on_a_class_or_method_declaration: { code: 1242, category: ts.DiagnosticCategory.Error, key: "'abstract' modifier can only appear on a class or method declaration." }, + _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." }, 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." }, @@ -1180,7 +1206,6 @@ var ts; Module_0_has_no_exported_member_1: { code: 2305, category: ts.DiagnosticCategory.Error, key: "Module '{0}' has no exported member '{1}'." }, File_0_is_not_a_module: { code: 2306, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not a module." }, Cannot_find_module_0: { code: 2307, category: ts.DiagnosticCategory.Error, key: "Cannot find module '{0}'." }, - A_module_cannot_have_more_than_one_export_assignment: { code: 2308, category: ts.DiagnosticCategory.Error, key: "A module cannot have more than one export assignment." }, An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { code: 2309, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in a module with other exported elements." }, Type_0_recursively_references_itself_as_a_base_type: { code: 2310, category: ts.DiagnosticCategory.Error, key: "Type '{0}' recursively references itself as a base type." }, A_class_may_only_extend_another_class: { code: 2311, category: ts.DiagnosticCategory.Error, key: "A class may only extend another class." }, @@ -1208,10 +1233,10 @@ var ts; this_cannot_be_referenced_in_a_static_property_initializer: { code: 2334, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a static property initializer." }, super_can_only_be_referenced_in_a_derived_class: { code: 2335, category: ts.DiagnosticCategory.Error, key: "'super' can only be referenced in a derived class." }, super_cannot_be_referenced_in_constructor_arguments: { code: 2336, category: ts.DiagnosticCategory.Error, key: "'super' cannot be referenced in constructor arguments." }, - Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: ts.DiagnosticCategory.Error, key: "Super calls are not permitted outside constructors or in nested functions inside constructors" }, - super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: ts.DiagnosticCategory.Error, key: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class" }, + Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: ts.DiagnosticCategory.Error, key: "Super calls are not permitted outside constructors or in nested functions inside constructors." }, + super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: ts.DiagnosticCategory.Error, key: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class." }, 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" }, + 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'." }, Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: ts.DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." }, @@ -1370,6 +1395,29 @@ var ts; No_base_constructor_has_the_specified_number_of_type_arguments: { code: 2508, category: ts.DiagnosticCategory.Error, key: "No base constructor has the specified number of type arguments." }, Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: ts.DiagnosticCategory.Error, key: "Base constructor return type '{0}' is not a class or interface type." }, Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: ts.DiagnosticCategory.Error, key: "Base constructors must all have the same return type." }, + Cannot_create_an_instance_of_the_abstract_class_0: { code: 2511, category: ts.DiagnosticCategory.Error, key: "Cannot create an instance of the abstract class '{0}'." }, + Overload_signatures_must_all_be_abstract_or_not_abstract: { code: 2512, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be abstract or not abstract." }, + Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: { code: 2513, category: ts.DiagnosticCategory.Error, key: "Abstract method '{0}' in class '{1}' cannot be accessed via super expression." }, + Classes_containing_abstract_methods_must_be_marked_abstract: { code: 2514, category: ts.DiagnosticCategory.Error, key: "Classes containing abstract methods must be marked abstract." }, + 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." }, + Constructor_objects_of_abstract_type_cannot_be_assigned_to_constructor_objects_of_non_abstract_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Constructor objects of abstract type cannot be assigned to constructor objects of non-abstract 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." }, + 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." }, + Property_0_in_type_1_is_not_assignable_to_type_2: { code: 2603, category: ts.DiagnosticCategory.Error, key: "Property '{0}' in type '{1}' is not assignable to type '{2}'" }, + JSX_element_type_0_does_not_have_any_construct_or_call_signatures: { code: 2604, category: ts.DiagnosticCategory.Error, key: "JSX element type '{0}' does not have any construct or call signatures." }, + JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements: { code: 2605, category: ts.DiagnosticCategory.Error, key: "JSX element type '{0}' is not a constructor function for JSX elements." }, + Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of JSX spread attribute is not assignable to target property." }, + JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" }, + The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" }, + Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" }, 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}'." }, @@ -1506,15 +1554,18 @@ var ts; File_0_has_unsupported_extension_The_only_supported_extensions_are_1: { code: 6054, category: ts.DiagnosticCategory.Error, key: "File '{0}' has unsupported extension. The only supported extensions are {1}." }, Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: ts.DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: ts.DiagnosticCategory.Message, key: "Do not emit declarations for code that has an '@internal' annotation." }, - Preserve_new_lines_when_emitting_code: { code: 6057, category: ts.DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." }, Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: ts.DiagnosticCategory.Message, key: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." }, File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." }, Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: ts.DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE" }, Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, + Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify JSX code generation: 'preserve' or 'react'" }, + Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: ts.DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." }, 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." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -1531,6 +1582,7 @@ var ts; _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: { code: 7023, category: ts.DiagnosticCategory.Error, key: "'{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." }, Function_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: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function 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." }, Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: ts.DiagnosticCategory.Error, key: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." }, + JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: ts.DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists" }, You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: ts.DiagnosticCategory.Error, key: "'import ... =' can only be used in a .ts file." }, @@ -1547,7 +1599,14 @@ var ts; property_declarations_can_only_be_used_in_a_ts_file: { code: 8014, category: ts.DiagnosticCategory.Error, key: "'property declarations' can only be used in a .ts file." }, enum_declarations_can_only_be_used_in_a_ts_file: { code: 8015, category: ts.DiagnosticCategory.Error, key: "'enum declarations' can only be used in a .ts file." }, type_assertion_expressions_can_only_be_used_in_a_ts_file: { code: 8016, category: ts.DiagnosticCategory.Error, key: "'type assertion expressions' can only be used in a .ts file." }, - decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: ts.DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." } + decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: ts.DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." }, + Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: ts.DiagnosticCategory.Error, key: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." }, + class_expressions_are_not_currently_supported: { code: 9003, category: ts.DiagnosticCategory.Error, key: "'class' expressions are not currently supported." }, + JSX_attributes_must_only_be_assigned_a_non_empty_expression: { code: 17000, category: ts.DiagnosticCategory.Error, key: "JSX attributes must only be assigned a non-empty 'expression'." }, + JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { code: 17001, category: ts.DiagnosticCategory.Error, key: "JSX elements cannot have multiple attributes with the same name." }, + 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." } }; })(ts || (ts = {})); /// @@ -1555,68 +1614,71 @@ var ts; var ts; (function (ts) { var textToToken = { - "any": 112, - "as": 111, - "boolean": 113, - "break": 66, - "case": 67, - "catch": 68, - "class": 69, - "continue": 71, - "const": 70, - "constructor": 114, - "debugger": 72, - "declare": 115, - "default": 73, - "delete": 74, - "do": 75, - "else": 76, - "enum": 77, - "export": 78, - "extends": 79, - "false": 80, - "finally": 81, - "for": 82, - "from": 126, - "function": 83, - "get": 116, - "if": 84, - "implements": 102, - "import": 85, - "in": 86, - "instanceof": 87, - "interface": 103, - "is": 117, - "let": 104, - "module": 118, - "namespace": 119, - "new": 88, - "null": 89, - "number": 121, - "package": 105, - "private": 106, - "protected": 107, - "public": 108, - "require": 120, - "return": 90, - "set": 122, - "static": 109, - "string": 123, - "super": 91, - "switch": 92, - "symbol": 124, - "this": 93, - "throw": 94, - "true": 95, - "try": 96, - "type": 125, - "typeof": 97, - "var": 98, - "void": 99, - "while": 100, - "with": 101, - "yield": 110, - "of": 127, + "abstract": 112, + "any": 114, + "as": 113, + "boolean": 117, + "break": 67, + "case": 68, + "catch": 69, + "class": 70, + "continue": 72, + "const": 71, + "constructor": 118, + "debugger": 73, + "declare": 119, + "default": 74, + "delete": 75, + "do": 76, + "else": 77, + "enum": 78, + "export": 79, + "extends": 80, + "false": 81, + "finally": 82, + "for": 83, + "from": 130, + "function": 84, + "get": 120, + "if": 85, + "implements": 103, + "import": 86, + "in": 87, + "instanceof": 88, + "interface": 104, + "is": 121, + "let": 105, + "module": 122, + "namespace": 123, + "new": 89, + "null": 90, + "number": 125, + "package": 106, + "private": 107, + "protected": 108, + "public": 109, + "require": 124, + "return": 91, + "set": 126, + "static": 110, + "string": 127, + "super": 92, + "switch": 93, + "symbol": 128, + "this": 94, + "throw": 95, + "true": 96, + "try": 97, + "type": 129, + "typeof": 98, + "var": 99, + "void": 100, + "while": 101, + "with": 102, + "yield": 111, + "async": 115, + "await": 116, + "of": 131, "{": 14, "}": 15, "(": 16, @@ -1628,46 +1690,47 @@ var ts; ";": 22, ",": 23, "<": 24, - ">": 25, - "<=": 26, - ">=": 27, - "==": 28, - "!=": 29, - "===": 30, - "!==": 31, - "=>": 32, - "+": 33, - "-": 34, - "*": 35, - "/": 36, - "%": 37, - "++": 38, - "--": 39, - "<<": 40, - ">>": 41, - ">>>": 42, - "&": 43, - "|": 44, - "^": 45, - "!": 46, - "~": 47, - "&&": 48, - "||": 49, - "?": 50, - ":": 51, - "=": 53, - "+=": 54, - "-=": 55, - "*=": 56, - "/=": 57, - "%=": 58, - "<<=": 59, - ">>=": 60, - ">>>=": 61, - "&=": 62, - "|=": 63, - "^=": 64, - "@": 52 + ">": 26, + "<=": 27, + ">=": 28, + "==": 29, + "!=": 30, + "===": 31, + "!==": 32, + "=>": 33, + "+": 34, + "-": 35, + "*": 36, + "/": 37, + "%": 38, + "++": 39, + "--": 40, + "<<": 41, + ">": 42, + ">>>": 43, + "&": 44, + "|": 45, + "^": 46, + "!": 47, + "~": 48, + "&&": 49, + "||": 50, + "?": 51, + ":": 52, + "=": 54, + "+=": 55, + "-=": 56, + "*=": 57, + "/=": 58, + "%=": 59, + "<<=": 60, + ">>=": 61, + ">>>=": 62, + "&=": 63, + "|=": 64, + "^=": 65, + "@": 53 }; 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,]; @@ -1708,9 +1771,9 @@ var ts; } function makeReverseMap(source) { var result = []; - for (var name_3 in source) { - if (source.hasOwnProperty(name_3)) { - result[source[name_3]] = name_3; + for (var name_4 in source) { + if (source.hasOwnProperty(name_4)) { + result[source[name_4]] = name_4; } } return result; @@ -1804,8 +1867,8 @@ var ts; // \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. + // 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 || @@ -2033,7 +2096,8 @@ var ts; ch > 127 && isUnicodeIdentifierPart(ch, languageVersion); } ts.isIdentifierPart = isIdentifierPart; - function createScanner(languageVersion, skipTrivia, text, onError, start, length) { + function createScanner(languageVersion, skipTrivia, languageVariant, text, onError, start, length) { + if (languageVariant === void 0) { languageVariant = 0; } var pos; var end; var startPos; @@ -2053,15 +2117,19 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 65 || token > 101; }, - isReservedWord: function () { return token >= 66 && token <= 101; }, + isIdentifier: function () { return token === 66 || token > 102; }, + isReservedWord: function () { return token >= 67 && token <= 102; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, reScanTemplateToken: reScanTemplateToken, + scanJsxIdentifier: scanJsxIdentifier, + reScanJsxToken: reScanJsxToken, + scanJsxToken: scanJsxToken, scan: scan, setText: setText, setScriptTarget: setScriptTarget, + setLanguageVariant: setLanguageVariant, setOnError: setOnError, setTextPos: setTextPos, tryScan: tryScan, @@ -2364,7 +2432,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 65; + return token = 66; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); @@ -2430,11 +2498,11 @@ var ts; case 33: if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 31; + return pos += 3, token = 32; } - return pos += 2, token = 29; + return pos += 2, token = 30; } - return pos++, token = 46; + return pos++, token = 47; case 34: case 39: tokenValue = scanString(); @@ -2443,44 +2511,44 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 58; + return pos += 2, token = 59; } - return pos++, token = 37; + return pos++, token = 38; case 38: if (text.charCodeAt(pos + 1) === 38) { - return pos += 2, token = 48; + return pos += 2, token = 49; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 62; + return pos += 2, token = 63; } - return pos++, token = 43; + return pos++, token = 44; case 40: return pos++, token = 16; case 41: return pos++, token = 17; case 42: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 56; + return pos += 2, token = 57; } - return pos++, token = 35; + return pos++, token = 36; case 43: if (text.charCodeAt(pos + 1) === 43) { - return pos += 2, token = 38; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 54; - } - return pos++, token = 33; - case 44: - return pos++, token = 23; - case 45: - if (text.charCodeAt(pos + 1) === 45) { return pos += 2, token = 39; } if (text.charCodeAt(pos + 1) === 61) { return pos += 2, token = 55; } return pos++, token = 34; + case 44: + return pos++, token = 23; + case 45: + if (text.charCodeAt(pos + 1) === 45) { + return pos += 2, token = 40; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 56; + } + return pos++, token = 35; case 46: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanNumber(); @@ -2533,9 +2601,9 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 57; + return pos += 2, token = 58; } - return pos++, token = 36; + return pos++, token = 37; case 48: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) { pos += 2; @@ -2583,7 +2651,7 @@ var ts; tokenValue = "" + scanNumber(); return token = 7; case 58: - return pos++, token = 51; + return pos++, token = 52; case 59: return pos++, token = 22; case 60: @@ -2598,12 +2666,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 60) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 59; + return pos += 3, token = 60; } - return pos += 2, token = 40; + return pos += 2, token = 41; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 26; + return pos += 2, token = 27; + } + if (text.charCodeAt(pos + 1) === 47 && languageVariant === 1) { + return pos += 2, token = 25; } return pos++, token = 24; case 61: @@ -2618,14 +2689,14 @@ var ts; } if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 30; + return pos += 3, token = 31; } - return pos += 2, token = 28; + return pos += 2, token = 29; } if (text.charCodeAt(pos + 1) === 62) { - return pos += 2, token = 32; + return pos += 2, token = 33; } - return pos++, token = 53; + return pos++, token = 54; case 62: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -2636,34 +2707,34 @@ var ts; return token = 6; } } - return pos++, token = 25; + return pos++, token = 26; case 63: - return pos++, token = 50; + return pos++, token = 51; case 91: return pos++, token = 18; case 93: return pos++, token = 19; case 94: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 64; + return pos += 2, token = 65; } - return pos++, token = 45; + return pos++, token = 46; case 123: return pos++, token = 14; case 124: if (text.charCodeAt(pos + 1) === 124) { - return pos += 2, token = 49; + return pos += 2, token = 50; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 63; + return pos += 2, token = 64; } - return pos++, token = 44; + return pos++, token = 45; case 125: return pos++, token = 15; case 126: - return pos++, token = 47; + return pos++, token = 48; case 64: - return pos++, token = 52; + return pos++, token = 53; case 92: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { @@ -2699,27 +2770,27 @@ var ts; } } function reScanGreaterToken() { - if (token === 25) { + if (token === 26) { if (text.charCodeAt(pos) === 62) { if (text.charCodeAt(pos + 1) === 62) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 61; + return pos += 3, token = 62; } - return pos += 2, token = 42; + return pos += 2, token = 43; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 60; + return pos += 2, token = 61; } - return pos++, token = 41; + return pos++, token = 42; } if (text.charCodeAt(pos) === 61) { - return pos++, token = 27; + return pos++, token = 28; } } return token; } function reScanSlashToken() { - if (token === 36 || token === 57) { + if (token === 37 || token === 58) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -2767,6 +2838,53 @@ var ts; pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } + function reScanJsxToken() { + pos = tokenPos = startPos; + return token = scanJsxToken(); + } + function scanJsxToken() { + startPos = tokenPos = pos; + if (pos >= end) { + return token = 1; + } + var char = text.charCodeAt(pos); + if (char === 60) { + if (text.charCodeAt(pos + 1) === 47) { + pos += 2; + return token = 25; + } + pos++; + return token = 24; + } + if (char === 123) { + pos++; + return token = 14; + } + while (pos < end) { + pos++; + char = text.charCodeAt(pos); + if ((char === 123) || (char === 60)) { + break; + } + } + return token = 233; + } + function scanJsxIdentifier() { + if (token === 66) { + var firstCharPosition = pos; + while (pos < end) { + var ch = text.charCodeAt(pos); + if (ch === 45 || ((firstCharPosition === pos) ? isIdentifierStart(ch) : isIdentifierPart(ch))) { + pos++; + } + else { + break; + } + } + tokenValue += text.substr(firstCharPosition, pos - firstCharPosition); + } + return token; + } function speculationHelper(callback, isLookahead) { var savePos = pos; var saveStartPos = startPos; @@ -2802,6 +2920,9 @@ var ts; function setScriptTarget(scriptTarget) { languageVersion = scriptTarget; } + function setLanguageVariant(variant) { + languageVariant = variant; + } function setTextPos(textPos) { ts.Debug.assert(textPos >= 0); pos = textPos; @@ -2821,16 +2942,16 @@ var ts; (function (ts) { ts.bindTime = 0; function getModuleInstanceState(node) { - if (node.kind === 205 || node.kind === 206) { + if (node.kind === 212 || node.kind === 213) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 212 || node.kind === 211) && !(node.flags & 1)) { + else if ((node.kind === 219 || node.kind === 218) && !(node.flags & 1)) { return 0; } - else if (node.kind === 209) { + else if (node.kind === 216) { var state = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -2846,7 +2967,7 @@ var ts; }); return state; } - else if (node.kind === 208) { + else if (node.kind === 215) { return getModuleInstanceState(node.body); } else { @@ -2898,10 +3019,10 @@ var ts; } function getDeclarationName(node) { if (node.name) { - if (node.kind === 208 && node.name.kind === 8) { + if (node.kind === 215 && node.name.kind === 8) { return '"' + node.name.text + '"'; } - if (node.name.kind === 129) { + if (node.name.kind === 133) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -2909,23 +3030,23 @@ var ts; return node.name.text; } switch (node.kind) { - case 137: - return "__constructor"; - case 145: - case 140: - return "__call"; - case 146: case 141: + return "__constructor"; + case 149: + case 144: + return "__call"; + case 150: + case 145: return "__new"; - case 142: + case 146: return "__index"; - case 218: + case 225: return "__export"; - case 217: + case 224: return node.isExportEquals ? "export=" : "default"; - case 203: - case 204: - return node.flags & 256 ? "default" : undefined; + case 210: + case 211: + return node.flags & 1024 ? "default" : undefined; } } function getDisplayName(node) { @@ -2933,7 +3054,7 @@ var ts; } function declareSymbol(symbolTable, parent, node, includes, excludes) { ts.Debug.assert(!ts.hasDynamicName(node)); - var name = node.flags & 256 && parent ? "default" : getDeclarationName(node); + var name = node.flags & 1024 && parent ? "default" : getDeclarationName(node); var symbol; if (name !== undefined) { symbol = ts.hasProperty(symbolTable, name) @@ -2966,7 +3087,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 220 || (node.kind === 211 && hasExportModifier)) { + if (node.kind === 227 || (node.kind === 218 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -2974,7 +3095,7 @@ var ts; } } else { - if (hasExportModifier || container.flags & 65536) { + if (hasExportModifier || container.flags & 262144) { var exportKind = (symbolFlags & 107455 ? 1048576 : 0) | (symbolFlags & 793056 ? 2097152 : 0) | (symbolFlags & 1536 ? 4194304 : 0); @@ -3012,37 +3133,37 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 177: - case 204: - case 205: - case 207: - case 148: - case 157: + case 183: + case 211: + case 212: + case 214: + case 152: + case 162: return 1; - case 140: - case 141: - case 142: - case 136: - case 135: - case 203: - case 137: - case 138: - case 139: + case 144: case 145: case 146: - case 165: - case 166: - case 208: - case 230: - case 206: - return 5; - case 226: - case 189: - case 190: - case 191: + case 140: + case 139: case 210: + case 141: + case 142: + case 143: + case 149: + case 150: + case 170: + case 171: + case 215: + case 245: + case 213: + return 5; + case 241: + case 196: + case 197: + case 198: + case 217: return 2; - case 182: + case 189: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -3058,33 +3179,33 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 208: + case 215: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 230: + case 245: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 177: - case 204: + case 183: + case 211: return declareClassMember(node, symbolFlags, symbolExcludes); - case 207: + case 214: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 148: - case 157: - case 205: + case 152: + case 162: + case 212: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); + case 149: + case 150: + case 144: case 145: case 146: case 140: + case 139: case 141: case 142: - case 136: - case 135: - case 137: - case 138: - case 139: - case 203: - case 165: - case 166: - case 206: + case 143: + case 210: + case 170: + case 171: + case 213: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -3108,11 +3229,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 230 ? node : node.body; - if (body.kind === 230 || body.kind === 209) { + var body = node.kind === 245 ? node : node.body; + if (body.kind === 245 || body.kind === 216) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 218 || stat.kind === 217) { + if (stat.kind === 225 || stat.kind === 224) { return true; } } @@ -3121,10 +3242,10 @@ var ts; } function setExportContextFlag(node) { if (isAmbientContext(node) && !hasExportDeclarations(node)) { - node.flags |= 65536; + node.flags |= 262144; } else { - node.flags &= ~65536; + node.flags &= ~262144; } } function bindModuleDeclaration(node) { @@ -3162,11 +3283,11 @@ var ts; var seen = {}; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 65) { + if (prop.name.kind !== 66) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 227 || prop.kind === 228 || prop.kind === 136 + var currentKind = prop.kind === 242 || prop.kind === 243 || prop.kind === 140 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -3188,10 +3309,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 208: + case 215: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 230: + case 245: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -3209,8 +3330,8 @@ var ts; } function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 102 && - node.originalKeywordKind <= 110 && + node.originalKeywordKind >= 103 && + node.originalKeywordKind <= 111 && !ts.isIdentifierName(node)) { if (!file.parseDiagnostics.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); @@ -3237,17 +3358,17 @@ var ts; } } function checkStrictModeDeleteExpression(node) { - if (inStrictMode && node.expression.kind === 65) { + if (inStrictMode && node.expression.kind === 66) { var span = ts.getErrorSpanForNode(file, node.expression); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 65 && + return node.kind === 66 && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 65) { + if (name && name.kind === 66) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { var span = ts.getErrorSpanForNode(file, name); @@ -3270,7 +3391,7 @@ var ts; } } function checkStrictModeNumericLiteral(node) { - if (inStrictMode && node.flags & 16384) { + if (inStrictMode && node.flags & 65536) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); } } @@ -3281,7 +3402,7 @@ var ts; } function checkStrictModePrefixUnaryExpression(node) { if (inStrictMode) { - if (node.operator === 38 || node.operator === 39) { + if (node.operator === 39 || node.operator === 40) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -3310,17 +3431,17 @@ var ts; } function updateStrictMode(node) { switch (node.kind) { - case 230: - case 209: + case 245: + case 216: updateStrictModeStatementList(node.statements); return; - case 182: + case 189: if (ts.isFunctionLike(node.parent)) { updateStrictModeStatementList(node.statements); } return; - case 204: - case 177: + case 211: + case 183: inStrictMode = true; return; } @@ -3343,87 +3464,88 @@ var ts; } function bindWorker(node) { switch (node.kind) { - case 65: + case 66: return checkStrictModeIdentifier(node); - case 172: + case 178: return checkStrictModeBinaryExpression(node); - case 226: + case 241: return checkStrictModeCatchClause(node); - case 167: + case 172: return checkStrictModeDeleteExpression(node); case 7: return checkStrictModeNumericLiteral(node); - case 171: + case 177: return checkStrictModePostfixUnaryExpression(node); - case 170: + case 176: return checkStrictModePrefixUnaryExpression(node); - case 195: + case 202: return checkStrictModeWithStatement(node); - case 130: - return declareSymbolAndAddToSymbolTable(node, 262144, 530912); - case 131: - return bindParameter(node); - case 201: - case 155: - return bindVariableDeclarationOrBindingElement(node); case 134: - case 133: - return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); - case 227: - case 228: - return bindPropertyOrMethodOrAccessor(node, 4, 107455); - case 229: - return bindPropertyOrMethodOrAccessor(node, 8, 107455); - case 140: - case 141: - case 142: - return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 136: + return declareSymbolAndAddToSymbolTable(node, 262144, 530912); case 135: - return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); - case 203: - checkStrictModeFunctionName(node); - return declareSymbolAndAddToSymbolTable(node, 16, 106927); - case 137: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); + return bindParameter(node); + case 208: + case 160: + return bindVariableDeclarationOrBindingElement(node); case 138: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); - case 139: - return bindPropertyOrMethodOrAccessor(node, 65536, 74687); + case 137: + return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); + case 242: + case 243: + return bindPropertyOrMethodOrAccessor(node, 4, 107455); + case 244: + return bindPropertyOrMethodOrAccessor(node, 8, 107455); + case 144: case 145: case 146: - return bindFunctionOrConstructorType(node); - case 148: - return bindAnonymousDeclaration(node, 2048, "__type"); - case 157: - return bindObjectLiteralExpression(node); - case 165: - case 166: + return declareSymbolAndAddToSymbolTable(node, 131072, 0); + case 140: + case 139: + return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); + case 210: checkStrictModeFunctionName(node); - return bindAnonymousDeclaration(node, 16, "__function"); - case 177: - case 204: - return bindClassLikeDeclaration(node); - case 205: - return bindBlockScopedDeclaration(node, 64, 792992); - case 206: - return bindBlockScopedDeclaration(node, 524288, 793056); - case 207: - return bindEnumDeclaration(node); - case 208: - return bindModuleDeclaration(node); + return declareSymbolAndAddToSymbolTable(node, 16, 106927); + case 141: + return declareSymbolAndAddToSymbolTable(node, 16384, 0); + case 142: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 143: + return bindPropertyOrMethodOrAccessor(node, 65536, 74687); + case 149: + case 150: + return bindFunctionOrConstructorType(node); + case 152: + return bindAnonymousDeclaration(node, 2048, "__type"); + case 162: + return bindObjectLiteralExpression(node); + case 170: + case 171: + checkStrictModeFunctionName(node); + var bindingName = node.name ? node.name.text : "__function"; + return bindAnonymousDeclaration(node, 16, bindingName); + case 183: case 211: - case 214: - case 216: - case 220: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + return bindClassLikeDeclaration(node); + case 212: + return bindBlockScopedDeclaration(node, 64, 792960); case 213: - return bindImportClause(node); + return bindBlockScopedDeclaration(node, 524288, 793056); + case 214: + return bindEnumDeclaration(node); + case 215: + return bindModuleDeclaration(node); case 218: + case 221: + case 223: + case 227: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 220: + return bindImportClause(node); + case 225: return bindExportDeclaration(node); - case 217: + case 224: return bindExportAssignment(node); - case 230: + case 245: return bindSourceFileIfExternalModule(); } } @@ -3437,7 +3559,7 @@ var ts; if (!container.symbol || !container.symbol.exports) { bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } - else if (node.expression.kind === 65) { + else if (node.expression.kind === 66) { declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 107455 | 8388608); } else { @@ -3458,11 +3580,12 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 204) { - bindBlockScopedDeclaration(node, 32, 899583); + if (node.kind === 211) { + bindBlockScopedDeclaration(node, 32, 899519); } else { - bindAnonymousDeclaration(node, 32, "__class"); + var bindingName = node.name ? node.name.text : "__class"; + bindAnonymousDeclaration(node, 32, bindingName); } var symbol = node.symbol; var prototypeSymbol = createSymbol(4 | 134217728, "prototype"); @@ -3507,7 +3630,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 1, 107455); } if (node.flags & 112 && - node.parent.kind === 137 && + node.parent.kind === 141 && ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455); @@ -3525,10 +3648,12 @@ var ts; (function (ts) { function getDeclarationOfKind(symbol, kind) { var declarations = symbol.declarations; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; - if (declaration.kind === kind) { - return declaration; + if (declarations) { + for (var _i = 0; _i < declarations.length; _i++) { + var declaration = declarations[_i]; + if (declaration.kind === kind) { + return declaration; + } } } return undefined; @@ -3569,21 +3694,21 @@ var ts; ts.getFullWidth = getFullWidth; function containsParseError(node) { aggregateChildData(node); - return (node.parserContextFlags & 128) !== 0; + return (node.parserContextFlags & 64) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.parserContextFlags & 256)) { - var thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & 32) !== 0) || + if (!(node.parserContextFlags & 128)) { + var thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & 16) !== 0) || ts.forEachChild(node, containsParseError); if (thisNodeOrAnySubNodesHasError) { - node.parserContextFlags |= 128; + node.parserContextFlags |= 64; } - node.parserContextFlags |= 256; + node.parserContextFlags |= 128; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 230) { + while (node && node.kind !== 245) { node = node.parent; } return node; @@ -3608,7 +3733,7 @@ var ts; if (!node) { return true; } - return node.pos === node.end && node.kind !== 1; + return node.pos === node.end && node.pos >= 0 && node.kind !== 1; } ts.nodeIsMissing = nodeIsMissing; function nodeIsPresent(node) { @@ -3629,12 +3754,13 @@ var ts; return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end); } ts.getNonDecoratorTokenPosOfNode = getNonDecoratorTokenPosOfNode; - function getSourceTextOfNodeFromSourceFile(sourceFile, node) { + function getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia) { + if (includeTrivia === void 0) { includeTrivia = false; } if (nodeIsMissing(node)) { return ""; } var text = sourceFile.text; - return text.substring(ts.skipTrivia(text, node.pos), node.end); + return text.substring(includeTrivia ? node.pos : ts.skipTrivia(text, node.pos), node.end); } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function getTextOfNodeFromSourceText(sourceText, node) { @@ -3644,8 +3770,9 @@ var ts; return sourceText.substring(ts.skipTrivia(sourceText, node.pos), node.end); } ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText; - function getTextOfNode(node) { - return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node); + function getTextOfNode(node, includeTrivia) { + if (includeTrivia === void 0) { includeTrivia = false; } + return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); } ts.getTextOfNode = getTextOfNode; function escapeIdentifier(identifier) { @@ -3661,7 +3788,7 @@ var ts; } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { - return (getCombinedNodeFlags(declaration) & 12288) !== 0 || + return (getCombinedNodeFlags(declaration) & 49152) !== 0 || isCatchClauseVariableDeclaration(declaration); } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; @@ -3672,15 +3799,15 @@ var ts; return current; } switch (current.kind) { - case 230: - case 210: - case 226: - case 208: - case 189: - case 190: - case 191: + case 245: + case 217: + case 241: + case 215: + case 196: + case 197: + case 198: return current; - case 182: + case 189: if (!isFunctionLike(current.parent)) { return current; } @@ -3691,9 +3818,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 201 && + declaration.kind === 208 && declaration.parent && - declaration.parent.kind === 226; + declaration.parent.kind === 241; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function declarationNameToString(name) { @@ -3720,7 +3847,7 @@ var ts; } ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; function getSpanOfTokenAtPosition(sourceFile, pos) { - var scanner = ts.createScanner(sourceFile.languageVersion, true, sourceFile.text, undefined, pos); + var scanner = ts.createScanner(sourceFile.languageVersion, true, sourceFile.languageVariant, sourceFile.text, undefined, pos); scanner.scan(); var start = scanner.getTokenPos(); return ts.createTextSpanFromBounds(start, scanner.getTextPos()); @@ -3729,22 +3856,22 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 230: + case 245: 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 201: - case 155: - case 204: - case 177: - case 205: case 208: - case 207: - case 229: - case 203: - case 165: + case 160: + case 211: + case 183: + case 212: + case 215: + case 214: + case 244: + case 210: + case 170: errorNode = node.name; break; } @@ -3762,15 +3889,15 @@ var ts; } ts.isExternalModule = isExternalModule; function isDeclarationFile(file) { - return (file.flags & 2048) !== 0; + return (file.flags & 8192) !== 0; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 207 && isConst(node); + return node.kind === 214 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 155 || isBindingPattern(node))) { + while (node && (node.kind === 160 || isBindingPattern(node))) { node = node.parent; } return node; @@ -3778,33 +3905,33 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 201) { + if (node.kind === 208) { node = node.parent; } - if (node && node.kind === 202) { + if (node && node.kind === 209) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 183) { + if (node && node.kind === 190) { flags |= node.flags; } return flags; } ts.getCombinedNodeFlags = getCombinedNodeFlags; function isConst(node) { - return !!(getCombinedNodeFlags(node) & 8192); + return !!(getCombinedNodeFlags(node) & 32768); } ts.isConst = isConst; function isLet(node) { - return !!(getCombinedNodeFlags(node) & 4096); + return !!(getCombinedNodeFlags(node) & 16384); } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 185 && node.expression.kind === 8; + return node.kind === 192 && node.expression.kind === 8; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - if (node.kind === 131 || node.kind === 130) { + if (node.kind === 135 || node.kind === 134) { return ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)); } else { @@ -3823,68 +3950,68 @@ var ts; ts.getJsDocComments = getJsDocComments; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (144 <= node.kind && node.kind <= 152) { + if (148 <= node.kind && node.kind <= 157) { return true; } switch (node.kind) { - case 112: - case 121: - case 123: - case 113: - case 124: - return true; - case 99: - return node.parent.kind !== 169; - case 8: - return node.parent.kind === 131; - case 179: - return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 65: - if (node.parent.kind === 128 && node.parent.right === node) { - node = node.parent; - } - else if (node.parent.kind === 158 && node.parent.name === node) { - node = node.parent; - } + case 114: + case 125: + case 127: + case 117: case 128: - case 158: - ts.Debug.assert(node.kind === 65 || node.kind === 128 || node.kind === 158, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + return true; + case 100: + return node.parent.kind !== 174; + case 8: + return node.parent.kind === 135; + case 185: + return !isExpressionWithTypeArgumentsInClassExtendsClause(node); + case 66: + if (node.parent.kind === 132 && node.parent.right === node) { + node = node.parent; + } + else if (node.parent.kind === 163 && node.parent.name === node) { + node = node.parent; + } + case 132: + case 163: + ts.Debug.assert(node.kind === 66 || node.kind === 132 || node.kind === 163, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); var parent_1 = node.parent; - if (parent_1.kind === 147) { + if (parent_1.kind === 151) { return false; } - if (144 <= parent_1.kind && parent_1.kind <= 152) { + if (148 <= parent_1.kind && parent_1.kind <= 157) { return true; } switch (parent_1.kind) { - case 179: + case 185: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 130: - return node === parent_1.constraint; case 134: - case 133: - case 131: - case 201: + return node === parent_1.constraint; + case 138: + case 137: + case 135: + case 208: + return node === parent_1.type; + case 210: + case 170: + case 171: + case 141: + case 140: + case 139: + case 142: + case 143: + return node === parent_1.type; + case 144: + case 145: + case 146: + return node === parent_1.type; + case 168: return node === parent_1.type; - case 203: case 165: case 166: - case 137: - case 136: - case 135: - case 138: - case 139: - return node === parent_1.type; - case 140: - case 141: - case 142: - return node === parent_1.type; - case 163: - return node === parent_1.type; - case 160: - case 161: return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 162: + case 167: return false; } } @@ -3895,23 +4022,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 194: + case 201: return visitor(node); - case 210: - case 182: - case 186: - case 187: - case 188: + case 217: case 189: - case 190: - case 191: + case 193: + case 194: case 195: case 196: - case 223: - case 224: case 197: - case 199: - case 226: + case 198: + case 202: + case 203: + case 238: + case 239: + case 204: + case 206: + case 241: return ts.forEachChild(node, traverse); } } @@ -3921,24 +4048,24 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 175: + case 181: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 207: - case 205: - case 208: - case 206: - case 204: - case 177: + case 214: + case 212: + case 215: + case 213: + case 211: + case 183: return; default: if (isFunctionLike(node)) { - var name_4 = node.name; - if (name_4 && name_4.kind === 129) { - traverse(name_4.expression); + var name_5 = node.name; + if (name_5 && name_5.kind === 133) { + traverse(name_5.expression); return; } } @@ -3952,14 +4079,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 155: - case 229: - case 131: - case 227: - case 134: - case 133: - case 228: - case 201: + case 160: + case 244: + case 135: + case 242: + case 138: + case 137: + case 243: + case 208: return true; } } @@ -3967,29 +4094,29 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 138 || node.kind === 139); + return node && (node.kind === 142 || node.kind === 143); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 204 || node.kind === 177); + return node && (node.kind === 211 || node.kind === 183); } ts.isClassLike = isClassLike; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 137: - case 165: - case 203: - case 166: - case 136: - case 135: - case 138: - case 139: - case 140: case 141: + case 170: + case 210: + case 171: + case 140: + case 139: case 142: + case 143: + case 144: case 145: case 146: + case 149: + case 150: return true; } } @@ -3997,11 +4124,11 @@ var ts; } ts.isFunctionLike = isFunctionLike; function isFunctionBlock(node) { - return node && node.kind === 182 && isFunctionLike(node.parent); + return node && node.kind === 189 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 136 && node.parent.kind === 157; + return node && node.kind === 140 && node.parent.kind === 162; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -4029,36 +4156,36 @@ var ts; return undefined; } switch (node.kind) { - case 129: + case 133: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 132: - if (node.parent.kind === 131 && isClassElement(node.parent.parent)) { + case 136: + if (node.parent.kind === 135 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 166: + case 171: if (!includeArrowFunctions) { continue; } - case 203: - case 165: - case 208: - case 134: - case 133: - case 136: - case 135: - case 137: + case 210: + case 170: + case 215: case 138: + case 137: + case 140: case 139: - case 207: - case 230: + case 141: + case 142: + case 143: + case 214: + case 245: return node; } } @@ -4070,40 +4197,55 @@ var ts; if (!node) return node; switch (node.kind) { - case 129: + case 133: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 132: - if (node.parent.kind === 131 && isClassElement(node.parent.parent)) { + case 136: + if (node.parent.kind === 135 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 203: - case 165: - case 166: + case 210: + case 170: + case 171: if (!includeFunctions) { continue; } - case 134: - case 133: - case 136: - case 135: - case 137: case 138: + case 137: + case 140: case 139: + case 141: + case 142: + case 143: return node; } } } ts.getSuperContainer = getSuperContainer; + function getEntityNameFromTypeNode(node) { + if (node) { + switch (node.kind) { + case 148: + return node.typeName; + case 185: + return node.expression; + case 66: + case 132: + return node; + } + } + return undefined; + } + ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { - if (node.kind === 162) { + if (node.kind === 167) { return node.tag; } return node.expression; @@ -4111,40 +4253,40 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 204: + case 211: return true; - case 134: - return node.parent.kind === 204; - case 131: - return node.parent.body && node.parent.parent.kind === 204; case 138: - case 139: - case 136: - return node.body && node.parent.kind === 204; + return node.parent.kind === 211; + case 135: + return node.parent.body && node.parent.parent.kind === 211; + case 142: + case 143: + case 140: + return node.body && node.parent.kind === 211; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 204: - if (node.decorators) { - return true; - } - return false; - case 134: - case 131: + case 211: if (node.decorators) { return true; } return false; case 138: + case 135: + if (node.decorators) { + return true; + } + return false; + case 142: if (node.body && node.decorators) { return true; } return false; - case 136: - case 139: + case 140: + case 143: if (node.body && node.decorators) { return true; } @@ -4155,10 +4297,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 204: + case 211: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 136: - case 139: + case 140: + case 143: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -4170,88 +4312,92 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function isExpression(node) { switch (node.kind) { - case 93: - case 91: - case 89: - case 95: - case 80: + case 94: + case 92: + case 90: + case 96: + case 81: case 9: - case 156: - case 157: - case 158: - case 159: - case 160: case 161: case 162: case 163: case 164: case 165: - case 177: case 166: - case 169: case 167: + case 186: case 168: + case 169: case 170: + case 183: case 171: + case 174: case 172: case 173: case 176: - case 174: - case 10: + case 177: case 178: - case 175: + case 179: + case 182: + case 180: + case 10: + case 184: + case 230: + case 231: + case 181: return true; - case 128: - while (node.parent.kind === 128) { + case 132: + while (node.parent.kind === 132) { node = node.parent; } - return node.parent.kind === 147; - case 65: - if (node.parent.kind === 147) { + return node.parent.kind === 151; + case 66: + if (node.parent.kind === 151) { return true; } case 7: case 8: var parent_2 = node.parent; switch (parent_2.kind) { - case 201: - case 131: - case 134: - case 133: - case 229: - case 227: - case 155: + case 208: + case 135: + case 138: + case 137: + case 244: + case 242: + case 160: return parent_2.initializer === node; - case 185: - case 186: - case 187: - case 188: + case 192: + case 193: case 194: case 195: - case 196: - case 223: - case 198: - case 196: + case 201: + case 202: + case 203: + case 238: + case 205: + case 203: return parent_2.expression === node; - case 189: + case 196: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 202) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 209) || forStatement.condition === node || forStatement.incrementor === node; - case 190: - case 191: + case 197: + case 198: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 202) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 209) || forInStatement.expression === node; - case 163: + case 168: + case 186: return node === parent_2.expression; - case 180: + case 187: return node === parent_2.expression; - case 129: + case 133: return node === parent_2.expression; - case 132: + case 136: return true; - case 179: + case 185: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -4269,7 +4415,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 211 && node.moduleReference.kind === 222; + return node.kind === 218 && node.moduleReference.kind === 229; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -4278,20 +4424,20 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 211 && node.moduleReference.kind !== 222; + return node.kind === 218 && node.moduleReference.kind !== 229; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function getExternalModuleName(node) { - if (node.kind === 212) { + if (node.kind === 219) { return node.moduleSpecifier; } - if (node.kind === 211) { + if (node.kind === 218) { var reference = node.moduleReference; - if (reference.kind === 222) { + if (reference.kind === 229) { return reference.expression; } } - if (node.kind === 218) { + if (node.kind === 225) { return node.moduleSpecifier; } } @@ -4299,15 +4445,15 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 131: - return node.questionToken !== undefined; - case 136: case 135: return node.questionToken !== undefined; - case 228: - case 227: - case 134: - case 133: + case 140: + case 139: + return node.questionToken !== undefined; + case 243: + case 242: + case 138: + case 137: return node.questionToken !== undefined; } } @@ -4315,9 +4461,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 243 && + return node.kind === 258 && node.parameters.length > 0 && - node.parameters[0].type.kind === 245; + node.parameters[0].type.kind === 260; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -4331,27 +4477,27 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 251); + return getJSDocTag(node, 266); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 250); + return getJSDocTag(node, 265); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 252); + return getJSDocTag(node, 267); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 65) { + if (parameter.name && parameter.name.kind === 66) { var parameterName = parameter.name.text; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 249) { + if (t.kind === 264) { var parameterTag = t; - var name_5 = parameterTag.preParameterName || parameterTag.postParameterName; - if (name_5.text === parameterName) { + var name_6 = parameterTag.preParameterName || parameterTag.postParameterName; + if (name_6.text === parameterName) { return t; } } @@ -4366,13 +4512,13 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { if (node) { - if (node.parserContextFlags & 64) { - if (node.type && node.type.kind === 244) { + if (node.parserContextFlags & 32) { + if (node.type && node.type.kind === 259) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 244; + return paramTag.typeExpression.type.kind === 259; } } return node.dotDotDotToken !== undefined; @@ -4393,12 +4539,12 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 154 || node.kind === 153); + return !!node && (node.kind === 159 || node.kind === 158); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { while (node) { - if (node.flags & (2 | 2048)) { + if (node.flags & (2 | 8192)) { return true; } node = node.parent; @@ -4408,34 +4554,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 166: - case 155: - case 204: - case 177: - case 137: - case 207: - case 229: - case 220: - case 203: - case 165: - case 138: - case 213: + case 171: + case 160: case 211: - case 216: - case 205: - case 136: - case 135: - case 208: + case 183: + case 141: case 214: - case 131: + case 244: case 227: - case 134: - case 133: + case 210: + case 170: + case 142: + case 220: + case 218: + case 223: + case 212: + case 140: case 139: - case 228: - case 206: - case 130: - case 201: + case 215: + case 221: + case 135: + case 242: + case 138: + case 137: + case 143: + case 243: + case 213: + case 134: + case 208: return true; } return false; @@ -4443,25 +4589,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 193: - case 192: case 200: - case 187: - case 185: - case 184: - case 190: - case 191: - case 189: - case 186: - case 197: - case 194: - case 196: - case 94: case 199: - case 183: - case 188: + case 207: + case 194: + case 192: + case 191: + case 197: + case 198: + case 196: + case 193: + case 204: + case 201: + case 203: + case 95: + case 206: + case 190: case 195: - case 217: + case 202: + case 224: return true; default: return false; @@ -4470,13 +4616,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 137: - case 134: - case 136: + case 141: case 138: - case 139: - case 135: + case 140: case 142: + case 143: + case 139: + case 146: return true; default: return false; @@ -4484,11 +4630,11 @@ var ts; } ts.isClassElement = isClassElement; function isDeclarationName(name) { - if (name.kind !== 65 && name.kind !== 8 && name.kind !== 7) { + if (name.kind !== 66 && name.kind !== 8 && name.kind !== 7) { return false; } var parent = name.parent; - if (parent.kind === 216 || parent.kind === 220) { + if (parent.kind === 223 || parent.kind === 227) { if (parent.propertyName) { return true; } @@ -4502,54 +4648,54 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 134: - case 133: - case 136: - case 135: case 138: + case 137: + case 140: case 139: - case 229: - case 227: - case 158: + case 142: + case 143: + case 244: + case 242: + case 163: return parent.name === node; - case 128: + case 132: if (parent.right === node) { - while (parent.kind === 128) { + while (parent.kind === 132) { parent = parent.parent; } - return parent.kind === 147; + return parent.kind === 151; } return false; - case 155: - case 216: + case 160: + case 223: return parent.propertyName === node; - case 220: + case 227: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 211 || - node.kind === 213 && !!node.name || - node.kind === 214 || - node.kind === 216 || - node.kind === 220 || - node.kind === 217 && node.expression.kind === 65; + return node.kind === 218 || + node.kind === 220 && !!node.name || + node.kind === 221 || + node.kind === 223 || + node.kind === 227 || + node.kind === 224 && node.expression.kind === 66; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 79); + var heritageClause = getHeritageClause(node.heritageClauses, 80); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 102); + var heritageClause = getHeritageClause(node.heritageClauses, 103); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 79); + var heritageClause = getHeritageClause(node.heritageClauses, 80); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -4618,28 +4764,32 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 66 <= token && token <= 127; + return 67 <= token && token <= 131; } ts.isKeyword = isKeyword; function isTrivia(token) { return 2 <= token && token <= 6; } ts.isTrivia = isTrivia; + function isAsyncFunctionLike(node) { + return isFunctionLike(node) && (node.flags & 512) !== 0 && !isAccessor(node); + } + ts.isAsyncFunctionLike = isAsyncFunctionLike; function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 129 && + declaration.name.kind === 133 && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; function isWellKnownSymbolSyntactically(node) { - return node.kind === 158 && isESSymbolIdentifier(node.expression); + return node.kind === 163 && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 65 || name.kind === 8 || name.kind === 7) { + if (name.kind === 66 || name.kind === 8 || name.kind === 7) { return name.text; } - if (name.kind === 129) { + if (name.kind === 133) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -4654,19 +4804,21 @@ var ts; } ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; function isESSymbolIdentifier(node) { - return node.kind === 65 && node.text === "Symbol"; + return node.kind === 66 && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isModifier(token) { switch (token) { - case 108: - case 106: - case 107: - case 109: - case 78: + case 112: case 115: - case 70: - case 73: + case 71: + case 119: + case 74: + case 79: + case 109: + case 107: + case 108: + case 110: return true; } return false; @@ -4674,18 +4826,18 @@ var ts; ts.isModifier = isModifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 131; + return root.kind === 135; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 155) { + while (node.kind === 160) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 208 || n.kind === 230; + return isFunctionLike(n) || n.kind === 215 || n.kind === 245; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -4694,8 +4846,6 @@ var ts; ts.nodeIsSynthesized = nodeIsSynthesized; function createSynthesizedNode(kind, startsOnNewLine) { var node = ts.createNode(kind); - node.pos = -1; - node.end = -1; node.startsOnNewLine = startsOnNewLine; return node; } @@ -4795,6 +4945,11 @@ var ts; } } ts.escapeString = escapeString; + function isIntrinsicJsxName(name) { + var ch = name.substr(0, 1); + return ch.toLowerCase() === ch; + } + ts.isIntrinsicJsxName = isIntrinsicJsxName; function get16BitUnicodeEscapeSequence(charCode) { var hexCharCode = charCode.toString(16).toUpperCase(); var paddedHexCode = ("0000" + hexCharCode).slice(-4); @@ -4909,12 +5064,16 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 137 && nodeIsPresent(member.body)) { + if (member.kind === 141 && nodeIsPresent(member.body)) { return member; } }); } ts.getFirstConstructorWithBody = getFirstConstructorWithBody; + function getSetAccessorTypeAnnotationNode(accessor) { + return accessor && accessor.parameters.length > 0 && accessor.parameters[0].type; + } + ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; function shouldEmitToOwnFile(sourceFile, compilerOptions) { if (!isDeclarationFile(sourceFile)) { if ((isExternalModule(sourceFile) || !compilerOptions.out)) { @@ -4932,10 +5091,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 138) { + if (accessor.kind === 142) { getAccessor = accessor; } - else if (accessor.kind === 139) { + else if (accessor.kind === 143) { setAccessor = accessor; } else { @@ -4944,7 +5103,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 138 || member.kind === 139) + if ((member.kind === 142 || member.kind === 143) && (member.flags & 128) === (accessor.flags & 128)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -4955,10 +5114,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 138 && !getAccessor) { + if (member.kind === 142 && !getAccessor) { getAccessor = member; } - if (member.kind === 139 && !setAccessor) { + if (member.kind === 143 && !setAccessor) { setAccessor = member; } } @@ -5064,14 +5223,16 @@ var ts; ts.writeCommentRange = writeCommentRange; function modifierToFlag(token) { switch (token) { - case 109: return 128; - case 108: return 16; - case 107: return 64; - case 106: return 32; - case 78: return 1; - case 115: return 2; - case 70: return 8192; - case 73: return 256; + case 110: return 128; + case 109: return 16; + case 108: return 64; + case 107: return 32; + case 112: return 256; + case 79: return 1; + case 119: return 2; + case 71: return 32768; + case 74: return 1024; + case 115: return 512; } return 0; } @@ -5079,27 +5240,29 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 158: - case 159: - case 161: - case 160: - case 162: - case 156: + case 163: case 164: - case 157: - case 177: + case 166: case 165: - case 65: + case 230: + case 231: + case 167: + case 161: + case 169: + case 162: + case 183: + case 170: + case 66: case 9: case 7: case 8: case 10: - case 174: - case 80: - case 89: - case 93: - case 95: - case 91: + case 180: + case 81: + case 90: + case 94: + case 96: + case 92: return true; } } @@ -5107,12 +5270,12 @@ var ts; } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isAssignmentOperator(token) { - return token >= 53 && token <= 64; + return token >= 54 && token <= 65; } ts.isAssignmentOperator = isAssignmentOperator; function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 179 && - node.parent.token === 79 && + return node.kind === 185 && + node.parent.token === 80 && isClassLike(node.parent.parent); } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; @@ -5121,10 +5284,10 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 65) { + if (node.kind === 66) { return true; } - else if (node.kind === 158) { + else if (node.kind === 163) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { @@ -5132,22 +5295,25 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 128 && node.parent.right === node) || - (node.parent.kind === 158 && node.parent.name === node); + return (node.parent.kind === 132 && node.parent.right === node) || + (node.parent.kind === 163 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function getLocalSymbolForExportDefault(symbol) { - return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 256) ? symbol.valueDeclaration.localSymbol : undefined; + return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; function isJavaScript(fileName) { return ts.fileExtensionIs(fileName, ".js"); } ts.isJavaScript = isJavaScript; + function isTsx(fileName) { + return ts.fileExtensionIs(fileName, ".tsx"); + } + ts.isTsx = isTsx; function getExpandedCharCodes(input) { var output = []; var length = input.length; - var leadSurrogate = undefined; for (var i = 0; i < length; i++) { var charCode = input.charCodeAt(i); if (charCode < 0x80) { @@ -5336,9 +5502,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 130) { + if (d && d.kind === 134) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 205) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 212) { return current; } } @@ -5350,7 +5516,7 @@ var ts; /// var ts; (function (ts) { - var nodeConstructors = new Array(254); + var nodeConstructors = new Array(269); ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -5388,20 +5554,20 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 128: + case 132: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 130: + case 134: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 131: - case 134: - case 133: - case 227: - case 228: - case 201: - case 155: + case 135: + case 138: + case 137: + case 242: + case 243: + case 208: + case 160: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -5410,24 +5576,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); + case 149: + case 150: + case 144: case 145: case 146: - case 140: - case 141: - case 142: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 136: - case 135: - case 137: - case 138: + case 140: case 139: - case 165: - case 203: - case 166: + case 141: + case 142: + case 143: + case 170: + case 210: + case 171: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -5438,267 +5604,290 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 144: + case 148: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 143: + case 147: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 147: - return visitNode(cbNode, node.exprName); - case 148: - return visitNodes(cbNodes, node.members); - case 149: - return visitNode(cbNode, node.elementType); - case 150: - return visitNodes(cbNodes, node.elementTypes); case 151: - return visitNodes(cbNodes, node.types); + return visitNode(cbNode, node.exprName); case 152: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.members); case 153: + return visitNode(cbNode, node.elementType); case 154: - return visitNodes(cbNodes, node.elements); + return visitNodes(cbNodes, node.elementTypes); + case 155: case 156: - return visitNodes(cbNodes, node.elements); + return visitNodes(cbNodes, node.types); case 157: - return visitNodes(cbNodes, node.properties); + return visitNode(cbNode, node.type); case 158: + case 159: + return visitNodes(cbNodes, node.elements); + case 161: + return visitNodes(cbNodes, node.elements); + case 162: + return visitNodes(cbNodes, node.properties); + case 163: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 159: + case 164: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 160: - case 161: + case 165: + case 166: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 162: + case 167: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 163: + case 168: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 164: - return visitNode(cbNode, node.expression); - case 167: - return visitNode(cbNode, node.expression); - case 168: - return visitNode(cbNode, node.expression); case 169: return visitNode(cbNode, node.expression); - case 170: + case 172: + return visitNode(cbNode, node.expression); + case 173: + return visitNode(cbNode, node.expression); + case 174: + return visitNode(cbNode, node.expression); + case 176: return visitNode(cbNode, node.operand); - case 175: + case 181: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 171: + case 175: + return visitNode(cbNode, node.expression); + case 177: return visitNode(cbNode, node.operand); - case 172: + case 178: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 173: + case 186: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.type); + case 179: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 176: - return visitNode(cbNode, node.expression); case 182: - case 209: + return visitNode(cbNode, node.expression); + case 189: + case 216: return visitNodes(cbNodes, node.statements); - case 230: + case 245: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 183: + case 190: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 202: + case 209: return visitNodes(cbNodes, node.declarations); - case 185: + case 192: return visitNode(cbNode, node.expression); - case 186: + case 193: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 187: + case 194: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 188: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 189: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.condition) || - visitNode(cbNode, node.incrementor) || - visitNode(cbNode, node.statement); - case 190: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 191: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 192: - case 193: - return visitNode(cbNode, node.label); - case 194: - return visitNode(cbNode, node.expression); case 195: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 196: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.caseBlock); - case 210: - return visitNodes(cbNodes, node.clauses); - case 223: - return visitNode(cbNode, node.expression) || - visitNodes(cbNodes, node.statements); - case 224: - return visitNodes(cbNodes, node.statements); + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.condition) || + visitNode(cbNode, node.incrementor) || + visitNode(cbNode, node.statement); case 197: - return visitNode(cbNode, node.label) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 198: - return visitNode(cbNode, node.expression); + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); case 199: + case 200: + return visitNode(cbNode, node.label); + case 201: + return visitNode(cbNode, node.expression); + case 202: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 203: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.caseBlock); + case 217: + return visitNodes(cbNodes, node.clauses); + case 238: + return visitNode(cbNode, node.expression) || + visitNodes(cbNodes, node.statements); + case 239: + return visitNodes(cbNodes, node.statements); + case 204: + return visitNode(cbNode, node.label) || + visitNode(cbNode, node.statement); + case 205: + return visitNode(cbNode, node.expression); + case 206: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 226: + case 241: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 132: + case 136: return visitNode(cbNode, node.expression); - case 204: - case 177: + case 211: + case 183: 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 205: + case 212: 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 206: + case 213: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 207: + case 214: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 229: + case 244: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 208: + case 215: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 211: + case 218: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 212: + case 219: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 213: + case 220: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 214: + case 221: return visitNode(cbNode, node.name); - case 215: - case 219: + case 222: + case 226: return visitNodes(cbNodes, node.elements); - case 218: + case 225: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 216: - case 220: + case 223: + case 227: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 217: + case 224: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 174: - return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); case 180: + return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); + case 187: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 129: + case 133: return visitNode(cbNode, node.expression); - case 225: + case 240: return visitNodes(cbNodes, node.types); - case 179: + case 185: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 222: + case 229: return visitNode(cbNode, node.expression); - case 221: + case 228: return visitNodes(cbNodes, node.decorators); + case 230: + return visitNode(cbNode, node.openingElement) || + visitNodes(cbNodes, node.children) || + visitNode(cbNode, node.closingElement); case 231: - return visitNode(cbNode, node.type); + case 232: + return visitNode(cbNode, node.tagName) || + visitNodes(cbNodes, node.attributes); case 235: - return visitNodes(cbNodes, node.types); - case 236: - return visitNodes(cbNodes, node.types); - case 234: - return visitNode(cbNode, node.elementType); - case 238: - return visitNode(cbNode, node.type); - case 237: - return visitNode(cbNode, node.type); - case 239: - return visitNodes(cbNodes, node.members); - case 241: return visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeArguments); - case 242: - return visitNode(cbNode, node.type); - case 243: - return visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type); - case 244: - return visitNode(cbNode, node.type); - case 245: - return visitNode(cbNode, node.type); + visitNode(cbNode, node.initializer); + case 236: + return visitNode(cbNode, node.expression); + case 237: + return visitNode(cbNode, node.expression); + case 234: + return visitNode(cbNode, node.tagName); case 246: return visitNode(cbNode, node.type); - case 240: + case 250: + return visitNodes(cbNodes, node.types); + case 251: + return visitNodes(cbNodes, node.types); + case 249: + return visitNode(cbNode, node.elementType); + case 253: + return visitNode(cbNode, node.type); + case 252: + return visitNode(cbNode, node.type); + case 254: + return visitNodes(cbNodes, node.members); + case 256: + return visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeArguments); + case 257: + return visitNode(cbNode, node.type); + case 258: + return visitNodes(cbNodes, node.parameters) || + visitNode(cbNode, node.type); + case 259: + return visitNode(cbNode, node.type); + case 260: + return visitNode(cbNode, node.type); + case 261: + return visitNode(cbNode, node.type); + case 255: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 247: + case 262: return visitNodes(cbNodes, node.tags); - case 249: + case 264: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 250: + case 265: return visitNode(cbNode, node.typeExpression); - case 251: + case 266: return visitNode(cbNode, node.typeExpression); - case 252: + case 267: return visitNodes(cbNodes, node.typeParameters); } } @@ -5726,7 +5915,7 @@ var ts; var Parser; (function (Parser) { var scanner = ts.createScanner(2, true); - var disallowInAndDecoratorContext = 2 | 16; + var disallowInAndDecoratorContext = 1 | 4; var sourceFile; var parseDiagnostics; var syntaxCursor; @@ -5753,11 +5942,12 @@ var ts; identifiers = {}; identifierCount = 0; nodeCount = 0; - contextFlags = ts.isJavaScript(fileName) ? 64 : 0; + contextFlags = ts.isJavaScript(fileName) ? 32 : 0; parseErrorBeforeNextFinishedNode = false; scanner.setText(sourceText); scanner.setOnError(scanError); scanner.setScriptTarget(languageVersion); + scanner.setLanguageVariant(ts.isTsx(fileName) ? 1 : 0); } function clearState() { scanner.setText(""); @@ -5793,9 +5983,9 @@ var ts; return; function visit(node) { switch (node.kind) { - case 183: - case 203: - case 131: + case 190: + case 210: + case 135: addJSDocComment(node); } forEachChild(node, visit); @@ -5833,14 +6023,15 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(230, 0); + var sourceFile = createNode(245, 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; sourceFile.languageVersion = languageVersion; sourceFile.fileName = ts.normalizePath(fileName); - sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 2048 : 0; + sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 8192 : 0; + sourceFile.languageVariant = ts.isTsx(sourceFile.fileName) ? 1 : 0; return sourceFile; } function setContextFlag(val, flag) { @@ -5852,83 +6043,78 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 2); + setContextFlag(val, 1); } function setYieldContext(val) { - setContextFlag(val, 4); - } - function setGeneratorParameterContext(val) { - setContextFlag(val, 8); + setContextFlag(val, 2); } function setDecoratorContext(val) { - setContextFlag(val, 16); + setContextFlag(val, 4); } - function doOutsideOfContext(flags, func) { - var currentContextFlags = contextFlags & flags; - if (currentContextFlags) { - setContextFlag(false, currentContextFlags); + function setAwaitContext(val) { + setContextFlag(val, 8); + } + function doOutsideOfContext(context, func) { + var contextFlagsToClear = context & contextFlags; + if (contextFlagsToClear) { + setContextFlag(false, contextFlagsToClear); var result = func(); - setContextFlag(true, currentContextFlags); + setContextFlag(true, contextFlagsToClear); + return result; + } + return func(); + } + function doInsideOfContext(context, func) { + var contextFlagsToSet = context & ~contextFlags; + if (contextFlagsToSet) { + setContextFlag(true, contextFlagsToSet); + var result = func(); + setContextFlag(false, contextFlagsToSet); return result; } return func(); } function allowInAnd(func) { - if (contextFlags & 2) { - setDisallowInContext(false); - var result = func(); - setDisallowInContext(true); - return result; - } - return func(); + return doOutsideOfContext(1, func); } function disallowInAnd(func) { - if (contextFlags & 2) { - return func(); - } - setDisallowInContext(true); - var result = func(); - setDisallowInContext(false); - return result; + return doInsideOfContext(1, func); } function doInYieldContext(func) { - if (contextFlags & 4) { - return func(); - } - setYieldContext(true); - var result = func(); - setYieldContext(false); - return result; + return doInsideOfContext(2, func); } function doOutsideOfYieldContext(func) { - if (contextFlags & 4) { - setYieldContext(false); - var result = func(); - setYieldContext(true); - return result; - } - return func(); + return doOutsideOfContext(2, func); } function doInDecoratorContext(func) { - if (contextFlags & 16) { - return func(); - } - setDecoratorContext(true); - var result = func(); - setDecoratorContext(false); - return result; + return doInsideOfContext(4, func); + } + function doInAwaitContext(func) { + return doInsideOfContext(8, func); + } + function doOutsideOfAwaitContext(func) { + return doOutsideOfContext(8, func); + } + function doInYieldAndAwaitContext(func) { + return doInsideOfContext(2 | 8, func); + } + function doOutsideOfYieldAndAwaitContext(func) { + return doOutsideOfContext(2 | 8, func); + } + function inContext(flags) { + return (contextFlags & flags) !== 0; } function inYieldContext() { - return (contextFlags & 4) !== 0; - } - function inGeneratorParameterContext() { - return (contextFlags & 8) !== 0; + return inContext(2); } function inDisallowInContext() { - return (contextFlags & 2) !== 0; + return inContext(1); } function inDecoratorContext() { - return (contextFlags & 16) !== 0; + return inContext(4); + } + function inAwaitContext() { + return inContext(8); } function parseErrorAtCurrentToken(message, arg0) { var start = scanner.getTokenPos(); @@ -5967,6 +6153,9 @@ var ts; function reScanTemplateToken() { return token = scanner.reScanTemplateToken(); } + function scanJsxIdentifier() { + return token = scanner.scanJsxIdentifier(); + } function speculationHelper(callback, isLookAhead) { var saveToken = token; var saveParseDiagnosticsLength = parseDiagnostics.length; @@ -5990,13 +6179,16 @@ var ts; return speculationHelper(callback, false); } function isIdentifier() { - if (token === 65) { + if (token === 66) { return true; } - if (token === 110 && inYieldContext()) { + if (token === 111 && inYieldContext()) { return false; } - return token > 101; + if (token === 116 && inAwaitContext()) { + return false; + } + return token > 102; } function parseExpected(kind, diagnosticMessage) { if (token === kind) { @@ -6067,7 +6259,7 @@ var ts; } if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.parserContextFlags |= 32; + node.parserContextFlags |= 16; } return node; } @@ -6089,15 +6281,15 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(65); - if (token !== 65) { + var node = createNode(66); + if (token !== 66) { node.originalKeywordKind = token; } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(65, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(66, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -6129,16 +6321,9 @@ var ts; return token === 8 || token === 7 || isIdentifierOrKeyword(); } function parseComputedPropertyName() { - var node = createNode(129); + var node = createNode(133); parseExpected(18); - var yieldContext = inYieldContext(); - if (inGeneratorParameterContext()) { - setYieldContext(false); - } node.expression = allowInAnd(parseExpression); - if (inGeneratorParameterContext()) { - setYieldContext(yieldContext); - } parseExpected(19); return finishNode(node); } @@ -6146,17 +6331,17 @@ var ts; return token === t && tryParse(nextTokenCanFollowModifier); } function nextTokenCanFollowModifier() { - if (token === 70) { - return nextToken() === 77; + if (token === 71) { + return nextToken() === 78; } - if (token === 78) { + if (token === 79) { nextToken(); - if (token === 73) { + if (token === 74) { return lookAhead(nextTokenIsClassOrFunction); } - return token !== 35 && token !== 14 && canFollowModifier(); + return token !== 36 && token !== 14 && canFollowModifier(); } - if (token === 73) { + if (token === 74) { return nextTokenIsClassOrFunction(); } nextToken(); @@ -6168,12 +6353,12 @@ var ts; function canFollowModifier() { return token === 18 || token === 14 - || token === 35 + || token === 36 || isLiteralPropertyName(); } function nextTokenIsClassOrFunction() { nextToken(); - return token === 69 || token === 83; + return token === 70 || token === 84; } function isListElement(parsingContext, inErrorRecovery) { var node = currentNode(parsingContext); @@ -6186,7 +6371,7 @@ var ts; case 3: return !(token === 22 && inErrorRecovery) && isStartOfStatement(); case 2: - return token === 67 || token === 73; + return token === 68 || token === 74; case 4: return isStartOfTypeMember(); case 5: @@ -6194,7 +6379,7 @@ var ts; case 6: return token === 18 || isLiteralPropertyName(); case 12: - return token === 18 || token === 35 || isLiteralPropertyName(); + return token === 18 || token === 36 || isLiteralPropertyName(); case 9: return isLiteralPropertyName(); case 7: @@ -6211,25 +6396,29 @@ var ts; return isIdentifierOrPattern(); case 10: return token === 23 || token === 21 || isIdentifierOrPattern(); - case 15: + case 17: return isIdentifier(); case 11: - case 13: + case 15: return token === 23 || token === 21 || isStartOfExpression(); - case 14: - return isStartOfParameter(); case 16: - case 17: - return token === 23 || isStartOfType(); + return isStartOfParameter(); case 18: - return isHeritageClause(); case 19: - return isIdentifierOrKeyword(); + return token === 23 || isStartOfType(); case 20: + return isHeritageClause(); case 21: - case 23: - return JSDocParser.isJSDocType(); + return isIdentifierOrKeyword(); + case 13: + return isIdentifierOrKeyword() || token === 14; + case 14: + return true; case 22: + case 23: + case 25: + return JSDocParser.isJSDocType(); + case 24: return isSimplePropertyName(); } ts.Debug.fail("Non-exhaustive case in 'isListElement'."); @@ -6238,7 +6427,7 @@ var ts; ts.Debug.assert(token === 14); if (nextToken() === 15) { var next = nextToken(); - return next === 23 || next === 14 || next === 79 || next === 102; + return next === 23 || next === 14 || next === 80 || next === 103; } return true; } @@ -6246,9 +6435,13 @@ var ts; nextToken(); return isIdentifier(); } + function nextTokenIsIdentifierOrKeyword() { + nextToken(); + return isIdentifierOrKeyword(); + } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token === 102 || - token === 79) { + if (token === 103 || + token === 80) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -6269,35 +6462,39 @@ var ts; case 6: case 12: case 9: - case 19: + case 21: return token === 15; case 3: - return token === 15 || token === 67 || token === 73; + return token === 15 || token === 68 || token === 74; case 7: - return token === 14 || token === 79 || token === 102; + return token === 14 || token === 80 || token === 103; case 8: return isVariableDeclaratorListTerminator(); - case 15: - return token === 25 || token === 16 || token === 14 || token === 79 || token === 102; + case 17: + return token === 26 || token === 16 || token === 14 || token === 80 || token === 103; case 11: return token === 17 || token === 22; - case 13: - case 17: + case 15: + case 19: case 10: return token === 19; - case 14: - return token === 17 || token === 19; case 16: - return token === 25 || token === 16; + return token === 17 || token === 19; case 18: - return token === 14 || token === 15; + return token === 26 || token === 16; case 20: - return token === 17 || token === 51 || token === 15; - case 21: - return token === 25 || token === 15; - case 23: - return token === 19 || token === 15; + return token === 14 || token === 15; + case 13: + return token === 26 || token === 37; + case 14: + return token === 24 && lookAhead(nextTokenIsSlash); case 22: + return token === 17 || token === 52 || token === 15; + case 23: + return token === 26 || token === 15; + case 25: + return token === 19 || token === 15; + case 24: return token === 15; } } @@ -6308,13 +6505,13 @@ var ts; if (isInOrOfKeyword(token)) { return true; } - if (token === 32) { + if (token === 33) { return true; } return false; } function isInSomeParsingContext() { - for (var kind = 0; kind < 24; kind++) { + for (var kind = 0; kind < 26; kind++) { if (parsingContext & (1 << kind)) { if (isListElement(kind, true) || isListTerminator(kind)) { return true; @@ -6366,7 +6563,7 @@ var ts; if (ts.containsParseError(node)) { return undefined; } - var nodeContextFlags = node.parserContextFlags & 62; + var nodeContextFlags = node.parserContextFlags & 31; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -6396,32 +6593,34 @@ var ts; return isReusableTypeMember(node); case 8: return isReusableVariableDeclaration(node); - case 14: - return isReusableParameter(node); - case 18: - case 15: - case 17: case 16: + return isReusableParameter(node); + case 20: + case 17: + case 19: + case 18: case 11: case 12: case 7: + case 13: + case 14: } return false; } function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 137: + case 141: + case 146: case 142: + case 143: case 138: - case 139: - case 134: - case 181: + case 188: return true; - case 136: + case 140: var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 65 && - methodDeclaration.name.originalKeywordKind === 114; + var nameIsConstructor = methodDeclaration.name.kind === 66 && + methodDeclaration.name.originalKeywordKind === 118; return !nameIsConstructor; } } @@ -6430,8 +6629,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 223: - case 224: + case 238: + case 239: return true; } } @@ -6440,65 +6639,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 203: - case 183: - case 182: - case 186: - case 185: - case 198: - case 194: - case 196: + case 210: + case 190: + case 189: case 193: case 192: - case 190: - case 191: - case 189: - case 188: - case 195: - case 184: + case 205: + case 201: + case 203: + case 200: case 199: case 197: - case 187: - case 200: - case 212: - case 211: - case 218: - case 217: - case 208: - case 204: - case 205: - case 207: + case 198: + case 196: + case 195: + case 202: + case 191: case 206: + case 204: + case 194: + case 207: + case 219: + case 218: + case 225: + case 224: + case 215: + case 211: + case 212: + case 214: + case 213: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 229; + return node.kind === 244; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 141: - case 135: - case 142: - case 133: - case 140: + case 145: + case 139: + case 146: + case 137: + case 144: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 201) { + if (node.kind !== 208) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 131) { + if (node.kind !== 135) { return false; } var parameter = node; @@ -6527,17 +6726,19 @@ var ts; case 10: return ts.Diagnostics.Array_element_destructuring_pattern_expected; case 11: return ts.Diagnostics.Argument_expression_expected; case 12: return ts.Diagnostics.Property_assignment_expected; - case 13: return ts.Diagnostics.Expression_or_comma_expected; - case 14: return ts.Diagnostics.Parameter_declaration_expected; - case 15: return ts.Diagnostics.Type_parameter_declaration_expected; - case 16: return ts.Diagnostics.Type_argument_expected; - case 17: return ts.Diagnostics.Type_expected; - case 18: return ts.Diagnostics.Unexpected_token_expected; - case 19: return ts.Diagnostics.Identifier_expected; - case 20: return ts.Diagnostics.Parameter_declaration_expected; - case 21: return ts.Diagnostics.Type_argument_expected; - case 23: return ts.Diagnostics.Type_expected; - case 22: return ts.Diagnostics.Property_assignment_expected; + case 15: return ts.Diagnostics.Expression_or_comma_expected; + case 16: return ts.Diagnostics.Parameter_declaration_expected; + case 17: return ts.Diagnostics.Type_parameter_declaration_expected; + case 18: return ts.Diagnostics.Type_argument_expected; + case 19: return ts.Diagnostics.Type_expected; + case 20: return ts.Diagnostics.Unexpected_token_expected; + case 21: return ts.Diagnostics.Identifier_expected; + case 13: return ts.Diagnostics.Identifier_expected; + case 14: return ts.Diagnostics.Identifier_expected; + case 22: return ts.Diagnostics.Parameter_declaration_expected; + case 23: return ts.Diagnostics.Type_argument_expected; + case 25: return ts.Diagnostics.Type_expected; + case 24: return ts.Diagnostics.Property_assignment_expected; } } ; @@ -6596,7 +6797,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(20)) { - var node = createNode(128, entity.pos); + var node = createNode(132, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -6607,13 +6808,13 @@ var ts; if (scanner.hasPrecedingLineBreak() && isIdentifierOrKeyword()) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { - return createMissingNode(65, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(66, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(174); + var template = createNode(180); template.head = parseLiteralNode(); ts.Debug.assert(template.head.kind === 11, "Template head has wrong token kind"); var templateSpans = []; @@ -6626,7 +6827,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(180); + var span = createNode(187); span.expression = allowInAnd(parseExpression); var literal; if (token === 15) { @@ -6655,36 +6856,36 @@ var ts; if (node.kind === 7 && sourceText.charCodeAt(tokenPos) === 48 && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { - node.flags |= 16384; + node.flags |= 65536; } return node; } function parseTypeReferenceOrTypePredicate() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - if (typeName.kind === 65 && token === 117 && !scanner.hasPrecedingLineBreak()) { + if (typeName.kind === 66 && token === 121 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var node_1 = createNode(143, typeName.pos); + var node_1 = createNode(147, typeName.pos); node_1.parameterName = typeName; node_1.type = parseType(); return finishNode(node_1); } - var node = createNode(144, typeName.pos); + var node = createNode(148, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token === 24) { - node.typeArguments = parseBracketedList(16, parseType, 24, 25); + node.typeArguments = parseBracketedList(18, parseType, 24, 26); } return finishNode(node); } function parseTypeQuery() { - var node = createNode(147); - parseExpected(97); + var node = createNode(151); + parseExpected(98); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(130); + var node = createNode(134); node.name = parseIdentifier(); - if (parseOptional(79)) { + if (parseOptional(80)) { if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } @@ -6696,11 +6897,11 @@ var ts; } function parseTypeParameters() { if (token === 24) { - return parseBracketedList(15, parseTypeParameter, 24, 25); + return parseBracketedList(17, parseTypeParameter, 24, 26); } } function parseParameterType() { - if (parseOptional(51)) { + if (parseOptional(52)) { return token === 8 ? parseLiteralNode(true) : parseType(); @@ -6708,7 +6909,7 @@ var ts; return undefined; } function isStartOfParameter() { - return token === 21 || isIdentifierOrPattern() || ts.isModifier(token) || token === 52; + return token === 21 || isIdentifierOrPattern() || ts.isModifier(token) || token === 53; } function setModifiers(node, modifiers) { if (modifiers) { @@ -6717,26 +6918,29 @@ var ts; } } function parseParameter() { - var node = createNode(131); + var node = createNode(135); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(21); - node.name = inGeneratorParameterContext() ? doInYieldContext(parseIdentifierOrPattern) : parseIdentifierOrPattern(); + node.name = parseIdentifierOrPattern(); if (ts.getFullWidth(node.name) === 0 && node.flags === 0 && ts.isModifier(token)) { nextToken(); } - node.questionToken = parseOptionalToken(50); + node.questionToken = parseOptionalToken(51); node.type = parseParameterType(); - node.initializer = inGeneratorParameterContext() ? doOutsideOfYieldContext(parseParameterInitializer) : parseParameterInitializer(); + node.initializer = parseBindingElementInitializer(true); return finishNode(node); } + function parseBindingElementInitializer(inParameter) { + return inParameter ? parseParameterInitializer() : parseNonParameterInitializer(); + } function parseParameterInitializer() { return parseInitializer(true); } - function fillSignature(returnToken, yieldAndGeneratorParameterContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 32; + function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { + var returnTokenRequired = returnToken === 33; signature.typeParameters = parseTypeParameters(); - signature.parameters = parseParameterList(yieldAndGeneratorParameterContext, requireCompleteParameterList); + signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { parseExpected(returnToken); signature.type = parseType(); @@ -6745,15 +6949,15 @@ var ts; signature.type = parseType(); } } - function parseParameterList(yieldAndGeneratorParameterContext, requireCompleteParameterList) { + function parseParameterList(yieldContext, awaitContext, requireCompleteParameterList) { if (parseExpected(16)) { var savedYieldContext = inYieldContext(); - var savedGeneratorParameterContext = inGeneratorParameterContext(); - setYieldContext(yieldAndGeneratorParameterContext); - setGeneratorParameterContext(yieldAndGeneratorParameterContext); - var result = parseDelimitedList(14, parseParameter); + var savedAwaitContext = inAwaitContext(); + setYieldContext(yieldContext); + setAwaitContext(awaitContext); + var result = parseDelimitedList(16, parseParameter); setYieldContext(savedYieldContext); - setGeneratorParameterContext(savedGeneratorParameterContext); + setAwaitContext(savedAwaitContext); if (!parseExpected(17) && requireCompleteParameterList) { return undefined; } @@ -6769,10 +6973,10 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 141) { - parseExpected(88); + if (kind === 145) { + parseExpected(89); } - fillSignature(51, false, false, node); + fillSignature(52, false, false, false, node); parseTypeMemberSemicolon(); return finishNode(node); } @@ -6799,20 +7003,20 @@ var ts; else { nextToken(); } - if (token === 51 || token === 23) { + if (token === 52 || token === 23) { return true; } - if (token !== 50) { + if (token !== 51) { return false; } nextToken(); - return token === 51 || token === 23 || token === 19; + return token === 52 || token === 23 || token === 19; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(142, fullStart); + var node = createNode(146, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.parameters = parseBracketedList(14, parseParameter, 18, 19); + node.parameters = parseBracketedList(16, parseParameter, 18, 19); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); @@ -6820,17 +7024,17 @@ var ts; function parsePropertyOrMethodSignature() { var fullStart = scanner.getStartPos(); var name = parsePropertyName(); - var questionToken = parseOptionalToken(50); + var questionToken = parseOptionalToken(51); if (token === 16 || token === 24) { - var method = createNode(135, fullStart); + var method = createNode(139, fullStart); method.name = name; method.questionToken = questionToken; - fillSignature(51, false, false, method); + fillSignature(52, false, false, false, method); parseTypeMemberSemicolon(); return finishNode(method); } else { - var property = createNode(133, fullStart); + var property = createNode(137, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -6864,22 +7068,22 @@ var ts; nextToken(); return token === 16 || token === 24 || - token === 50 || token === 51 || + token === 52 || canParseSemicolon(); } function parseTypeMember() { switch (token) { case 16: case 24: - return parseSignatureMember(140); + return parseSignatureMember(144); case 18: return isIndexSignature() ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) : parsePropertyOrMethodSignature(); - case 88: + case 89: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(141); + return parseSignatureMember(145); } case 8: case 7: @@ -6909,7 +7113,7 @@ var ts; return token === 16 || token === 24; } function parseTypeLiteral() { - var node = createNode(148); + var node = createNode(152); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -6925,12 +7129,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(150); - node.elementTypes = parseBracketedList(17, parseType, 18, 19); + var node = createNode(154); + node.elementTypes = parseBracketedList(19, parseType, 18, 19); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(152); + var node = createNode(157); parseExpected(16); node.type = parseType(); parseExpected(17); @@ -6938,10 +7142,10 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 146) { - parseExpected(88); + if (kind === 150) { + parseExpected(89); } - fillSignature(32, false, false, node); + fillSignature(33, false, false, false, node); return finishNode(node); } function parseKeywordAndNoDot() { @@ -6950,16 +7154,16 @@ var ts; } function parseNonArrayType() { switch (token) { - case 112: - case 123: - case 121: - case 113: - case 124: + case 114: + case 127: + case 125: + case 117: + case 128: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReferenceOrTypePredicate(); - case 99: + case 100: return parseTokenNode(); - case 97: + case 98: return parseTypeQuery(); case 14: return parseTypeLiteral(); @@ -6973,17 +7177,17 @@ var ts; } function isStartOfType() { switch (token) { - case 112: - case 123: - case 121: - case 113: - case 124: - case 99: - case 97: + case 114: + case 127: + case 125: + case 117: + case 128: + case 100: + case 98: case 14: case 18: case 24: - case 88: + case 89: return true; case 16: return lookAhead(isStartOfParenthesizedOrFunctionType); @@ -6999,27 +7203,33 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(18)) { parseExpected(19); - var node = createNode(149, type.pos); + var node = createNode(153, type.pos); node.elementType = type; type = finishNode(node); } return type; } - function parseUnionTypeOrHigher() { - var type = parseArrayTypeOrHigher(); - if (token === 44) { + function parseUnionOrIntersectionType(kind, parseConstituentType, operator) { + var type = parseConstituentType(); + if (token === operator) { var types = [type]; types.pos = type.pos; - while (parseOptional(44)) { - types.push(parseArrayTypeOrHigher()); + while (parseOptional(operator)) { + types.push(parseConstituentType()); } types.end = getNodeEnd(); - var node = createNode(151, type.pos); + var node = createNode(kind, type.pos); node.types = types; type = finishNode(node); } return type; } + function parseIntersectionTypeOrHigher() { + return parseUnionOrIntersectionType(156, parseArrayTypeOrHigher, 44); + } + function parseUnionTypeOrHigher() { + return parseUnionOrIntersectionType(155, parseIntersectionTypeOrHigher, 45); + } function isStartOfFunctionType() { if (token === 24) { return true; @@ -7033,14 +7243,14 @@ var ts; } if (isIdentifier() || ts.isModifier(token)) { nextToken(); - if (token === 51 || token === 23 || - token === 50 || token === 53 || + if (token === 52 || token === 23 || + token === 51 || token === 54 || isIdentifier() || ts.isModifier(token)) { return true; } if (token === 17) { nextToken(); - if (token === 32) { + if (token === 33) { return true; } } @@ -7048,34 +7258,27 @@ var ts; return false; } function parseType() { - var savedYieldContext = inYieldContext(); - var savedGeneratorParameterContext = inGeneratorParameterContext(); - setYieldContext(false); - setGeneratorParameterContext(false); - var result = parseTypeWorker(); - setYieldContext(savedYieldContext); - setGeneratorParameterContext(savedGeneratorParameterContext); - return result; + return doOutsideOfContext(10, parseTypeWorker); } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(145); + return parseFunctionOrConstructorType(149); } - if (token === 88) { - return parseFunctionOrConstructorType(146); + if (token === 89) { + return parseFunctionOrConstructorType(150); } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(51) ? parseType() : undefined; + return parseOptional(52) ? parseType() : undefined; } function isStartOfLeftHandSideExpression() { switch (token) { - case 93: - case 91: - case 89: - case 95: - case 80: + case 94: + case 92: + case 90: + case 96: + case 81: case 7: case 8: case 10: @@ -7083,12 +7286,12 @@ var ts; case 16: case 18: case 14: - case 83: - case 69: - case 88: - case 36: - case 57: - case 65: + case 84: + case 70: + case 89: + case 37: + case 58: + case 66: return true; default: return isIdentifier(); @@ -7099,17 +7302,18 @@ var ts; return true; } switch (token) { - case 33: case 34: + case 35: + case 48: case 47: - case 46: - case 74: - case 97: - case 99: - case 38: + case 75: + case 98: + case 100: case 39: + case 40: case 24: - case 110: + case 116: + case 111: return true; default: if (isBinaryOperator()) { @@ -7120,11 +7324,14 @@ var ts; } function isStartOfExpressionStatement() { return token !== 14 && - token !== 83 && - token !== 69 && - token !== 52 && + token !== 84 && + token !== 70 && + token !== 53 && isStartOfExpression(); } + function allowInAndParseExpression() { + return allowInAnd(parseExpression); + } function parseExpression() { // Expression[in]: // AssignmentExpression[in] @@ -7144,12 +7351,12 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token !== 53) { + if (token !== 54) { if (scanner.hasPrecedingLineBreak() || (inParameter && token === 14) || !isStartOfExpression()) { return undefined; } } - parseExpected(53); + parseExpected(54); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -7170,7 +7377,7 @@ var ts; return arrowExpression; } var expr = parseBinaryExpressionOrHigher(0); - if (expr.kind === 65 && token === 32) { + if (expr.kind === 66 && token === 33) { return parseSimpleArrowFunctionExpression(expr); } if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { @@ -7179,7 +7386,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token === 110) { + if (token === 111) { if (inYieldContext()) { return true; } @@ -7192,11 +7399,11 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(175); + var node = createNode(181); nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token === 35 || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(35); + (token === 36 || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(36); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -7205,16 +7412,16 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier) { - ts.Debug.assert(token === 32, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(166, identifier.pos); - var parameter = createNode(131, identifier.pos); + ts.Debug.assert(token === 33, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + var node = createNode(171, identifier.pos); + var parameter = createNode(135, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; node.parameters.pos = parameter.pos; node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(32, false, ts.Diagnostics._0_expected, "=>"); - node.body = parseArrowFunctionExpressionBody(); + node.equalsGreaterThanToken = parseExpectedToken(33, false, ts.Diagnostics._0_expected, "=>"); + node.body = parseArrowFunctionExpressionBody(false); return finishNode(node); } function tryParseParenthesizedArrowFunctionExpression() { @@ -7228,31 +7435,41 @@ var ts; if (!arrowFunction) { return undefined; } + var isAsync = !!(arrowFunction.flags & 512); var lastToken = token; - arrowFunction.equalsGreaterThanToken = parseExpectedToken(32, false, ts.Diagnostics._0_expected, "=>"); - arrowFunction.body = (lastToken === 32 || lastToken === 14) - ? parseArrowFunctionExpressionBody() + arrowFunction.equalsGreaterThanToken = parseExpectedToken(33, false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 33 || lastToken === 14) + ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); } function isParenthesizedArrowFunctionExpression() { - if (token === 16 || token === 24) { + if (token === 16 || token === 24 || token === 115) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token === 32) { + if (token === 33) { return 1; } return 0; } function isParenthesizedArrowFunctionExpressionWorker() { + if (token === 115) { + nextToken(); + if (scanner.hasPrecedingLineBreak()) { + return 0; + } + if (token !== 16 && token !== 24) { + return 0; + } + } var first = token; var second = nextToken(); if (first === 16) { if (second === 17) { var third = nextToken(); switch (third) { - case 32: - case 51: + case 33: + case 52: case 14: return 1; default: @@ -7268,7 +7485,7 @@ var ts; if (!isIdentifier()) { return 0; } - if (nextToken() === 51) { + if (nextToken() === 52) { return 1; } return 2; @@ -7278,6 +7495,29 @@ var ts; if (!isIdentifier()) { return 0; } + if (sourceFile.languageVariant === 1) { + var isArrowFunctionInJsx = lookAhead(function () { + var third = nextToken(); + if (third === 80) { + var fourth = nextToken(); + switch (fourth) { + case 54: + case 26: + return false; + default: + return true; + } + } + else if (third === 23) { + return true; + } + return false; + }); + if (isArrowFunctionInJsx) { + return 1; + } + return 0; + } return 2; } } @@ -7285,39 +7525,43 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(166); - fillSignature(51, false, !allowAmbiguity, node); + var node = createNode(171); + setModifiers(node, parseModifiersForArrowFunction()); + var isAsync = !!(node.flags & 512); + fillSignature(52, false, isAsync, !allowAmbiguity, node); if (!node.parameters) { return undefined; } - if (!allowAmbiguity && token !== 32 && token !== 14) { + if (!allowAmbiguity && token !== 33 && token !== 14) { return undefined; } return node; } - function parseArrowFunctionExpressionBody() { + function parseArrowFunctionExpressionBody(isAsync) { if (token === 14) { - return parseFunctionBlock(false, false); + return parseFunctionBlock(false, isAsync, false); } if (token !== 22 && - token !== 83 && - token !== 69 && + token !== 84 && + token !== 70 && isStartOfStatement() && !isStartOfExpressionStatement()) { - return parseFunctionBlock(false, true); + return parseFunctionBlock(false, isAsync, true); } - return parseAssignmentExpressionOrHigher(); + return isAsync + ? doInAwaitContext(parseAssignmentExpressionOrHigher) + : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); } function parseConditionalExpressionRest(leftOperand) { - var questionToken = parseOptionalToken(50); + var questionToken = parseOptionalToken(51); if (!questionToken) { return leftOperand; } - var node = createNode(173, leftOperand.pos); + var node = createNode(179, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(51, false, ts.Diagnostics._0_expected, ts.tokenToString(51)); + node.colonToken = parseExpectedToken(52, false, ts.Diagnostics._0_expected, ts.tokenToString(52)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -7326,7 +7570,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 86 || t === 127; + return t === 87 || t === 131; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -7335,106 +7579,147 @@ var ts; if (newPrecedence <= precedence) { break; } - if (token === 86 && inDisallowInContext()) { + if (token === 87 && inDisallowInContext()) { break; } - leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence)); + if (token === 113) { + if (scanner.hasPrecedingLineBreak()) { + break; + } + else { + nextToken(); + leftOperand = makeAsExpression(leftOperand, parseType()); + } + } + else { + leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence)); + } } return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token === 86) { + if (inDisallowInContext() && token === 87) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token) { - case 49: + case 50: return 1; - case 48: + case 49: return 2; - case 44: - return 3; case 45: + return 3; + case 46: return 4; - case 43: + case 44: return 5; - case 28: case 29: case 30: case 31: + case 32: return 6; case 24: - case 25: case 26: case 27: + case 28: + case 88: case 87: - case 86: + case 113: return 7; - case 40: case 41: case 42: + case 43: return 8; - case 33: case 34: - return 9; case 35: + return 9; case 36: case 37: + case 38: return 10; } return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(172, left.pos); + var node = createNode(178, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } + function makeAsExpression(left, right) { + var node = createNode(186, left.pos); + node.expression = left; + node.type = right; + return finishNode(node); + } function parsePrefixUnaryExpression() { - var node = createNode(170); + var node = createNode(176); node.operator = token; nextToken(); node.operand = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(167); + var node = createNode(172); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(168); + var node = createNode(173); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(169); + var node = createNode(174); + nextToken(); + node.expression = parseUnaryExpressionOrHigher(); + return finishNode(node); + } + function isAwaitExpression() { + if (token === 116) { + if (inAwaitContext()) { + return true; + } + return lookAhead(nextTokenIsIdentifierOnSameLine); + } + return false; + } + function parseAwaitExpression() { + var node = createNode(175); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseUnaryExpressionOrHigher() { + if (isAwaitExpression()) { + return parseAwaitExpression(); + } switch (token) { - case 33: case 34: + case 35: + case 48: case 47: - case 46: - case 38: case 39: + case 40: return parsePrefixUnaryExpression(); - case 74: + case 75: return parseDeleteExpression(); - case 97: + case 98: return parseTypeOfExpression(); - case 99: + case 100: return parseVoidExpression(); case 24: - return parseTypeAssertion(); + if (sourceFile.languageVariant !== 1) { + return parseTypeAssertion(); + } + if (lookAhead(nextTokenIsIdentifierOrKeyword)) { + return parseJsxElementOrSelfClosingElement(); + } default: return parsePostfixExpressionOrHigher(); } @@ -7442,8 +7727,8 @@ var ts; function parsePostfixExpressionOrHigher() { var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token === 38 || token === 39) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(171, expression.pos); + if ((token === 39 || token === 40) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(177, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -7452,7 +7737,7 @@ var ts; return expression; } function parseLeftHandSideExpressionOrHigher() { - var expression = token === 91 + var expression = token === 92 ? parseSuperExpression() : parseMemberExpressionOrHigher(); return parseCallExpressionRest(expression); @@ -7466,17 +7751,140 @@ var ts; if (token === 16 || token === 20) { return expression; } - var node = createNode(158, expression.pos); + var node = createNode(163, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(20, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } + function parseJsxElementOrSelfClosingElement() { + var opening = parseJsxOpeningOrSelfClosingElement(); + if (opening.kind === 232) { + var node = createNode(230, opening.pos); + node.openingElement = opening; + node.children = parseJsxChildren(node.openingElement.tagName); + node.closingElement = parseJsxClosingElement(); + return finishNode(node); + } + else { + ts.Debug.assert(opening.kind === 231); + return opening; + } + } + function parseJsxText() { + var node = createNode(233, scanner.getStartPos()); + token = scanner.scanJsxToken(); + return finishNode(node); + } + function parseJsxChild() { + switch (token) { + case 233: + return parseJsxText(); + case 14: + return parseJsxExpression(); + case 24: + return parseJsxElementOrSelfClosingElement(); + } + ts.Debug.fail('Unknown JSX child kind ' + token); + } + function parseJsxChildren(openingTagName) { + var result = []; + result.pos = scanner.getStartPos(); + var saveParsingContext = parsingContext; + parsingContext |= 1 << 14; + while (true) { + token = scanner.reScanJsxToken(); + if (token === 25) { + break; + } + else if (token === 1) { + parseErrorAtCurrentToken(ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNodeFromSourceText(sourceText, openingTagName)); + break; + } + result.push(parseJsxChild()); + } + result.end = scanner.getTokenPos(); + parsingContext = saveParsingContext; + return result; + } + function parseJsxOpeningOrSelfClosingElement() { + var fullStart = scanner.getStartPos(); + parseExpected(24); + var tagName = parseJsxElementName(); + var attributes = parseList(13, parseJsxAttribute); + var node; + if (parseOptional(26)) { + node = createNode(232, fullStart); + } + else { + parseExpected(37); + parseExpected(26); + node = createNode(231, fullStart); + } + node.tagName = tagName; + node.attributes = attributes; + return finishNode(node); + } + function parseJsxElementName() { + scanJsxIdentifier(); + var elementName = parseIdentifierName(); + while (parseOptional(20)) { + scanJsxIdentifier(); + var node = createNode(132, elementName.pos); + node.left = elementName; + node.right = parseIdentifierName(); + elementName = finishNode(node); + } + return elementName; + } + function parseJsxExpression() { + var node = createNode(237); + parseExpected(14); + if (token !== 15) { + node.expression = parseExpression(); + } + parseExpected(15); + return finishNode(node); + } + function parseJsxAttribute() { + if (token === 14) { + return parseJsxSpreadAttribute(); + } + scanJsxIdentifier(); + var node = createNode(235); + node.name = parseIdentifierName(); + if (parseOptional(54)) { + switch (token) { + case 8: + node.initializer = parseLiteralNode(); + break; + default: + node.initializer = parseJsxExpression(); + break; + } + } + return finishNode(node); + } + function parseJsxSpreadAttribute() { + var node = createNode(236); + parseExpected(14); + parseExpected(21); + node.expression = parseExpression(); + parseExpected(15); + return finishNode(node); + } + function parseJsxClosingElement() { + var node = createNode(234); + parseExpected(25); + node.tagName = parseJsxElementName(); + parseExpected(26); + return finishNode(node); + } function parseTypeAssertion() { - var node = createNode(163); + var node = createNode(168); parseExpected(24); node.type = parseType(); - parseExpected(25); + parseExpected(26); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } @@ -7484,7 +7892,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(20); if (dotToken) { - var propertyAccess = createNode(158, expression.pos); + var propertyAccess = createNode(163, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); @@ -7492,7 +7900,7 @@ var ts; continue; } if (!inDecoratorContext() && parseOptional(18)) { - var indexedAccess = createNode(159, expression.pos); + var indexedAccess = createNode(164, expression.pos); indexedAccess.expression = expression; if (token !== 19) { indexedAccess.argumentExpression = allowInAnd(parseExpression); @@ -7506,7 +7914,7 @@ var ts; continue; } if (token === 10 || token === 11) { - var tagExpression = createNode(162, expression.pos); + var tagExpression = createNode(167, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 10 ? parseLiteralNode() @@ -7525,7 +7933,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(160, expression.pos); + var callExpr = createNode(165, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -7533,7 +7941,7 @@ var ts; continue; } else if (token === 16) { - var callExpr = createNode(160, expression.pos); + var callExpr = createNode(165, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -7552,8 +7960,8 @@ var ts; if (!parseOptional(24)) { return undefined; } - var typeArguments = parseDelimitedList(16, parseType); - if (!parseExpected(25)) { + var typeArguments = parseDelimitedList(18, parseType); + if (!parseExpected(26)) { return undefined; } return typeArguments && canFollowTypeArgumentsInExpression() @@ -7566,18 +7974,18 @@ var ts; case 20: case 17: case 19: - case 51: + case 52: case 22: - case 50: - case 28: - case 30: + case 51: case 29: case 31: - case 48: + case 30: + case 32: case 49: - case 45: - case 43: + case 50: + case 46: case 44: + case 45: case 15: case 1: return true; @@ -7593,11 +8001,11 @@ var ts; case 8: case 10: return parseLiteralNode(); - case 93: - case 91: - case 89: - case 95: - case 80: + case 94: + case 92: + case 90: + case 96: + case 81: return parseTokenNode(); case 16: return parseParenthesizedExpression(); @@ -7605,14 +8013,19 @@ var ts; return parseArrayLiteralExpression(); case 14: return parseObjectLiteralExpression(); - case 69: - return parseClassExpression(); - case 83: + case 115: + if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { + break; + } return parseFunctionExpression(); - case 88: + case 70: + return parseClassExpression(); + case 84: + return parseFunctionExpression(); + case 89: return parseNewExpression(); - case 36: - case 57: + case 37: + case 58: if (reScanSlashToken() === 9) { return parseLiteralNode(); } @@ -7623,41 +8036,41 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(164); + var node = createNode(169); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); return finishNode(node); } function parseSpreadElement() { - var node = createNode(176); + var node = createNode(182); parseExpected(21); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 21 ? parseSpreadElement() : - token === 23 ? createNode(178) : + token === 23 ? createNode(184) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(156); + var node = createNode(161); parseExpected(18); if (scanner.hasPrecedingLineBreak()) - node.flags |= 512; - node.elements = parseDelimitedList(13, parseArgumentOrArrayLiteralElement); + node.flags |= 2048; + node.elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement); parseExpected(19); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(116)) { - return parseAccessorDeclaration(138, fullStart, decorators, modifiers); + if (parseContextualModifier(120)) { + return parseAccessorDeclaration(142, fullStart, decorators, modifiers); } - else if (parseContextualModifier(122)) { - return parseAccessorDeclaration(139, fullStart, decorators, modifiers); + else if (parseContextualModifier(126)) { + return parseAccessorDeclaration(143, fullStart, decorators, modifiers); } return undefined; } @@ -7669,34 +8082,34 @@ var ts; if (accessor) { return accessor; } - var asteriskToken = parseOptionalToken(35); + var asteriskToken = parseOptionalToken(36); var tokenIsIdentifier = isIdentifier(); var nameToken = token; var propertyName = parsePropertyName(); - var questionToken = parseOptionalToken(50); + var questionToken = parseOptionalToken(51); if (asteriskToken || token === 16 || token === 24) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } if ((token === 23 || token === 15) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(228, fullStart); + var shorthandDeclaration = createNode(243, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(227, fullStart); + var propertyAssignment = createNode(242, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(51); + parseExpected(52); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return finishNode(propertyAssignment); } } function parseObjectLiteralExpression() { - var node = createNode(157); + var node = createNode(162); parseExpected(14); if (scanner.hasPrecedingLineBreak()) { - node.flags |= 512; + node.flags |= 2048; } node.properties = parseDelimitedList(12, parseObjectLiteralElement, true); parseExpected(15); @@ -7707,12 +8120,19 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(165); - parseExpected(83); - node.asteriskToken = parseOptionalToken(35); - node.name = node.asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(51, !!node.asteriskToken, false, node); - node.body = parseFunctionBlock(!!node.asteriskToken, false); + var node = createNode(170); + setModifiers(node, parseModifiers()); + parseExpected(84); + node.asteriskToken = parseOptionalToken(36); + var isGenerator = !!node.asteriskToken; + var isAsync = !!(node.flags & 512); + node.name = + isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : + isGenerator ? doInYieldContext(parseOptionalIdentifier) : + isAsync ? doInAwaitContext(parseOptionalIdentifier) : + parseOptionalIdentifier(); + fillSignature(52, isGenerator, isAsync, false, node); + node.body = parseFunctionBlock(isGenerator, isAsync, false); if (saveDecoratorContext) { setDecoratorContext(true); } @@ -7722,8 +8142,8 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(161); - parseExpected(88); + var node = createNode(166); + parseExpected(89); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token === 16) { @@ -7732,7 +8152,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(182); + var node = createNode(189); if (parseExpected(14, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(1, parseStatement); parseExpected(15); @@ -7742,9 +8162,11 @@ var ts; } return finishNode(node); } - function parseFunctionBlock(allowYield, ignoreMissingOpenBrace, diagnosticMessage) { + function parseFunctionBlock(allowYield, allowAwait, ignoreMissingOpenBrace, diagnosticMessage) { var savedYieldContext = inYieldContext(); setYieldContext(allowYield); + var savedAwaitContext = inAwaitContext(); + setAwaitContext(allowAwait); var saveDecoratorContext = inDecoratorContext(); if (saveDecoratorContext) { setDecoratorContext(false); @@ -7754,28 +8176,29 @@ var ts; setDecoratorContext(true); } setYieldContext(savedYieldContext); + setAwaitContext(savedAwaitContext); return block; } function parseEmptyStatement() { - var node = createNode(184); + var node = createNode(191); parseExpected(22); return finishNode(node); } function parseIfStatement() { - var node = createNode(186); - parseExpected(84); + var node = createNode(193); + parseExpected(85); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(76) ? parseStatement() : undefined; + node.elseStatement = parseOptional(77) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(187); - parseExpected(75); + var node = createNode(194); + parseExpected(76); node.statement = parseStatement(); - parseExpected(100); + parseExpected(101); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); @@ -7783,8 +8206,8 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(188); - parseExpected(100); + var node = createNode(195); + parseExpected(101); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); @@ -7793,11 +8216,11 @@ var ts; } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(82); + parseExpected(83); parseExpected(16); var initializer = undefined; if (token !== 22) { - if (token === 98 || token === 104 || token === 70) { + if (token === 99 || token === 105 || token === 71) { initializer = parseVariableDeclarationList(true); } else { @@ -7805,22 +8228,22 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(86)) { - var forInStatement = createNode(190, pos); + if (parseOptional(87)) { + var forInStatement = createNode(197, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(17); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(127)) { - var forOfStatement = createNode(191, pos); + else if (parseOptional(131)) { + var forOfStatement = createNode(198, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(17); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(189, pos); + var forStatement = createNode(196, pos); forStatement.initializer = initializer; parseExpected(22); if (token !== 22 && token !== 17) { @@ -7838,7 +8261,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 193 ? 66 : 71); + parseExpected(kind === 200 ? 67 : 72); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -7846,8 +8269,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(194); - parseExpected(90); + var node = createNode(201); + parseExpected(91); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -7855,8 +8278,8 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(195); - parseExpected(101); + var node = createNode(202); + parseExpected(102); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); @@ -7864,30 +8287,30 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(223); - parseExpected(67); + var node = createNode(238); + parseExpected(68); node.expression = allowInAnd(parseExpression); - parseExpected(51); + parseExpected(52); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(224); - parseExpected(73); - parseExpected(51); + var node = createNode(239); + parseExpected(74); + parseExpected(52); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token === 67 ? parseCaseClause() : parseDefaultClause(); + return token === 68 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(196); - parseExpected(92); + var node = createNode(203); + parseExpected(93); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); - var caseBlock = createNode(210, scanner.getStartPos()); + var caseBlock = createNode(217, scanner.getStartPos()); parseExpected(14); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(15); @@ -7897,26 +8320,26 @@ var ts; function parseThrowStatement() { // ThrowStatement[Yield] : // throw [no LineTerminator here]Expression[In, ?Yield]; - var node = createNode(198); - parseExpected(94); + var node = createNode(205); + parseExpected(95); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(199); - parseExpected(96); + var node = createNode(206); + parseExpected(97); node.tryBlock = parseBlock(false); - node.catchClause = token === 68 ? parseCatchClause() : undefined; - if (!node.catchClause || token === 81) { - parseExpected(81); + node.catchClause = token === 69 ? parseCatchClause() : undefined; + if (!node.catchClause || token === 82) { + parseExpected(82); node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(226); - parseExpected(68); + var result = createNode(241); + parseExpected(69); if (parseExpected(16)) { result.variableDeclaration = parseVariableDeclaration(); } @@ -7925,34 +8348,38 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(200); - parseExpected(72); + var node = createNode(207); + parseExpected(73); parseSemicolon(); return finishNode(node); } function parseExpressionOrLabeledStatement() { var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 65 && parseOptional(51)) { - var labeledStatement = createNode(197, fullStart); + if (expression.kind === 66 && parseOptional(52)) { + var labeledStatement = createNode(204, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(185, fullStart); + var expressionStatement = createNode(192, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); } } function isIdentifierOrKeyword() { - return token >= 65; + return token >= 66; } function nextTokenIsIdentifierOrKeywordOnSameLine() { nextToken(); return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak(); } + function nextTokenIsFunctionKeywordOnSameLine() { + nextToken(); + return token === 84 && !scanner.hasPrecedingLineBreak(); + } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); return (isIdentifierOrKeyword() || token === 7) && !scanner.hasPrecedingLineBreak(); @@ -7960,40 +8387,42 @@ var ts; function isDeclaration() { while (true) { switch (token) { - case 98: - case 104: + case 99: + case 105: + case 71: + case 84: case 70: - case 83: - case 69: - case 77: + case 78: return true; - case 103: - case 125: + case 104: + case 129: return nextTokenIsIdentifierOnSameLine(); - case 118: - case 119: + case 122: + case 123: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); case 115: + case 119: nextToken(); if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 85: + case 86: nextToken(); - return token === 8 || token === 35 || + return token === 8 || token === 36 || token === 14 || isIdentifierOrKeyword(); - case 78: + case 79: nextToken(); - if (token === 53 || token === 35 || - token === 14 || token === 73) { + if (token === 54 || token === 36 || + token === 14 || token === 74) { return true; } continue; - case 108: - case 106: - case 107: case 109: + case 107: + case 108: + case 110: + case 112: nextToken(); continue; default: @@ -8006,43 +8435,44 @@ var ts; } function isStartOfStatement() { switch (token) { - case 52: + case 53: case 22: case 14: - case 98: - case 104: - case 83: - case 69: - case 77: + case 99: + case 105: case 84: - case 75: - case 100: - case 82: - case 71: - case 66: - case 90: - case 101: - case 92: - case 94: - case 96: - case 72: - case 68: - case 81: - return true; case 70: case 78: case 85: + case 76: + case 101: + case 83: + case 72: + case 67: + case 91: + case 102: + case 93: + case 95: + case 97: + case 73: + case 69: + case 82: + return true; + case 71: + case 79: + case 86: return isStartOfDeclaration(); case 115: - case 103: - case 118: case 119: - case 125: + case 104: + case 122: + case 123: + case 129: return true; - case 108: - case 106: - case 107: case 109: + case 107: + case 108: + case 110: return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: return isStartOfExpression(); @@ -8061,58 +8491,60 @@ var ts; return parseEmptyStatement(); case 14: return parseBlock(false); - case 98: + case 99: return parseVariableStatement(scanner.getStartPos(), undefined, undefined); - case 104: + case 105: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), undefined, undefined); } break; - case 83: - return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); - case 69: - return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); case 84: - return parseIfStatement(); - case 75: - return parseDoStatement(); - case 100: - return parseWhileStatement(); - case 82: - return parseForOrForInOrForOfStatement(); - case 71: - return parseBreakOrContinueStatement(192); - case 66: - return parseBreakOrContinueStatement(193); - case 90: - return parseReturnStatement(); - case 101: - return parseWithStatement(); - case 92: - return parseSwitchStatement(); - case 94: - return parseThrowStatement(); - case 96: - case 68: - case 81: - return parseTryStatement(); - case 72: - return parseDebuggerStatement(); - case 52: - return parseDeclaration(); - case 103: - case 125: - case 118: - case 119: - case 115: + return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); case 70: - case 77: - case 78: + return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); case 85: - case 106: + return parseIfStatement(); + case 76: + return parseDoStatement(); + case 101: + return parseWhileStatement(); + case 83: + return parseForOrForInOrForOfStatement(); + case 72: + return parseBreakOrContinueStatement(199); + case 67: + return parseBreakOrContinueStatement(200); + case 91: + return parseReturnStatement(); + case 102: + return parseWithStatement(); + case 93: + return parseSwitchStatement(); + case 95: + return parseThrowStatement(); + case 97: + case 69: + case 82: + return parseTryStatement(); + case 73: + return parseDebuggerStatement(); + case 53: + return parseDeclaration(); + case 115: + case 104: + case 129: + case 122: + case 123: + case 119: + case 71: + case 78: + case 79: + case 86: case 107: case 108: case 109: + case 112: + case 110: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -8125,33 +8557,33 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token) { - case 98: - case 104: - case 70: + case 99: + case 105: + case 71: return parseVariableStatement(fullStart, decorators, modifiers); - case 83: + case 84: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 69: + case 70: return parseClassDeclaration(fullStart, decorators, modifiers); - case 103: + case 104: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 125: + case 129: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 77: - return parseEnumDeclaration(fullStart, decorators, modifiers); - case 118: - case 119: - return parseModuleDeclaration(fullStart, decorators, modifiers); - case 85: - return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); case 78: + return parseEnumDeclaration(fullStart, decorators, modifiers); + case 122: + case 123: + return parseModuleDeclaration(fullStart, decorators, modifiers); + case 86: + return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); + case 79: nextToken(); - return token === 73 || token === 53 ? + return token === 74 || token === 54 ? parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: if (decorators || modifiers) { - var node = createMissingNode(221, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(228, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -8163,47 +8595,47 @@ var ts; nextToken(); return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 8); } - function parseFunctionBlockOrSemicolon(isGenerator, diagnosticMessage) { + function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { if (token !== 14 && canParseSemicolon()) { parseSemicolon(); return; } - return parseFunctionBlock(isGenerator, false, diagnosticMessage); + return parseFunctionBlock(isGenerator, isAsync, false, diagnosticMessage); } function parseArrayBindingElement() { if (token === 23) { - return createNode(178); + return createNode(184); } - var node = createNode(155); + var node = createNode(160); node.dotDotDotToken = parseOptionalToken(21); node.name = parseIdentifierOrPattern(); - node.initializer = parseInitializer(false); + node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(155); + var node = createNode(160); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token !== 51) { + if (tokenIsIdentifier && token !== 52) { node.name = propertyName; } else { - parseExpected(51); + parseExpected(52); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } - node.initializer = parseInitializer(false); + node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(153); + var node = createNode(158); parseExpected(14); node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(15); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(154); + var node = createNode(159); parseExpected(18); node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(19); @@ -8222,7 +8654,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(201); + var node = createNode(208); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -8231,21 +8663,21 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(202); + var node = createNode(209); switch (token) { - case 98: + case 99: break; - case 104: - node.flags |= 4096; + case 105: + node.flags |= 16384; break; - case 70: - node.flags |= 8192; + case 71: + node.flags |= 32768; break; default: ts.Debug.fail(); } nextToken(); - if (token === 127 && lookAhead(canFollowContextualOfKeyword)) { + if (token === 131 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -8260,7 +8692,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 17; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(183, fullStart); + var node = createNode(190, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); @@ -8268,38 +8700,42 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(203, fullStart); + var node = createNode(210, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(83); - node.asteriskToken = parseOptionalToken(35); - node.name = node.flags & 256 ? parseOptionalIdentifier() : parseIdentifier(); - fillSignature(51, !!node.asteriskToken, false, node); - node.body = parseFunctionBlockOrSemicolon(!!node.asteriskToken, ts.Diagnostics.or_expected); + parseExpected(84); + node.asteriskToken = parseOptionalToken(36); + node.name = node.flags & 1024 ? parseOptionalIdentifier() : parseIdentifier(); + var isGenerator = !!node.asteriskToken; + var isAsync = !!(node.flags & 512); + fillSignature(52, isGenerator, isAsync, false, node); + node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(137, pos); + var node = createNode(141, pos); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(114); - fillSignature(51, false, false, node); - node.body = parseFunctionBlockOrSemicolon(false, ts.Diagnostics.or_expected); + parseExpected(118); + fillSignature(52, 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(136, fullStart); + var method = createNode(140, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; method.name = name; method.questionToken = questionToken; - fillSignature(51, !!asteriskToken, false, method); - method.body = parseFunctionBlockOrSemicolon(!!asteriskToken, diagnosticMessage); + var isGenerator = !!asteriskToken; + var isAsync = !!(method.flags & 512); + fillSignature(52, isGenerator, isAsync, false, method); + method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(134, fullStart); + var property = createNode(138, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -8307,14 +8743,14 @@ var ts; property.type = parseTypeAnnotation(); property.initializer = modifiers && modifiers.flags & 128 ? allowInAnd(parseNonParameterInitializer) - : doOutsideOfContext(4 | 2, parseNonParameterInitializer); + : doOutsideOfContext(2 | 1, parseNonParameterInitializer); parseSemicolon(); return finishNode(property); } function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(35); + var asteriskToken = parseOptionalToken(36); var name = parsePropertyName(); - var questionToken = parseOptionalToken(50); + var questionToken = parseOptionalToken(51); if (asteriskToken || token === 16 || token === 24) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } @@ -8330,16 +8766,16 @@ var ts; node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(51, false, false, node); - node.body = parseFunctionBlockOrSemicolon(false); + fillSignature(52, false, false, false, node); + node.body = parseFunctionBlockOrSemicolon(false, false); return finishNode(node); } function isClassMemberModifier(idToken) { switch (idToken) { - case 108: - case 106: - case 107: case 109: + case 107: + case 108: + case 110: return true; default: return false; @@ -8347,7 +8783,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token === 52) { + if (token === 53) { return true; } while (ts.isModifier(token)) { @@ -8357,7 +8793,7 @@ var ts; } nextToken(); } - if (token === 35) { + if (token === 36) { return true; } if (isLiteralPropertyName()) { @@ -8368,15 +8804,15 @@ var ts; return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 122 || idToken === 116) { + if (!ts.isKeyword(idToken) || idToken === 126 || idToken === 120) { return true; } switch (token) { case 16: case 24: + case 52: + case 54: case 51: - case 53: - case 50: return true; default: return canParseSemicolon(); @@ -8388,14 +8824,14 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(52)) { + if (!parseOptional(53)) { break; } if (!decorators) { decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(132, decoratorStart); + var decorator = createNode(136, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -8426,9 +8862,25 @@ var ts; } return modifiers; } + function parseModifiersForArrowFunction() { + var flags = 0; + var modifiers; + if (token === 115) { + var modifierStart = scanner.getStartPos(); + var modifierKind = token; + nextToken(); + modifiers = []; + modifiers.pos = modifierStart; + flags |= ts.modifierToFlag(modifierKind); + modifiers.push(finishNode(createNode(modifierKind, modifierStart))); + modifiers.flags = flags; + modifiers.end = scanner.getStartPos(); + } + return modifiers; + } function parseClassElement() { if (token === 22) { - var result = createNode(181); + var result = createNode(188); nextToken(); return finishNode(result); } @@ -8439,7 +8891,7 @@ var ts; if (accessor) { return accessor; } - if (token === 114) { + if (token === 118) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -8448,34 +8900,32 @@ var ts; if (isIdentifierOrKeyword() || token === 8 || token === 7 || - token === 35 || + token === 36 || token === 18) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name_6 = createMissingNode(65, true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_6, undefined); + var name_7 = createMissingNode(66, 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, 177); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 183); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 204); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 211); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(69); + parseExpected(70); node.name = parseOptionalIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(true); if (parseExpected(14)) { - node.members = inGeneratorParameterContext() - ? doOutsideOfYieldContext(parseClassMembers) - : parseClassMembers(); + node.members = parseClassMembers(); parseExpected(15); } else { @@ -8484,22 +8934,19 @@ var ts; return finishNode(node); } function parseHeritageClauses(isClassHeritageClause) { - // ClassTail[Yield,GeneratorParameter] : See 14.5 - // [~GeneratorParameter]ClassHeritage[?Yield]opt { ClassBody[?Yield]opt } - // [+GeneratorParameter] ClassHeritageopt { ClassBodyopt } + // ClassTail[Yield,Await] : (Modified) See 14.5 + // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } if (isHeritageClause()) { - return isClassHeritageClause && inGeneratorParameterContext() - ? doOutsideOfYieldContext(parseHeritageClausesWorker) - : parseHeritageClausesWorker(); + return parseList(20, parseHeritageClause); } return undefined; } function parseHeritageClausesWorker() { - return parseList(18, parseHeritageClause); + return parseList(20, parseHeritageClause); } function parseHeritageClause() { - if (token === 79 || token === 102) { - var node = createNode(225); + if (token === 80 || token === 103) { + var node = createNode(240); node.token = token; nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -8508,24 +8955,24 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(179); + var node = createNode(185); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === 24) { - node.typeArguments = parseBracketedList(16, parseType, 24, 25); + node.typeArguments = parseBracketedList(18, parseType, 24, 26); } return finishNode(node); } function isHeritageClause() { - return token === 79 || token === 102; + return token === 80 || token === 103; } function parseClassMembers() { return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(205, fullStart); + var node = createNode(212, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(103); + parseExpected(104); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(false); @@ -8533,28 +8980,28 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(206, fullStart); + var node = createNode(213, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(125); + parseExpected(129); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(53); + parseExpected(54); node.type = parseType(); parseSemicolon(); return finishNode(node); } function parseEnumMember() { - var node = createNode(229, scanner.getStartPos()); + var node = createNode(244, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(207, fullStart); + var node = createNode(214, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(77); + parseExpected(78); node.name = parseIdentifier(); if (parseExpected(14)) { node.members = parseDelimitedList(6, parseEnumMember); @@ -8566,7 +9013,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(209, scanner.getStartPos()); + var node = createNode(216, scanner.getStartPos()); if (parseExpected(14)) { node.statements = parseList(1, parseStatement); parseExpected(15); @@ -8577,7 +9024,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(208, fullStart); + var node = createNode(215, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; @@ -8588,7 +9035,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(208, fullStart); + var node = createNode(215, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(true); @@ -8597,11 +9044,11 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(119)) { - flags |= 32768; + if (parseOptional(123)) { + flags |= 131072; } else { - parseExpected(118); + parseExpected(122); if (token === 8) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -8609,61 +9056,64 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 120 && + return token === 124 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { return nextToken() === 16; } + function nextTokenIsSlash() { + return nextToken() === 37; + } function nextTokenIsCommaOrFromKeyword() { nextToken(); return token === 23 || - token === 126; + token === 130; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(85); + parseExpected(86); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 23 && token !== 126) { - var importEqualsDeclaration = createNode(211, fullStart); + if (token !== 23 && token !== 130) { + var importEqualsDeclaration = createNode(218, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; - parseExpected(53); + parseExpected(54); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(importEqualsDeclaration); } } - var importDeclaration = createNode(212, fullStart); + var importDeclaration = createNode(219, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); if (identifier || - token === 35 || + token === 36 || token === 14) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(126); + parseExpected(130); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - //ImportClause: + // ImportClause: // ImportedDefaultBinding // NameSpaceImport // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(213, fullStart); + var importClause = createNode(220, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(23)) { - importClause.namedBindings = token === 35 ? parseNamespaceImport() : parseNamedImportsOrExports(215); + importClause.namedBindings = token === 36 ? parseNamespaceImport() : parseNamedImportsOrExports(222); } return finishNode(importClause); } @@ -8673,8 +9123,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(222); - parseExpected(120); + var node = createNode(229); + parseExpected(124); parseExpected(16); node.expression = parseModuleSpecifier(); parseExpected(17); @@ -8688,22 +9138,22 @@ var ts; return result; } function parseNamespaceImport() { - var namespaceImport = createNode(214); - parseExpected(35); - parseExpected(111); + var namespaceImport = createNode(221); + parseExpected(36); + parseExpected(113); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(19, kind === 215 ? parseImportSpecifier : parseExportSpecifier, 14, 15); + node.elements = parseBracketedList(21, kind === 222 ? parseImportSpecifier : parseExportSpecifier, 14, 15); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(220); + return parseImportOrExportSpecifier(227); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(216); + return parseImportOrExportSpecifier(223); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -8711,9 +9161,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token === 111) { + if (token === 113) { node.propertyName = identifierName; - parseExpected(111); + parseExpected(113); checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -8722,22 +9172,22 @@ var ts; else { node.name = identifierName; } - if (kind === 216 && checkIdentifierIsKeyword) { + if (kind === 223 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(218, fullStart); + var node = createNode(225, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(35)) { - parseExpected(126); + if (parseOptional(36)) { + parseExpected(130); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(219); - if (parseOptional(126)) { + node.exportClause = parseNamedImportsOrExports(226); + if (parseOptional(130)) { node.moduleSpecifier = parseModuleSpecifier(); } } @@ -8745,21 +9195,21 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(217, fullStart); + var node = createNode(224, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(53)) { + if (parseOptional(54)) { node.isExportEquals = true; } else { - parseExpected(73); + parseExpected(74); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); return finishNode(node); } function processReferenceComments(sourceFile) { - var triviaScanner = ts.createScanner(sourceFile.languageVersion, false, sourceText); + var triviaScanner = ts.createScanner(sourceFile.languageVersion, false, 0, sourceText); var referencedFiles = []; var amdDependencies = []; var amdModuleName; @@ -8815,10 +9265,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 - || node.kind === 211 && node.moduleReference.kind === 222 - || node.kind === 212 - || node.kind === 217 - || node.kind === 218 + || node.kind === 218 && node.moduleReference.kind === 229 + || node.kind === 219 + || node.kind === 224 + || node.kind === 225 ? node : undefined; }); @@ -8827,16 +9277,16 @@ var ts; (function (JSDocParser) { function isJSDocType() { switch (token) { - case 35: - case 50: + case 36: + case 51: case 16: case 18: - case 46: + case 47: case 14: - case 83: + case 84: case 21: - case 88: - case 93: + case 89: + case 94: return true; } return isIdentifierOrKeyword(); @@ -8853,7 +9303,7 @@ var ts; function parseJSDocTypeExpression(start, length) { scanner.setText(sourceText, start, length); token = nextToken(); - var result = createNode(231); + var result = createNode(246); parseExpected(14); result.type = parseJSDocTopLevelType(); parseExpected(15); @@ -8863,13 +9313,13 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token === 44) { - var unionType = createNode(235, type.pos); + if (token === 45) { + var unionType = createNode(250, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token === 53) { - var optionalType = createNode(242, type.pos); + if (token === 54) { + var optionalType = createNode(257, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -8880,20 +9330,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token === 18) { - var arrayType = createNode(234, type.pos); + var arrayType = createNode(249, type.pos); arrayType.elementType = type; nextToken(); parseExpected(19); type = finishNode(arrayType); } - else if (token === 50) { - var nullableType = createNode(237, type.pos); + else if (token === 51) { + var nullableType = createNode(252, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token === 46) { - var nonNullableType = createNode(238, type.pos); + else if (token === 47) { + var nonNullableType = createNode(253, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -8906,82 +9356,82 @@ var ts; } function parseBasicTypeExpression() { switch (token) { - case 35: + case 36: return parseJSDocAllType(); - case 50: + case 51: return parseJSDocUnknownOrNullableType(); case 16: return parseJSDocUnionType(); case 18: return parseJSDocTupleType(); - case 46: + case 47: return parseJSDocNonNullableType(); case 14: return parseJSDocRecordType(); - case 83: + case 84: return parseJSDocFunctionType(); case 21: return parseJSDocVariadicType(); - case 88: + case 89: return parseJSDocConstructorType(); - case 93: + case 94: return parseJSDocThisType(); - case 112: - case 123: - case 121: - case 113: - case 124: - case 99: + case 114: + case 127: + case 125: + case 117: + case 128: + case 100: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(246); + var result = createNode(261); nextToken(); - parseExpected(51); + parseExpected(52); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(245); + var result = createNode(260); nextToken(); - parseExpected(51); + parseExpected(52); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(244); + var result = createNode(259); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(243); + var result = createNode(258); nextToken(); parseExpected(16); - result.parameters = parseDelimitedList(20, parseJSDocParameter); + result.parameters = parseDelimitedList(22, parseJSDocParameter); checkForTrailingComma(result.parameters); parseExpected(17); - if (token === 51) { + if (token === 52) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(131); + var parameter = createNode(135); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type) { - var result = createNode(242, type.pos); + var result = createNode(257, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference() { - var result = createNode(241); + var result = createNode(256); result.name = parseSimplePropertyName(); while (parseOptional(20)) { if (token === 24) { @@ -8996,10 +9446,10 @@ var ts; } function parseTypeArguments() { nextToken(); - var typeArguments = parseDelimitedList(21, parseJSDocType); + var typeArguments = parseDelimitedList(23, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); - parseExpected(25); + parseExpected(26); return typeArguments; } function checkForEmptyTypeArgumentList(typeArguments) { @@ -9010,38 +9460,38 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(128, left.pos); + var result = createNode(132, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(239); + var result = createNode(254); nextToken(); - result.members = parseDelimitedList(22, parseJSDocRecordMember); + result.members = parseDelimitedList(24, parseJSDocRecordMember); checkForTrailingComma(result.members); parseExpected(15); return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(240); + var result = createNode(255); result.name = parseSimplePropertyName(); - if (token === 51) { + if (token === 52) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(238); + var result = createNode(253); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(236); + var result = createNode(251); nextToken(); - result.types = parseDelimitedList(23, parseJSDocType); + result.types = parseDelimitedList(25, parseJSDocType); checkForTrailingComma(result.types); parseExpected(19); return finishNode(result); @@ -9053,7 +9503,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(235); + var result = createNode(250); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(17); @@ -9064,14 +9514,14 @@ var ts; var types = []; types.pos = firstType.pos; types.push(firstType); - while (parseOptional(44)) { + while (parseOptional(45)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); return types; } function parseJSDocAllType() { - var result = createNode(232); + var result = createNode(247); nextToken(); return finishNode(result); } @@ -9081,14 +9531,14 @@ var ts; if (token === 23 || token === 15 || token === 17 || - token === 25 || - token === 53 || - token === 44) { - var result = createNode(233, pos); + token === 26 || + token === 54 || + token === 45) { + var result = createNode(248, pos); return finishNode(result); } else { - var result = createNode(237, pos); + var result = createNode(252, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -9159,7 +9609,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(247, start); + var result = createNode(262, start); result.tags = tags; return finishNode(result, end); } @@ -9170,9 +9620,8 @@ var ts; } function parseTag() { ts.Debug.assert(content.charCodeAt(pos - 1) === 64); - var atToken = createNode(52, pos - 1); + var atToken = createNode(53, pos - 1); atToken.end = pos; - var startPos = pos; var tagName = scanIdentifier(); if (!tagName) { return; @@ -9197,7 +9646,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(248, atToken.pos); + var result = createNode(263, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -9249,7 +9698,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(249, atToken.pos); + var result = createNode(264, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -9259,27 +9708,27 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 250; })) { + if (ts.forEach(tags, function (t) { return t.kind === 265; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(250, atToken.pos); + var result = createNode(265, 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 === 251; })) { + if (ts.forEach(tags, function (t) { return t.kind === 266; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(251, atToken.pos); + var result = createNode(266, 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 === 252; })) { + if (ts.forEach(tags, function (t) { return t.kind === 267; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = []; @@ -9287,13 +9736,13 @@ var ts; while (true) { skipWhitespace(); var startPos = pos; - var name_7 = scanIdentifier(); - if (!name_7) { + var name_8 = scanIdentifier(); + if (!name_8) { parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(130, name_7.pos); - typeParameter.name = name_7; + var typeParameter = createNode(134, name_8.pos); + typeParameter.name = name_8; finishNode(typeParameter, pos); typeParameters.push(typeParameter); skipWhitespace(); @@ -9303,7 +9752,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(252, atToken.pos); + var result = createNode(267, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -9324,7 +9773,7 @@ var ts; if (startPos === pos) { return undefined; } - var result = createNode(65, startPos); + var result = createNode(66, startPos); result.text = content.substring(startPos, pos); return finishNode(result, pos); } @@ -9368,8 +9817,9 @@ var ts; } return; function visitNode(node) { + var text = ''; if (aggressiveChecks && shouldCheckNode(node)) { - var text = oldText.substring(node.pos, node.end); + text = oldText.substring(node.pos, node.end); } if (node._children) { node._children = undefined; @@ -9399,7 +9849,7 @@ var ts; switch (node.kind) { case 8: case 7: - case 65: + case 66: return true; } return false; @@ -9634,6 +10084,7 @@ var ts; } ts.getSymbolId = getSymbolId; function createTypeChecker(host, produceDiagnostics) { + var cancellationToken; var Symbol = ts.objectAllocator.getSymbolConstructor(); var Type = ts.objectAllocator.getTypeConstructor(); var Signature = ts.objectAllocator.getSignatureConstructor(); @@ -9679,7 +10130,9 @@ var ts; isImplementationOfOverload: isImplementationOfOverload, getAliasedSymbol: resolveAlias, getEmitResolver: getEmitResolver, - getExportsOfModule: getExportsOfModuleAsArray + getExportsOfModule: getExportsOfModuleAsArray, + getJsxElementAttributesType: getJsxElementAttributesType, + getJsxIntrinsicTagNames: getJsxIntrinsicTagNames }; var unknownSymbol = createSymbol(4 | 67108864, "unknown"); var resolvingSymbol = createSymbol(67108864, "__resolving__"); @@ -9687,10 +10140,10 @@ var ts; var stringType = createIntrinsicType(2, "string"); var numberType = createIntrinsicType(4, "number"); var booleanType = createIntrinsicType(8, "boolean"); - var esSymbolType = createIntrinsicType(2097152, "symbol"); + var esSymbolType = createIntrinsicType(4194304, "symbol"); var voidType = createIntrinsicType(16, "void"); - var undefinedType = createIntrinsicType(32 | 524288, "undefined"); - var nullType = createIntrinsicType(64 | 524288, "null"); + var undefinedType = createIntrinsicType(32 | 1048576, "undefined"); + var nullType = createIntrinsicType(64 | 1048576, "null"); var unknownType = createIntrinsicType(1, "unknown"); var circularType = createIntrinsicType(1, "__circular__"); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); @@ -9702,6 +10155,7 @@ var ts; var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); var globals = {}; var globalESSymbolConstructorSymbol; + var getGlobalPromiseConstructorSymbol; var globalObjectType; var globalFunctionType; var globalArrayType; @@ -9711,23 +10165,39 @@ var ts; var globalRegExpType; var globalTemplateStringsArrayType; var globalESSymbolType; + var jsxElementType; + var jsxIntrinsicElementsType; var globalIterableType; var globalIteratorType; var globalIterableIteratorType; var anyArrayType; + var getGlobalClassDecoratorType; + var getGlobalParameterDecoratorType; + var getGlobalPropertyDecoratorType; + var getGlobalMethodDecoratorType; var getGlobalTypedPropertyDescriptorType; + var getGlobalPromiseType; + var tryGetGlobalPromiseType; + var getGlobalPromiseLikeType; + var getInstantiatedGlobalPromiseLikeType; + var getGlobalPromiseConstructorLikeType; + var getGlobalThenableType; var tupleTypes = {}; var unionTypes = {}; + var intersectionTypes = {}; var stringLiteralTypes = {}; var emitExtends = false; var emitDecorate = false; var emitParam = false; + var emitAwaiter = false; + var emitGenerator = false; var resolutionTargets = []; var resolutionResults = []; var mergedSymbols = []; var symbolLinks = []; var nodeLinks = []; var potentialThisCollisions = []; + var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); var primitiveTypeInfo = { "string": { @@ -9744,16 +10214,23 @@ var ts; }, "symbol": { type: esSymbolType, - flags: 2097152 + flags: 4194304 } }; + var JsxNames = { + JSX: "JSX", + IntrinsicElements: "IntrinsicElements", + ElementClass: "ElementClass", + ElementAttributesPropertyNameContainer: "ElementAttributesProperty", + Element: "Element" + }; var subtypeRelation = {}; var assignableRelation = {}; var identityRelation = {}; initializeTypeChecker(); return checker; - function getEmitResolver(sourceFile) { - getDiagnostics(sourceFile); + function getEmitResolver(sourceFile, cancellationToken) { + getDiagnostics(sourceFile, cancellationToken); return emitResolver; } function error(location, message, arg0, arg1, arg2) { @@ -9778,9 +10255,9 @@ var ts; if (flags & 16) result |= 106927; if (flags & 32) - result |= 899583; + result |= 899519; if (flags & 64) - result |= 792992; + result |= 792960; if (flags & 256) result |= 899327; if (flags & 128) @@ -9891,10 +10368,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 230); + return ts.getAncestor(node, 245); } function isGlobalSourceFile(node) { - return node.kind === 230 && !ts.isExternalModule(node); + return node.kind === 245 && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -9942,16 +10419,16 @@ var ts; } } switch (location.kind) { - case 230: + case 245: if (!ts.isExternalModule(location)) break; - case 208: + case 215: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 230 || - (location.kind === 208 && location.name.kind === 8)) { + if (location.kind === 245 || + (location.kind === 215 && location.name.kind === 8)) { if (ts.hasProperty(moduleExports, name) && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 220)) { + ts.getDeclarationOfKind(moduleExports[name], 227)) { break; } result = moduleExports["default"]; @@ -9965,13 +10442,13 @@ var ts; break loop; } break; - case 207: + case 214: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; - case 134: - case 133: + case 138: + case 137: if (ts.isClassLike(location.parent) && !(location.flags & 128)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -9981,9 +10458,9 @@ var ts; } } break; - case 204: - case 177: - case 205: + case 211: + case 183: + case 212: 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); @@ -9991,7 +10468,7 @@ var ts; } break loop; } - if (location.kind === 177 && meaning & 32) { + if (location.kind === 183 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -9999,28 +10476,28 @@ var ts; } } break; - case 129: + case 133: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 205) { + if (ts.isClassLike(grandparent) || grandparent.kind === 212) { 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 136: - case 135: - case 137: - case 138: + case 140: case 139: - case 203: - case 166: + case 141: + case 142: + case 143: + case 210: + case 171: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 165: + case 170: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -10033,8 +10510,8 @@ var ts; } } break; - case 132: - if (location.parent && location.parent.kind === 131) { + case 136: + if (location.parent && location.parent.kind === 135) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -10072,14 +10549,14 @@ var ts; ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); var isUsedBeforeDeclaration = !isDefinedBefore(declaration, errorLocation); if (!isUsedBeforeDeclaration) { - var variableDeclaration = ts.getAncestor(declaration, 201); + var variableDeclaration = ts.getAncestor(declaration, 208); var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 183 || - variableDeclaration.parent.parent.kind === 189) { + if (variableDeclaration.parent.parent.kind === 190 || + variableDeclaration.parent.parent.kind === 196) { isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); } - else if (variableDeclaration.parent.parent.kind === 191 || - variableDeclaration.parent.parent.kind === 190) { + else if (variableDeclaration.parent.parent.kind === 198 || + variableDeclaration.parent.parent.kind === 197) { var expression = variableDeclaration.parent.parent.expression; isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); } @@ -10101,10 +10578,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 211) { + if (node.kind === 218) { return node; } - while (node && node.kind !== 212) { + while (node && node.kind !== 219) { node = node.parent; } return node; @@ -10114,7 +10591,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 222) { + if (node.moduleReference.kind === 229) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -10176,15 +10653,15 @@ var ts; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); if (targetSymbol) { - var name_8 = specifier.propertyName || specifier.name; - if (name_8.text) { - var symbolFromModule = getExportOfModule(targetSymbol, name_8.text); - var symbolFromVariable = getPropertyOfVariable(targetSymbol, name_8.text); + var name_9 = specifier.propertyName || specifier.name; + if (name_9.text) { + var symbolFromModule = getExportOfModule(targetSymbol, name_9.text); + var symbolFromVariable = getPropertyOfVariable(targetSymbol, name_9.text); var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable; if (!symbol) { - error(name_8, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_8)); + error(name_9, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_9)); } return symbol; } @@ -10203,17 +10680,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 211: + case 218: return getTargetOfImportEqualsDeclaration(node); - case 213: - return getTargetOfImportClause(node); - case 214: - return getTargetOfNamespaceImport(node); - case 216: - return getTargetOfImportSpecifier(node); case 220: + return getTargetOfImportClause(node); + case 221: + return getTargetOfNamespaceImport(node); + case 223: + return getTargetOfImportSpecifier(node); + case 227: return getTargetOfExportSpecifier(node); - case 217: + case 224: return getTargetOfExportAssignment(node); } } @@ -10255,10 +10732,10 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 217) { + if (node.kind === 224) { checkExpressionCached(node.expression); } - else if (node.kind === 220) { + else if (node.kind === 227) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -10268,45 +10745,47 @@ var ts; } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 211); + importDeclaration = ts.getAncestor(entityName, 218); ts.Debug.assert(importDeclaration !== undefined); } - if (entityName.kind === 65 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 66 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 65 || entityName.parent.kind === 128) { + if (entityName.kind === 66 || entityName.parent.kind === 132) { return resolveEntityName(entityName, 1536); } else { - ts.Debug.assert(entityName.parent.kind === 211); + ts.Debug.assert(entityName.parent.kind === 218); return resolveEntityName(entityName, 107455 | 793056 | 1536); } } function getFullyQualifiedName(symbol) { return symbol.parent ? getFullyQualifiedName(symbol.parent) + "." + symbolToString(symbol) : symbolToString(symbol); } - function resolveEntityName(name, meaning) { + function resolveEntityName(name, meaning, ignoreErrors) { if (ts.nodeIsMissing(name)) { return undefined; } var symbol; - if (name.kind === 65) { + if (name.kind === 66) { var message = meaning === 1536 ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; - symbol = resolveName(name, name.text, meaning, message, name); + symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 128 || name.kind === 158) { - var left = name.kind === 128 ? name.left : name.expression; - var right = name.kind === 128 ? name.right : name.name; - var namespace = resolveEntityName(left, 1536); + else if (name.kind === 132 || name.kind === 163) { + var left = name.kind === 132 ? name.left : name.expression; + var right = name.kind === 132 ? name.right : name.name; + var namespace = resolveEntityName(left, 1536, ignoreErrors); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; } symbol = getSymbol(getExportsOfSymbol(namespace), right.text, meaning); if (!symbol) { - error(right, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(namespace), ts.declarationNameToString(right)); + if (!ignoreErrors) { + error(right, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(namespace), ts.declarationNameToString(right)); + } return undefined; } } @@ -10444,7 +10923,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 137 && ts.nodeIsPresent(member.body)) { + if (member.kind === 141 && ts.nodeIsPresent(member.body)) { return member; } } @@ -10498,7 +10977,7 @@ var ts; return type; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { - return setObjectTypeMembers(createObjectType(32768, symbol), members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + return setObjectTypeMembers(createObjectType(65536, symbol), members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; @@ -10509,17 +10988,17 @@ var ts; } } switch (location_1.kind) { - case 230: + case 245: if (!ts.isExternalModule(location_1)) { break; } - case 208: + case 215: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 204: - case 205: + case 211: + case 212: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -10550,7 +11029,9 @@ var ts; return [symbol]; } return ts.forEachValue(symbols, function (symbolFromSymbolTable) { - if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=") { + if (symbolFromSymbolTable.flags & 8388608 + && symbolFromSymbolTable.name !== "export=" + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 227)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -10579,7 +11060,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 227)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -10634,8 +11115,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 208 && declaration.name.kind === 8) || - (declaration.kind === 230 && ts.isExternalModule(declaration)); + return (declaration.kind === 215 && declaration.name.kind === 8) || + (declaration.kind === 245 && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -10667,11 +11148,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 147) { + if (entityName.parent.kind === 151) { meaning = 107455 | 1048576; } - else if (entityName.kind === 128 || entityName.kind === 158 || - entityName.parent.kind === 211) { + else if (entityName.kind === 132 || entityName.kind === 163 || + entityName.parent.kind === 218) { meaning = 1536; } else { @@ -10722,10 +11203,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 152) { + while (node.kind === 157) { node = node.parent; } - if (node.kind === 206) { + if (node.kind === 213) { return getSymbolOfNode(node); } } @@ -10740,10 +11221,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 177: + case 183: return "(Anonymous class)"; - case 165: - case 166: + case 170: + case 171: return "(Anonymous function)"; } } @@ -10806,7 +11287,7 @@ var ts; var globalFlagsToPass = globalFlags & 16; return writeType(type, globalFlags); function writeType(type, flags) { - if (type.flags & 2097279) { + if (type.flags & 4194431) { writer.writeKeyword(!(globalFlags & 16) && isTypeAny(type) ? "any" : type.intrinsicName); @@ -10820,10 +11301,10 @@ var ts; else if (type.flags & 8192) { writeTupleType(type); } - else if (type.flags & 16384) { - writeUnionType(type, flags); + else if (type.flags & 49152) { + writeUnionOrIntersectionType(type, flags); } - else if (type.flags & 32768) { + else if (type.flags & 65536) { writeAnonymousType(type, flags); } else if (type.flags & 256) { @@ -10837,16 +11318,16 @@ var ts; writePunctuation(writer, 15); } } - function writeTypeList(types, union) { + function writeTypeList(types, delimiter) { for (var i = 0; i < types.length; i++) { if (i > 0) { - if (union) { + if (delimiter !== 23) { writeSpace(writer); } - writePunctuation(writer, union ? 44 : 23); + writePunctuation(writer, delimiter); writeSpace(writer); } - writeType(types[i], union ? 64 : 0); + writeType(types[i], delimiter === 23 ? 0 : 64); } } function writeSymbolTypeReference(symbol, typeArguments, pos, end) { @@ -10861,7 +11342,7 @@ var ts; writeSpace(writer); writeType(typeArguments[pos++], 0); } - writePunctuation(writer, 25); + writePunctuation(writer, 26); } } function writeTypeReference(type, flags) { @@ -10893,14 +11374,14 @@ var ts; } function writeTupleType(type) { writePunctuation(writer, 18); - writeTypeList(type.elementTypes, false); + writeTypeList(type.elementTypes, 23); writePunctuation(writer, 19); } - function writeUnionType(type, flags) { + function writeUnionOrIntersectionType(type, flags) { if (flags & 64) { writePunctuation(writer, 16); } - writeTypeList(type.types, true); + writeTypeList(type.types, type.flags & 16384 ? 45 : 44); if (flags & 64) { writePunctuation(writer, 17); } @@ -10920,7 +11401,7 @@ var ts; buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793056, 0, flags); } else { - writeKeyword(writer, 112); + writeKeyword(writer, 114); } } else { @@ -10941,7 +11422,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 230 || declaration.parent.kind === 209; + return declaration.parent.kind === 245 || declaration.parent.kind === 216; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -10950,7 +11431,7 @@ var ts; } } function writeTypeofSymbol(type, typeFormatFlags) { - writeKeyword(writer, 97); + writeKeyword(writer, 98); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } @@ -10963,7 +11444,7 @@ var ts; return ts.declarationNameToString(declaration.parameters[0].name); } function writeLiteralType(type, flags) { - var resolved = resolveObjectOrUnionTypeMembers(type); + var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { writePunctuation(writer, 14); @@ -10984,7 +11465,7 @@ var ts; if (flags & 64) { writePunctuation(writer, 16); } - writeKeyword(writer, 88); + writeKeyword(writer, 89); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, symbolStack); if (flags & 64) { @@ -11004,7 +11485,7 @@ var ts; } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - writeKeyword(writer, 88); + writeKeyword(writer, 89); writeSpace(writer); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); writePunctuation(writer, 22); @@ -11013,11 +11494,11 @@ var ts; if (resolved.stringIndexType) { writePunctuation(writer, 18); writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); - writePunctuation(writer, 51); + writePunctuation(writer, 52); writeSpace(writer); - writeKeyword(writer, 123); + writeKeyword(writer, 127); writePunctuation(writer, 19); - writePunctuation(writer, 51); + writePunctuation(writer, 52); writeSpace(writer); writeType(resolved.stringIndexType, 0); writePunctuation(writer, 22); @@ -11026,11 +11507,11 @@ var ts; if (resolved.numberIndexType) { writePunctuation(writer, 18); writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); - writePunctuation(writer, 51); + writePunctuation(writer, 52); writeSpace(writer); - writeKeyword(writer, 121); + writeKeyword(writer, 125); writePunctuation(writer, 19); - writePunctuation(writer, 51); + writePunctuation(writer, 52); writeSpace(writer); writeType(resolved.numberIndexType, 0); writePunctuation(writer, 22); @@ -11045,7 +11526,7 @@ var ts; var signature = signatures[_f]; buildSymbolDisplay(p, writer); if (p.flags & 536870912) { - writePunctuation(writer, 50); + writePunctuation(writer, 51); } buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); writePunctuation(writer, 22); @@ -11055,9 +11536,9 @@ var ts; else { buildSymbolDisplay(p, writer); if (p.flags & 536870912) { - writePunctuation(writer, 50); + writePunctuation(writer, 51); } - writePunctuation(writer, 51); + writePunctuation(writer, 52); writeSpace(writer); writeType(t, 0); writePunctuation(writer, 22); @@ -11079,7 +11560,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 79); + writeKeyword(writer, 80); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -11091,9 +11572,9 @@ var ts; } appendSymbolNameOnly(p, writer); if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 50); + writePunctuation(writer, 51); } - writePunctuation(writer, 51); + writePunctuation(writer, 52); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } @@ -11107,7 +11588,7 @@ var ts; } buildTypeParameterDisplay(typeParameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 25); + writePunctuation(writer, 26); } } function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, symbolStack) { @@ -11120,7 +11601,7 @@ var ts; } buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, 0); } - writePunctuation(writer, 25); + writePunctuation(writer, 26); } } function buildDisplayForParametersAndDelimiters(parameters, writer, enclosingDeclaration, flags, symbolStack) { @@ -11137,13 +11618,24 @@ var ts; function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { if (flags & 8) { writeSpace(writer); - writePunctuation(writer, 32); + writePunctuation(writer, 33); } else { - writePunctuation(writer, 51); + writePunctuation(writer, 52); } writeSpace(writer); - buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags, symbolStack); + var returnType; + if (signature.typePredicate) { + writer.writeParameter(signature.typePredicate.parameterName); + writeSpace(writer); + writeKeyword(writer, 121); + writeSpace(writer); + returnType = signature.typePredicate.type; + } + else { + returnType = getReturnTypeOfSignature(signature); + } + buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); } function buildSignatureDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { if (signature.target && (flags & 32)) { @@ -11173,12 +11665,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 208) { + if (node.kind === 215) { if (node.name.kind === 8) { return node; } } - else if (node.kind === 230) { + else if (node.kind === 245) { return ts.isExternalModule(node) ? node : undefined; } } @@ -11221,58 +11713,59 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 155: + case 160: return isDeclarationVisible(node.parent.parent); - case 201: + case 208: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 208: - case 204: - case 205: - case 206: - case 203: - case 207: + case 215: case 211: + case 212: + case 213: + case 210: + case 214: + case 218: var parent_4 = getDeclarationContainer(node); if (!(ts.getCombinedNodeFlags(node) & 1) && - !(node.kind !== 211 && parent_4.kind !== 230 && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 218 && parent_4.kind !== 245 && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } return isDeclarationVisible(parent_4); - case 134: - case 133: case 138: + case 137: + case 142: + case 143: + case 140: case 139: - case 136: - case 135: if (node.flags & (32 | 64)) { return false; } - case 137: case 141: - case 140: - case 142: - case 131: - case 209: case 145: - case 146: - case 148: case 144: + case 146: + case 135: + case 216: case 149: case 150: - case 151: case 152: + case 148: + case 153: + case 154: + case 155: + case 156: + case 157: return isDeclarationVisible(node.parent); - case 213: - case 214: - case 216: + case 220: + case 221: + case 223: return false; - case 130: - case 230: + case 134: + case 245: return true; - case 217: + case 224: return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -11288,10 +11781,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 217) { + if (node.parent && node.parent.kind === 224) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 220) { + else if (node.parent.kind === 227) { exportSymbol = getTargetOfExportSpecifier(node.parent); } var result = []; @@ -11337,7 +11830,7 @@ var ts; } function getDeclarationContainer(node) { node = ts.getRootDeclaration(node); - return node.kind === 201 ? node.parent.parent.parent : node.parent; + return node.kind === 208 ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { var classType = getDeclaredTypeOfSymbol(prototype.parent); @@ -11363,13 +11856,13 @@ var ts; return parentType; } var type; - if (pattern.kind === 153) { - var name_9 = declaration.propertyName || declaration.name; - type = getTypeOfPropertyOfType(parentType, name_9.text) || - isNumericLiteralName(name_9.text) && getIndexTypeOfType(parentType, 1) || + if (pattern.kind === 158) { + var name_10 = declaration.propertyName || declaration.name; + type = getTypeOfPropertyOfType(parentType, name_10.text) || + isNumericLiteralName(name_10.text) && getIndexTypeOfType(parentType, 1) || getIndexTypeOfType(parentType, 0); if (!type) { - error(name_9, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_9)); + error(name_10, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_10)); return unknownType; } } @@ -11400,10 +11893,10 @@ var ts; return type; } function getTypeForVariableLikeDeclaration(declaration) { - if (declaration.parent.parent.kind === 190) { + if (declaration.parent.parent.kind === 197) { return anyType; } - if (declaration.parent.parent.kind === 191) { + if (declaration.parent.parent.kind === 198) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -11412,10 +11905,10 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 131) { + if (declaration.kind === 135) { var func = declaration.parent; - if (func.kind === 139 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 138); + if (func.kind === 143 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 142); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -11428,7 +11921,7 @@ var ts; if (declaration.initializer) { return checkExpressionCached(declaration.initializer); } - if (declaration.kind === 228) { + if (declaration.kind === 243) { return checkIdentifier(declaration.name); } return undefined; @@ -11457,7 +11950,7 @@ var ts; var hasSpreadElement = false; var elementTypes = []; ts.forEach(pattern.elements, function (e) { - elementTypes.push(e.kind === 178 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); + elementTypes.push(e.kind === 184 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); if (e.dotDotDotToken) { hasSpreadElement = true; } @@ -11472,7 +11965,7 @@ var ts; return createTupleType(elementTypes); } function getTypeFromBindingPattern(pattern) { - return pattern.kind === 153 + return pattern.kind === 158 ? getTypeFromObjectBindingPattern(pattern) : getTypeFromArrayBindingPattern(pattern); } @@ -11482,7 +11975,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - return declaration.kind !== 227 ? getWidenedType(type) : type; + return declaration.kind !== 242 ? getWidenedType(type) : type; } if (ts.isBindingPattern(declaration.name)) { return getTypeFromBindingPattern(declaration.name); @@ -11490,7 +11983,7 @@ var ts; type = declaration.dotDotDotToken ? anyArrayType : anyType; if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 131 && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 135 && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -11503,10 +11996,10 @@ var ts; return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 226) { + if (declaration.parent.kind === 241) { return links.type = anyType; } - if (declaration.kind === 217) { + if (declaration.kind === 224) { return links.type = checkExpression(declaration.expression); } if (!pushTypeResolution(symbol)) { @@ -11529,16 +12022,13 @@ var ts; } return links.type; } - function getSetAccessorTypeAnnotationNode(accessor) { - return accessor && accessor.parameters.length > 0 && accessor.parameters[0].type; - } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 138) { + if (accessor.kind === 142) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { - var setterTypeAnnotation = getSetAccessorTypeAnnotationNode(accessor); + var setterTypeAnnotation = ts.getSetAccessorTypeAnnotationNode(accessor); return setterTypeAnnotation && getTypeFromTypeNode(setterTypeAnnotation); } } @@ -11550,8 +12040,8 @@ var ts; if (!pushTypeResolution(symbol)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 138); - var setter = ts.getDeclarationOfKind(symbol, 139); + var getter = ts.getDeclarationOfKind(symbol, 142); + var setter = ts.getDeclarationOfKind(symbol, 143); var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -11577,7 +12067,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 138); + var getter_1 = ts.getDeclarationOfKind(symbol, 142); 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)); } } @@ -11588,7 +12078,7 @@ var ts; function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - links.type = createObjectType(32768, symbol); + links.type = createObjectType(65536, symbol); } return links.type; } @@ -11666,9 +12156,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 204 || node.kind === 177 || - node.kind === 203 || node.kind === 165 || - node.kind === 136 || node.kind === 166) { + if (node.kind === 211 || node.kind === 183 || + node.kind === 210 || node.kind === 170 || + node.kind === 140 || node.kind === 171) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -11677,15 +12167,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 205); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 212); 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 === 205 || node.kind === 204 || - node.kind === 177 || node.kind === 206) { + if (node.kind === 212 || node.kind === 211 || + node.kind === 183 || node.kind === 213) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -11698,7 +12188,7 @@ var ts; return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); } function isConstructorType(type) { - return type.flags & 48128 && getSignaturesOfType(type, 1).length > 0; + return type.flags & 80896 && getSignaturesOfType(type, 1).length > 0; } function getBaseTypeNodeOfClass(type) { return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); @@ -11725,8 +12215,8 @@ var ts; return unknownType; } var baseConstructorType = checkExpression(baseTypeNode.expression); - if (baseConstructorType.flags & 48128) { - resolveObjectOrUnionTypeMembers(baseConstructorType); + if (baseConstructorType.flags & 80896) { + resolveStructuredTypeMembers(baseConstructorType); } if (!popTypeResolution()) { error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); @@ -11757,7 +12247,7 @@ var ts; function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = emptyArray; var baseContructorType = getBaseConstructorTypeOfClass(type); - if (!(baseContructorType.flags & 48128)) { + if (!(baseContructorType.flags & 80896)) { return; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -11790,7 +12280,7 @@ var ts; type.resolvedBaseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 205 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 212 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -11837,7 +12327,7 @@ var ts; if (!pushTypeResolution(links)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 206); + var declaration = ts.getDeclarationOfKind(symbol, 213); var type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -11868,7 +12358,7 @@ var ts; if (!links.declaredType) { var type = createType(512); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 130).constraint) { + if (!ts.getDeclarationOfKind(symbol, 134).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -12030,7 +12520,7 @@ var ts; return members; } function resolveTupleTypeMembers(type) { - var arrayType = resolveObjectOrUnionTypeMembers(createArrayType(getUnionType(type.elementTypes))); + var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes))); var members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); @@ -12087,6 +12577,23 @@ var ts; var numberIndexType = getUnionIndexType(type.types, 1); setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); } + function intersectTypes(type1, type2) { + return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); + } + function resolveIntersectionTypeMembers(type) { + var callSignatures = emptyArray; + var constructSignatures = emptyArray; + var stringIndexType = undefined; + var numberIndexType = undefined; + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(t, 0)); + constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(t, 1)); + stringIndexType = intersectTypes(stringIndexType, getIndexTypeOfType(t, 0)); + numberIndexType = intersectTypes(numberIndexType, getIndexTypeOfType(t, 1)); + } + setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); + } function resolveAnonymousTypeMembers(type) { var symbol = type.symbol; var members; @@ -12118,7 +12625,7 @@ var ts; constructSignatures = getDefaultConstructSignatures(classType); } var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & 48128) { + if (baseConstructorType.flags & 80896) { members = createSymbolTable(getNamedMembers(members)); addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); } @@ -12128,12 +12635,12 @@ var ts; } setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } - function resolveObjectOrUnionTypeMembers(type) { + function resolveStructuredTypeMembers(type) { if (!type.members) { if (type.flags & (1024 | 2048)) { resolveClassOrInterfaceMembers(type); } - else if (type.flags & 32768) { + else if (type.flags & 65536) { resolveAnonymousTypeMembers(type); } else if (type.flags & 8192) { @@ -12142,6 +12649,9 @@ var ts; else if (type.flags & 16384) { resolveUnionTypeMembers(type); } + else if (type.flags & 32768) { + resolveIntersectionTypeMembers(type); + } else { resolveTypeReferenceMembers(type); } @@ -12149,14 +12659,14 @@ var ts; return type; } function getPropertiesOfObjectType(type) { - if (type.flags & 48128) { - return resolveObjectOrUnionTypeMembers(type).properties; + if (type.flags & 80896) { + return resolveStructuredTypeMembers(type).properties; } return emptyArray; } function getPropertyOfObjectType(type, name) { - if (type.flags & 48128) { - var resolved = resolveObjectOrUnionTypeMembers(type); + if (type.flags & 80896) { + var resolved = resolveStructuredTypeMembers(type); if (ts.hasProperty(resolved.members, name)) { var symbol = resolved.members[name]; if (symbolIsValue(symbol)) { @@ -12165,19 +12675,22 @@ var ts; } } } - function getPropertiesOfUnionType(type) { - var result = []; - ts.forEach(getPropertiesOfType(type.types[0]), function (prop) { - var unionProp = getPropertyOfUnionType(type, prop.name); - if (unionProp) { - result.push(unionProp); + function getPropertiesOfUnionOrIntersectionType(type) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var current = _a[_i]; + for (var _b = 0, _c = getPropertiesOfType(current); _b < _c.length; _b++) { + var prop = _c[_b]; + getPropertyOfUnionOrIntersectionType(type, prop.name); } - }); - return result; + if (type.flags & 16384) { + break; + } + } + return type.resolvedProperties ? symbolsToArray(type.resolvedProperties) : emptyArray; } function getPropertiesOfType(type) { type = getApparentType(type); - return type.flags & 16384 ? getPropertiesOfUnionType(type) : getPropertiesOfObjectType(type); + return type.flags & 49152 ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } function getApparentType(type) { if (type.flags & 16384) { @@ -12200,51 +12713,59 @@ var ts; else if (type.flags & 8) { type = globalBooleanType; } - else if (type.flags & 2097152) { + else if (type.flags & 4194304) { type = globalESSymbolType; } return type; } - function createUnionProperty(unionType, name) { - var types = unionType.types; + function createUnionOrIntersectionProperty(containingType, name) { + var types = containingType.types; var props; for (var _i = 0; _i < types.length; _i++) { var current = types[_i]; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); - if (!prop || getDeclarationFlagsFromSymbol(prop) & (32 | 64)) { + if (prop && !(getDeclarationFlagsFromSymbol(prop) & (32 | 64))) { + if (!props) { + props = [prop]; + } + else if (!ts.contains(props, prop)) { + props.push(prop); + } + } + else if (containingType.flags & 16384) { return undefined; } - if (!props) { - props = [prop]; - } - else { - props.push(prop); - } } } + if (!props) { + return undefined; + } + if (props.length === 1) { + return props[0]; + } var propTypes = []; var declarations = []; for (var _a = 0; _a < props.length; _a++) { var prop = props[_a]; if (prop.declarations) { - declarations.push.apply(declarations, prop.declarations); + ts.addRange(declarations, prop.declarations); } propTypes.push(getTypeOfSymbol(prop)); } var result = createSymbol(4 | 67108864 | 268435456, name); - result.unionType = unionType; + result.containingType = containingType; result.declarations = declarations; - result.type = getUnionType(propTypes); + result.type = containingType.flags & 16384 ? getUnionType(propTypes) : getIntersectionType(propTypes); return result; } - function getPropertyOfUnionType(type, name) { + function getPropertyOfUnionOrIntersectionType(type, name) { var properties = type.resolvedProperties || (type.resolvedProperties = {}); if (ts.hasProperty(properties, name)) { return properties[name]; } - var property = createUnionProperty(type, name); + var property = createUnionOrIntersectionProperty(type, name); if (property) { properties[name] = property; } @@ -12252,8 +12773,8 @@ var ts; } function getPropertyOfType(type, name) { type = getApparentType(type); - if (type.flags & 48128) { - var resolved = resolveObjectOrUnionTypeMembers(type); + if (type.flags & 80896) { + var resolved = resolveStructuredTypeMembers(type); if (ts.hasProperty(resolved.members, name)) { var symbol = resolved.members[name]; if (symbolIsValue(symbol)) { @@ -12268,38 +12789,45 @@ var ts; } return getPropertyOfObjectType(globalObjectType, name); } - if (type.flags & 16384) { - return getPropertyOfUnionType(type, name); + if (type.flags & 49152) { + return getPropertyOfUnionOrIntersectionType(type, name); } return undefined; } - function getSignaturesOfObjectOrUnionType(type, kind) { - if (type.flags & (48128 | 16384)) { - var resolved = resolveObjectOrUnionTypeMembers(type); + function getSignaturesOfStructuredType(type, kind) { + if (type.flags & 130048) { + var resolved = resolveStructuredTypeMembers(type); return kind === 0 ? resolved.callSignatures : resolved.constructSignatures; } return emptyArray; } function getSignaturesOfType(type, kind) { - return getSignaturesOfObjectOrUnionType(getApparentType(type), kind); + return getSignaturesOfStructuredType(getApparentType(type), kind); } - function typeHasCallOrConstructSignatures(type) { + function typeHasConstructSignatures(type) { var apparentType = getApparentType(type); - if (apparentType.flags & (48128 | 16384)) { - var resolved = resolveObjectOrUnionTypeMembers(type); - return resolved.callSignatures.length > 0 - || resolved.constructSignatures.length > 0; + if (apparentType.flags & (80896 | 16384)) { + var resolved = resolveStructuredTypeMembers(type); + return resolved.constructSignatures.length > 0; } return false; } - function getIndexTypeOfObjectOrUnionType(type, kind) { - if (type.flags & (48128 | 16384)) { - var resolved = resolveObjectOrUnionTypeMembers(type); + function typeHasCallOrConstructSignatures(type) { + var apparentType = getApparentType(type); + if (apparentType.flags & 130048) { + var resolved = resolveStructuredTypeMembers(type); + return resolved.callSignatures.length > 0 || resolved.constructSignatures.length > 0; + } + return false; + } + function getIndexTypeOfStructuredType(type, kind) { + if (type.flags & 130048) { + var resolved = resolveStructuredTypeMembers(type); return kind === 0 ? resolved.stringIndexType : resolved.numberIndexType; } } function getIndexTypeOfType(type, kind) { - return getIndexTypeOfObjectOrUnionType(getApparentType(type), kind); + return getIndexTypeOfStructuredType(getApparentType(type), kind); } function getTypeParametersFromDeclaration(typeParameterDeclarations) { var result = []; @@ -12326,7 +12854,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 137 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 141 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -12354,7 +12882,7 @@ var ts; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); - if (declaration.type.kind === 143) { + if (declaration.type.kind === 147) { var typePredicateNode = declaration.type; typePredicate = { parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, @@ -12364,8 +12892,8 @@ var ts; } } else { - if (declaration.kind === 138 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 139); + if (declaration.kind === 142 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 143); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -12383,19 +12911,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { + case 149: + case 150: + case 210: + case 140: + case 139: + case 141: + case 144: case 145: case 146: - case 203: - case 136: - case 135: - case 137: - case 140: - case 141: case 142: - case 138: - case 139: - case 165: - case 166: + case 143: + case 170: + case 171: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -12465,8 +12993,8 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 137 || signature.declaration.kind === 141; - var type = createObjectType(32768 | 131072); + var isConstructor = signature.declaration.kind === 141 || signature.declaration.kind === 145; + var type = createObjectType(65536 | 262144); type.members = emptySymbols; type.properties = emptyArray; type.callSignatures = !isConstructor ? [signature] : emptyArray; @@ -12479,10 +13007,9 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 121 : 123; + var syntaxKind = kind === 1 ? 125 : 127; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { - var len = indexSymbol.declarations.length; for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; var node = decl; @@ -12509,13 +13036,13 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 130).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 134).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 130).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 134).parent); } function getTypeListId(types) { switch (types.length) { @@ -12540,7 +13067,7 @@ var ts; var type = types[_i]; result |= type.flags; } - return result & 1572864; + return result & 3145728; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); @@ -12562,13 +13089,13 @@ var ts; while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { currentNode = currentNode.parent; } - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 130; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 134; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 144 && n.typeName.kind === 65) { + if (n.kind === 148 && n.typeName.kind === 66) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056, undefined, undefined); @@ -12635,7 +13162,7 @@ var ts; function getTypeFromTypeReference(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var typeNameOrExpression = node.kind === 144 ? node.typeName : + var typeNameOrExpression = node.kind === 148 ? node.typeName : ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : undefined; var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056) || unknownSymbol; @@ -12661,9 +13188,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 204: - case 205: - case 207: + case 211: + case 212: + case 214: return declaration; } } @@ -12672,7 +13199,7 @@ var ts; return arity ? emptyGenericType : emptyObjectType; } var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 48128)) { + if (!(type.flags & 80896)) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name); return arity ? emptyGenericType : emptyObjectType; } @@ -12695,6 +13222,15 @@ var ts; if (arity === void 0) { arity = 0; } return getTypeOfGlobalSymbol(getGlobalTypeSymbol(name), arity); } + function tryGetGlobalType(name, arity) { + if (arity === void 0) { arity = 0; } + return getTypeOfGlobalSymbol(getGlobalSymbol(name, 793056, undefined), arity); + } + function getExportedTypeFromNamespace(namespace, name) { + var namespaceSymbol = getGlobalSymbol(namespace, 1536, undefined); + var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793056); + return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); + } function getGlobalESSymbolConstructorSymbol() { return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol")); } @@ -12739,25 +13275,18 @@ var ts; } return links.resolvedType; } - function addTypeToSortedSet(sortedSet, type) { - if (type.flags & 16384) { - addTypesToSortedSet(sortedSet, type.types); + function addTypeToSet(typeSet, type, typeSetKind) { + if (type.flags & typeSetKind) { + addTypesToSet(typeSet, type.types, typeSetKind); } - else { - var i = 0; - var id = type.id; - while (i < sortedSet.length && sortedSet[i].id < id) { - i++; - } - if (i === sortedSet.length || sortedSet[i].id !== id) { - sortedSet.splice(i, 0, type); - } + else if (!ts.contains(typeSet, type)) { + typeSet.push(type); } } - function addTypesToSortedSet(sortedTypes, types) { + function addTypesToSet(typeSet, types, typeSetKind) { for (var _i = 0; _i < types.length; _i++) { var type = types[_i]; - addTypeToSortedSet(sortedTypes, type); + addTypeToSet(typeSet, type, typeSetKind); } } function isSubtypeOfAny(candidate, types) { @@ -12796,30 +13325,34 @@ var ts; } } } + function compareTypeIds(type1, type2) { + return type1.id - type2.id; + } function getUnionType(types, noSubtypeReduction) { if (types.length === 0) { return emptyObjectType; } - var sortedTypes = []; - addTypesToSortedSet(sortedTypes, types); + var typeSet = []; + addTypesToSet(typeSet, types, 16384); + typeSet.sort(compareTypeIds); if (noSubtypeReduction) { - if (containsTypeAny(sortedTypes)) { + if (containsTypeAny(typeSet)) { return anyType; } - removeAllButLast(sortedTypes, undefinedType); - removeAllButLast(sortedTypes, nullType); + removeAllButLast(typeSet, undefinedType); + removeAllButLast(typeSet, nullType); } else { - removeSubtypes(sortedTypes); + removeSubtypes(typeSet); } - if (sortedTypes.length === 1) { - return sortedTypes[0]; + if (typeSet.length === 1) { + return typeSet[0]; } - var id = getTypeListId(sortedTypes); + var id = getTypeListId(typeSet); var type = unionTypes[id]; if (!type) { - type = unionTypes[id] = createObjectType(16384 | getWideningFlagsOfTypes(sortedTypes)); - type.types = sortedTypes; + type = unionTypes[id] = createObjectType(16384 | getWideningFlagsOfTypes(typeSet)); + type.types = typeSet; type.reducedType = noSubtypeReduction ? undefined : type; } return type; @@ -12844,10 +13377,37 @@ var ts; } return links.resolvedType; } + function getIntersectionType(types) { + if (types.length === 0) { + return emptyObjectType; + } + var typeSet = []; + addTypesToSet(typeSet, types, 32768); + if (containsTypeAny(typeSet)) { + return anyType; + } + if (typeSet.length === 1) { + return typeSet[0]; + } + var id = getTypeListId(typeSet); + var type = intersectionTypes[id]; + if (!type) { + type = intersectionTypes[id] = createObjectType(32768 | getWideningFlagsOfTypes(typeSet)); + type.types = typeSet; + } + return type; + } + function getTypeFromIntersectionTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode)); + } + return links.resolvedType; + } function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = createObjectType(32768, node.symbol); + links.resolvedType = createObjectType(65536, node.symbol); } return links.resolvedType; } @@ -12868,42 +13428,44 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 112: + case 114: return anyType; - case 123: + case 127: return stringType; - case 121: + case 125: return numberType; - case 113: + case 117: return booleanType; - case 124: + case 128: return esSymbolType; - case 99: + case 100: return voidType; case 8: return getTypeFromStringLiteral(node); - case 144: - return getTypeFromTypeReference(node); - case 143: - return booleanType; - case 179: + case 148: return getTypeFromTypeReference(node); case 147: - return getTypeFromTypeQueryNode(node); - case 149: - return getTypeFromArrayTypeNode(node); - case 150: - return getTypeFromTupleTypeNode(node); + return booleanType; + case 185: + return getTypeFromTypeReference(node); case 151: + return getTypeFromTypeQueryNode(node); + case 153: + return getTypeFromArrayTypeNode(node); + case 154: + return getTypeFromTupleTypeNode(node); + case 155: return getTypeFromUnionTypeNode(node); - case 152: + case 156: + return getTypeFromIntersectionTypeNode(node); + case 157: return getTypeFromTypeNode(node.type); - case 145: - case 146: - case 148: + case 149: + case 150: + case 152: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 65: - case 128: + case 66: + case 132: var symbol = getSymbolInfo(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -13027,7 +13589,7 @@ var ts; return result; } function instantiateAnonymousType(type, mapper) { - var result = createObjectType(32768 | 65536, type.symbol); + 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); @@ -13045,7 +13607,7 @@ var ts; if (type.flags & 512) { return mapper(type); } - if (type.flags & 32768) { + if (type.flags & 65536) { return type.symbol && type.symbol.flags & (16 | 8192 | 32 | 2048 | 4096) ? instantiateAnonymousType(type, mapper) : type; } @@ -13058,31 +13620,34 @@ var ts; if (type.flags & 16384) { return getUnionType(instantiateList(type.types, mapper, instantiateType), true); } + if (type.flags & 32768) { + return getIntersectionType(instantiateList(type.types, mapper, instantiateType)); + } } return type; } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 136 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 140 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 165: - case 166: + case 170: + case 171: return isContextSensitiveFunctionLikeDeclaration(node); - case 157: + case 162: return ts.forEach(node.properties, isContextSensitive); - case 156: + case 161: return ts.forEach(node.elements, isContextSensitive); - case 173: + case 179: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 172: - return node.operatorToken.kind === 49 && + case 178: + return node.operatorToken.kind === 50 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 227: + case 242: return isContextSensitive(node.initializer); - case 136: - case 135: + case 140: + case 139: return isContextSensitiveFunctionLikeDeclaration(node); - case 164: + case 169: return isContextSensitive(node.expression); } return false; @@ -13091,10 +13656,10 @@ var ts; return !node.typeParameters && node.parameters.length && !ts.forEach(node.parameters, function (p) { return p.type; }); } function getTypeWithoutSignatures(type) { - if (type.flags & 48128) { - var resolved = resolveObjectOrUnionTypeMembers(type); + if (type.flags & 80896) { + var resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length) { - var result = createObjectType(32768, type.symbol); + var result = createObjectType(65536, type.symbol); result.members = resolved.members; result.properties = resolved.properties; result.callSignatures = emptyArray; @@ -13179,37 +13744,9 @@ var ts; } } var saveErrorInfo = errorInfo; - if (source.flags & 16384 || target.flags & 16384) { - if (relation === identityRelation) { - if (source.flags & 16384 && target.flags & 16384) { - if (result = unionTypeRelatedToUnionType(source, target)) { - if (result &= unionTypeRelatedToUnionType(target, source)) { - return result; - } - } - } - else if (source.flags & 16384) { - if (result = unionTypeRelatedToType(source, target, reportErrors)) { - return result; - } - } - else { - if (result = unionTypeRelatedToType(target, source, reportErrors)) { - return result; - } - } - } - else { - if (source.flags & 16384) { - if (result = unionTypeRelatedToType(source, target, reportErrors)) { - return result; - } - } - else { - if (result = typeRelatedToUnionType(source, target, reportErrors)) { - return result; - } - } + if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { + if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + return result; } } else if (source.flags & 512 && target.flags & 512) { @@ -13217,20 +13754,49 @@ var ts; return result; } } - else if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { - return result; + else if (relation !== identityRelation) { + if (source.flags & 16384) { + if (result = eachTypeRelatedToType(source, target, reportErrors)) { + return result; + } + } + else if (target.flags & 32768) { + if (result = typeRelatedToEachType(source, target, reportErrors)) { + return result; + } + } + else { + if (source.flags & 32768) { + if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384))) { + return result; + } + } + if (target.flags & 16384) { + if (result = typeRelatedToSomeType(source, target, reportErrors)) { + return result; + } + } + } + } + else { + if (source.flags & 16384 && target.flags & 16384 || + source.flags & 32768 && target.flags & 32768) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { + return result; + } + } } } var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; var sourceOrApparentType = relation === identityRelation ? source : getApparentType(source); - if (sourceOrApparentType.flags & 48128 && target.flags & 48128) { + if (sourceOrApparentType.flags & (80896 | 32768) && target.flags & 80896) { if (result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors)) { errorInfo = saveErrorInfo; return result; } } - else if (source.flags & 512 && sourceOrApparentType.flags & 16384) { + else if (source.flags & 512 && sourceOrApparentType.flags & 49152) { errorInfo = saveErrorInfo; if (result = isRelatedTo(sourceOrApparentType, target, reportErrors)) { return result; @@ -13248,12 +13814,12 @@ var ts; } return 0; } - function unionTypeRelatedToUnionType(source, target) { + function eachTypeRelatedToSomeType(source, target) { var result = -1; var sourceTypes = source.types; for (var _i = 0; _i < sourceTypes.length; _i++) { var sourceType = sourceTypes[_i]; - var related = typeRelatedToUnionType(sourceType, target, false); + var related = typeRelatedToSomeType(sourceType, target, false); if (!related) { return 0; } @@ -13261,7 +13827,7 @@ var ts; } return result; } - function typeRelatedToUnionType(source, target, reportErrors) { + function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; for (var i = 0, len = targetTypes.length; i < len; i++) { var related = isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1); @@ -13271,7 +13837,30 @@ var ts; } return 0; } - function unionTypeRelatedToType(source, target, reportErrors) { + function typeRelatedToEachType(source, target, reportErrors) { + var result = -1; + var targetTypes = target.types; + for (var _i = 0; _i < targetTypes.length; _i++) { + var targetType = targetTypes[_i]; + var related = isRelatedTo(source, targetType, reportErrors); + if (!related) { + return 0; + } + result &= related; + } + return result; + } + function someTypeRelatedToType(source, target, reportErrors) { + var sourceTypes = source.types; + for (var i = 0, len = sourceTypes.length; i < len; i++) { + var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); + if (related) { + return related; + } + } + return 0; + } + function eachTypeRelatedToType(source, target, reportErrors) { var result = -1; var sourceTypes = source.types; for (var _i = 0; _i < sourceTypes.length; _i++) { @@ -13395,7 +13984,7 @@ var ts; } var result = -1; var properties = getPropertiesOfObjectType(target); - var requireOptionalProperties = relation === subtypeRelation && !(source.flags & 262144); + var requireOptionalProperties = relation === subtypeRelation && !(source.flags & 524288); for (var _i = 0; _i < properties.length; _i++) { var targetProp = properties[_i]; var sourceProp = getPropertyOfType(source, targetProp.name); @@ -13409,22 +13998,22 @@ var ts; } } else if (!(targetProp.flags & 134217728)) { - var sourceFlags = getDeclarationFlagsFromSymbol(sourceProp); - var targetFlags = getDeclarationFlagsFromSymbol(targetProp); - if (sourceFlags & 32 || targetFlags & 32) { + var sourcePropFlags = getDeclarationFlagsFromSymbol(sourceProp); + var targetPropFlags = getDeclarationFlagsFromSymbol(targetProp); + if (sourcePropFlags & 32 || targetPropFlags & 32) { if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { - if (sourceFlags & 32 && targetFlags & 32) { + if (sourcePropFlags & 32 && targetPropFlags & 32) { reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); } else { - reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourceFlags & 32 ? source : target), typeToString(sourceFlags & 32 ? target : source)); + reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 32 ? source : target), typeToString(sourcePropFlags & 32 ? target : source)); } } return 0; } } - else if (targetFlags & 64) { + else if (targetPropFlags & 64) { var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32; var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(sourceProp.parent) : undefined; var targetClass = getDeclaredTypeOfSymbol(targetProp.parent); @@ -13435,7 +14024,7 @@ var ts; return 0; } } - else if (sourceFlags & 64) { + else if (sourcePropFlags & 64) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } @@ -13461,6 +14050,9 @@ var ts; return result; } function propertiesIdenticalTo(source, target) { + if (!(source.flags & 80896 && target.flags & 80896)) { + return 0; + } var sourceProperties = getPropertiesOfObjectType(source); var targetProperties = getPropertiesOfObjectType(target); if (sourceProperties.length !== targetProperties.length) { @@ -13494,11 +14086,11 @@ var ts; var saveErrorInfo = errorInfo; outer: for (var _i = 0; _i < targetSignatures.length; _i++) { var t = targetSignatures[_i]; - if (!t.hasStringLiterals || target.flags & 131072) { + if (!t.hasStringLiterals || target.flags & 262144) { var localErrors = reportErrors; for (var _a = 0; _a < sourceSignatures.length; _a++) { var s = sourceSignatures[_a]; - if (!s.hasStringLiterals || source.flags & 131072) { + if (!s.hasStringLiterals || source.flags & 262144) { var related = signatureRelatedTo(s, t, localErrors); if (related) { result &= related; @@ -13676,12 +14268,12 @@ var ts; } } function isDeeplyNestedGeneric(type, stack, depth) { - if (type.flags & (4096 | 65536) && depth >= 5) { + if (type.flags & (4096 | 131072) && depth >= 5) { var symbol = type.symbol; var count = 0; for (var i = 0; i < depth; i++) { var t = stack[i]; - if (t.flags & (4096 | 65536) && t.symbol === symbol) { + if (t.flags & (4096 | 131072) && t.symbol === symbol) { count++; if (count >= 5) return true; @@ -13832,11 +14424,11 @@ var ts; return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); } function getWidenedType(type) { - if (type.flags & 1572864) { + if (type.flags & 3145728) { if (type.flags & (32 | 64)) { return anyType; } - if (type.flags & 262144) { + if (type.flags & 524288) { return getWidenedTypeOfObjectLiteral(type); } if (type.flags & 16384) { @@ -13861,11 +14453,11 @@ var ts; if (isArrayType(type)) { return reportWideningErrorsInType(type.typeArguments[0]); } - if (type.flags & 262144) { + if (type.flags & 524288) { var errorReported = false; ts.forEach(getPropertiesOfObjectType(type), function (p) { var t = getTypeOfSymbol(p); - if (t.flags & 524288) { + if (t.flags & 1048576) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); } @@ -13880,22 +14472,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 134: - case 133: + case 138: + case 137: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 131: + case 135: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 203: - case 136: - case 135: - case 138: + case 210: + case 140: case 139: - case 165: - case 166: + case 142: + case 143: + case 170: + case 171: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -13908,7 +14500,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 524288) { + if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 1048576) { if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); } @@ -13995,7 +14587,7 @@ var ts; inferFromTypes(sourceTypes[i], targetTypes[i]); } } - else if (target.flags & 16384) { + else if (target.flags & 49152) { var targetTypes = target.types; var typeParameterCount = 0; var typeParameter; @@ -14009,21 +14601,21 @@ var ts; inferFromTypes(source, t); } } - if (typeParameterCount === 1) { + if (target.flags & 16384 && typeParameterCount === 1) { inferiority++; inferFromTypes(source, typeParameter); inferiority--; } } - else if (source.flags & 16384) { + else if (source.flags & 49152) { var sourceTypes = source.types; for (var _a = 0; _a < sourceTypes.length; _a++) { var sourceType = sourceTypes[_a]; inferFromTypes(sourceType, target); } } - else if (source.flags & 48128 && (target.flags & (4096 | 8192) || - (target.flags & 32768) && target.symbol && target.symbol.flags & (8192 | 2048))) { + else if (source.flags & 80896 && (target.flags & (4096 | 8192) || + (target.flags & 65536) && target.symbol && target.symbol.flags & (8192 | 2048 | 32))) { if (isInProcess(source, target)) { return; } @@ -14135,10 +14727,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 147: + case 151: return true; - case 65: - case 128: + case 66: + case 132: node = node.parent; continue; default: @@ -14178,12 +14770,12 @@ var ts; } return links.assignmentChecks[symbol.id] = isAssignedIn(node); function isAssignedInBinaryExpression(node) { - if (node.operatorToken.kind >= 53 && node.operatorToken.kind <= 64) { + if (node.operatorToken.kind >= 54 && node.operatorToken.kind <= 65) { var n = node.left; - while (n.kind === 164) { + while (n.kind === 169) { n = n.expression; } - if (n.kind === 65 && getResolvedSymbol(n) === symbol) { + if (n.kind === 66 && getResolvedSymbol(n) === symbol) { return true; } } @@ -14197,46 +14789,55 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 172: + case 178: return isAssignedInBinaryExpression(node); - case 201: - case 155: + case 208: + case 160: return isAssignedInVariableDeclaration(node); - case 153: - case 154: - case 156: - case 157: case 158: case 159: - case 160: case 161: + case 162: case 163: case 164: - case 170: - case 167: + case 165: + case 166: case 168: - case 169: - case 171: - case 173: - case 176: - case 182: - case 183: - case 185: case 186: - case 187: - case 188: + case 169: + case 176: + case 172: + case 175: + case 173: + case 174: + case 177: + case 181: + case 179: + case 182: case 189: case 190: - case 191: + case 192: + case 193: case 194: case 195: case 196: - case 223: - case 224: case 197: case 198: - case 199: - case 226: + case 201: + case 202: + case 203: + case 238: + case 239: + case 204: + case 205: + case 206: + case 241: + case 230: + case 231: + case 235: + case 236: + case 232: + case 237: return ts.forEachChild(node, isAssignedIn); } return false; @@ -14267,40 +14868,40 @@ var ts; function getNarrowedTypeOfSymbol(symbol, node) { var type = getTypeOfSymbol(symbol); if (node && symbol.flags & 3) { - if (isTypeAny(type) || type.flags & (48128 | 16384 | 512)) { + if (isTypeAny(type) || type.flags & (80896 | 16384 | 512)) { loop: while (node.parent) { var child = node; node = node.parent; var narrowedType = type; switch (node.kind) { - case 186: + case 193: if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 173: + case 179: if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 172: + case 178: if (child === node.right) { - if (node.operatorToken.kind === 48) { + if (node.operatorToken.kind === 49) { narrowedType = narrowType(type, node.left, true); } - else if (node.operatorToken.kind === 49) { + else if (node.operatorToken.kind === 50) { narrowedType = narrowType(type, node.left, false); } } break; - case 230: - case 208: - case 203: - case 136: - case 135: - case 138: + case 245: + case 215: + case 210: + case 140: case 139: - case 137: + case 142: + case 143: + case 141: break loop; } if (narrowedType !== type) { @@ -14314,21 +14915,21 @@ var ts; } return type; function narrowTypeByEquality(type, expr, assumeTrue) { - if (expr.left.kind !== 168 || expr.right.kind !== 8) { + if (expr.left.kind !== 173 || expr.right.kind !== 8) { return type; } var left = expr.left; var right = expr.right; - if (left.expression.kind !== 65 || getResolvedSymbol(left.expression) !== symbol) { + if (left.expression.kind !== 66 || getResolvedSymbol(left.expression) !== symbol) { return type; } var typeInfo = primitiveTypeInfo[right.text]; - if (expr.operatorToken.kind === 31) { + if (expr.operatorToken.kind === 32) { assumeTrue = !assumeTrue; } if (assumeTrue) { if (!typeInfo) { - return removeTypesFromUnionType(type, 258 | 132 | 8 | 2097152, true, false); + return removeTypesFromUnionType(type, 258 | 132 | 8 | 4194304, true, false); } if (isTypeSubtypeOf(typeInfo.type, type)) { return typeInfo.type; @@ -14365,7 +14966,7 @@ var ts; } } function narrowTypeByInstanceof(type, expr, assumeTrue) { - if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 65 || getResolvedSymbol(expr.left) !== symbol) { + if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 66 || getResolvedSymbol(expr.left) !== symbol) { return type; } var rightType = checkExpression(expr.right); @@ -14385,7 +14986,7 @@ var ts; if (rightType.flags & 2048) { constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures; } - else if (rightType.flags & 32768) { + else if (rightType.flags & 65536) { constructSignatures = getSignaturesOfType(rightType, 1); } if (constructSignatures && constructSignatures.length) { @@ -14426,27 +15027,27 @@ var ts; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 160: + case 165: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 164: + case 169: return narrowType(type, expr.expression, assumeTrue); - case 172: + case 178: var operator = expr.operatorToken.kind; - if (operator === 30 || operator === 31) { + if (operator === 31 || operator === 32) { return narrowTypeByEquality(type, expr, assumeTrue); } - else if (operator === 48) { + else if (operator === 49) { return narrowTypeByAnd(type, expr, assumeTrue); } - else if (operator === 49) { + else if (operator === 50) { return narrowTypeByOr(type, expr, assumeTrue); } - else if (operator === 87) { + else if (operator === 88) { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 170: - if (expr.operator === 46) { + case 176: + if (expr.operator === 47) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -14456,8 +15057,17 @@ var ts; } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); - if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 166 && languageVersion < 2) { - error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); + if (symbol === argumentsSymbol) { + var container = ts.getContainingFunction(node); + if (container.kind === 171) { + 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); + } + } + if (node.parserContextFlags & 8) { + getNodeLinks(container).flags |= 4096; + getNodeLinks(node).flags |= 2048; + } } if (symbol.flags & 8388608 && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { markAliasSymbolAsReferenced(symbol); @@ -14480,15 +15090,15 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 || (symbol.flags & 2) === 0 || - symbol.valueDeclaration.parent.kind === 226) { + symbol.valueDeclaration.parent.kind === 241) { return; } var container = symbol.valueDeclaration; - while (container.kind !== 202) { + while (container.kind !== 209) { container = container.parent; } container = container.parent; - if (container.kind === 183) { + if (container.kind === 190) { container = container.parent; } var inFunction = isInsideFunction(node.parent, container); @@ -14498,7 +15108,7 @@ var ts; if (inFunction) { grammarErrorOnFirstToken(current, ts.Diagnostics.Loop_contains_block_scoped_variable_0_referenced_by_a_function_in_the_loop_This_is_only_supported_in_ECMAScript_6_or_higher, ts.declarationNameToString(node)); } - getNodeLinks(symbol.valueDeclaration).flags |= 256; + getNodeLinks(symbol.valueDeclaration).flags |= 16384; break; } current = current.parent; @@ -14506,7 +15116,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 134 || container.kind === 137) { + if (container.kind === 138 || container.kind === 141) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -14517,29 +15127,29 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 166) { + if (container.kind === 171) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 208: + case 215: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 207: + case 214: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 137: + case 141: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 134: - case 133: + case 138: + case 137: if (container.flags & 128) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 129: + case 133: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -14554,14 +15164,14 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 131) { + if (n.kind === 135) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 160 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 165 && node.parent.expression === node; var classDeclaration = ts.getContainingClass(node); var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); var baseClassType = classType && getBaseTypes(classType)[0]; @@ -14576,45 +15186,45 @@ var ts; var canUseSuperExpression = false; var needToCaptureLexicalThis; if (isCallExpression) { - canUseSuperExpression = container.kind === 137; + canUseSuperExpression = container.kind === 141; } else { needToCaptureLexicalThis = false; - while (container && container.kind === 166) { + while (container && container.kind === 171) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } if (container && ts.isClassLike(container.parent)) { if (container.flags & 128) { canUseSuperExpression = - container.kind === 136 || - container.kind === 135 || - container.kind === 138 || - container.kind === 139; + container.kind === 140 || + container.kind === 139 || + container.kind === 142 || + container.kind === 143; } else { canUseSuperExpression = - container.kind === 136 || - container.kind === 135 || - container.kind === 138 || + container.kind === 140 || container.kind === 139 || - container.kind === 134 || - container.kind === 133 || - container.kind === 137; + container.kind === 142 || + container.kind === 143 || + container.kind === 138 || + container.kind === 137 || + container.kind === 141; } } } if (canUseSuperExpression) { var returnType; if ((container.flags & 128) || isCallExpression) { - getNodeLinks(node).flags |= 32; + getNodeLinks(node).flags |= 512; returnType = getBaseConstructorTypeOfClass(classType); } else { - getNodeLinks(node).flags |= 16; + getNodeLinks(node).flags |= 256; returnType = baseClassType; } - if (container.kind === 137 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 141 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); returnType = unknownType; } @@ -14624,7 +15234,7 @@ var ts; return returnType; } } - if (container && container.kind === 129) { + if (container && container.kind === 133) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { @@ -14662,7 +15272,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 131) { + if (declaration.kind === 135) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -14693,10 +15303,19 @@ var ts; } return undefined; } + function isInParameterInitializerBeforeContainingFunction(node) { + while (node.parent && !ts.isFunctionLike(node.parent)) { + if (node.parent.kind === 135 && node.parent.initializer === node) { + return true; + } + node = node.parent; + } + return false; + } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 137 || - functionDecl.kind === 138 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 139))) { + functionDecl.kind === 141 || + functionDecl.kind === 142 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 143))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -14715,7 +15334,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 162) { + if (template.parent.kind === 167) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -14723,12 +15342,12 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 53 && operator <= 64) { + if (operator >= 54 && operator <= 65) { if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); } } - else if (operator === 49) { + else if (operator === 50) { var type = getContextualType(binaryExpression); if (!type && node === binaryExpression.right) { type = checkExpression(binaryExpression.left); @@ -14763,18 +15382,18 @@ var ts; } function getTypeOfPropertyOfContextualType(type, name) { return applyToContextualType(type, function (t) { - var prop = getPropertyOfObjectType(t, name); + var prop = t.flags & 130048 ? getPropertyOfType(t, name) : undefined; return prop ? getTypeOfSymbol(prop) : undefined; }); } function getIndexTypeOfContextualType(type, kind) { - return applyToContextualType(type, function (t) { return getIndexTypeOfObjectOrUnionType(t, kind); }); + return applyToContextualType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }); } function contextualTypeIsTupleLikeType(type) { return !!(type.flags & 16384 ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); } function contextualTypeHasIndexSignature(type, kind) { - return !!(type.flags & 16384 ? ts.forEach(type.types, function (t) { return getIndexTypeOfObjectOrUnionType(t, kind); }) : getIndexTypeOfObjectOrUnionType(type, kind)); + return !!(type.flags & 16384 ? ts.forEach(type.types, function (t) { return getIndexTypeOfStructuredType(t, kind); }) : getIndexTypeOfStructuredType(type, kind)); } function getContextualTypeForObjectLiteralMethod(node) { ts.Debug.assert(ts.isObjectLiteralMethod(node)); @@ -14814,7 +15433,27 @@ var ts; var conditional = node.parent; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } + function getContextualTypeForJsxExpression(expr) { + if (expr.parent.kind === 235) { + var attrib = expr.parent; + var attrsType = getJsxElementAttributesType(attrib.parent); + if (!attrsType || isTypeAny(attrsType)) { + return undefined; + } + else { + return getTypeOfPropertyOfType(attrsType, attrib.name.text); + } + } + if (expr.kind === 236) { + return getJsxElementAttributesType(expr.parent); + } + return undefined; + } function getContextualType(node) { + var type = getContextualTypeWorker(node); + return type && getApparentType(type); + } + function getContextualTypeWorker(node) { if (isInsideWithStatementBody(node)) { return undefined; } @@ -14823,40 +15462,44 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 201: - case 131: - case 134: - case 133: - case 155: - return getContextualTypeForInitializerExpression(node); - case 166: - case 194: - return getContextualTypeForReturnExpression(node); - case 175: - return getContextualTypeForYieldOperand(parent); + case 208: + case 135: + case 138: + case 137: case 160: - case 161: + return getContextualTypeForInitializerExpression(node); + case 171: + case 201: + return getContextualTypeForReturnExpression(node); + case 181: + return getContextualTypeForYieldOperand(parent); + case 165: + case 166: return getContextualTypeForArgument(parent, node); - case 163: + case 168: + case 186: return getTypeFromTypeNode(parent.type); - case 172: + case 178: return getContextualTypeForBinaryOperand(node); - case 227: + case 242: return getContextualTypeForObjectLiteralElement(parent); - case 156: + case 161: return getContextualTypeForElementExpression(node); - case 173: + case 179: return getContextualTypeForConditionalOperand(node); - case 180: - ts.Debug.assert(parent.parent.kind === 174); + case 187: + ts.Debug.assert(parent.parent.kind === 180); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 164: + case 169: return getContextualType(parent); + case 237: + case 236: + return getContextualTypeForJsxExpression(parent); } return undefined; } function getNonGenericSignature(type) { - var signatures = getSignaturesOfObjectOrUnionType(type, 0); + var signatures = getSignaturesOfStructuredType(type, 0); if (signatures.length === 1) { var signature = signatures[0]; if (!signature.typeParameters) { @@ -14865,7 +15508,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 165 || node.kind === 166; + return node.kind === 170 || node.kind === 171; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -14873,7 +15516,7 @@ var ts; : undefined; } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 136 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 140 || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -14888,7 +15531,7 @@ var ts; for (var _i = 0; _i < types.length; _i++) { var current = types[_i]; if (signatureList && - getSignaturesOfObjectOrUnionType(current, 0).length > 1) { + getSignaturesOfStructuredType(current, 0).length > 1) { return undefined; } var signature = getNonGenericSignature(current); @@ -14917,13 +15560,13 @@ var ts; } function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 172 && parent.operatorToken.kind === 53 && parent.left === node) { + if (parent.kind === 178 && parent.operatorToken.kind === 54 && parent.left === node) { return true; } - if (parent.kind === 227) { + if (parent.kind === 242) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 156) { + if (parent.kind === 161) { return isAssignmentTarget(parent); } return false; @@ -14942,7 +15585,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 176) { + if (inDestructuringPattern && e.kind === 182) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -14954,7 +15597,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 176; + hasSpreadElement = hasSpreadElement || e.kind === 182; } if (!hasSpreadElement) { var contextualType = getContextualType(node); @@ -14965,7 +15608,7 @@ var ts; return createArrayType(getUnionType(elementTypes)); } function isNumericName(name) { - return name.kind === 129 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 133 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 132); @@ -14980,7 +15623,7 @@ var ts; var links = getNodeLinks(node.expression); if (!links.resolvedType) { links.resolvedType = checkExpression(node.expression); - if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 | 258 | 2097152)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 | 258 | 4194304)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } else { @@ -14998,18 +15641,18 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 227 || - memberDecl.kind === 228 || + if (memberDecl.kind === 242 || + memberDecl.kind === 243 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 227) { + if (memberDecl.kind === 242) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 136) { + else if (memberDecl.kind === 140) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 228); + ts.Debug.assert(memberDecl.kind === 243); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -15024,7 +15667,7 @@ var ts; member = prop; } else { - ts.Debug.assert(memberDecl.kind === 138 || memberDecl.kind === 139); + ts.Debug.assert(memberDecl.kind === 142 || memberDecl.kind === 143); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -15035,7 +15678,7 @@ var ts; var stringIndexType = getIndexType(0); var numberIndexType = getIndexType(1); var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); - result.flags |= 262144 | 1048576 | (typeFlags & 524288); + result.flags |= 524288 | 2097152 | (typeFlags & 1048576); return result; function getIndexType(kind) { if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { @@ -15056,39 +15699,367 @@ var ts; return undefined; } } + function checkJsxSelfClosingElement(node) { + checkJsxOpeningLikeElement(node); + return jsxElementType || anyType; + } + function tagNamesAreEquivalent(lhs, rhs) { + if (lhs.kind !== rhs.kind) { + return false; + } + if (lhs.kind === 66) { + return lhs.text === rhs.text; + } + return lhs.right.text === rhs.right.text && + tagNamesAreEquivalent(lhs.left, rhs.left); + } + function checkJsxElement(node) { + if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) { + error(node.closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNode(node.openingElement.tagName)); + } + checkJsxOpeningLikeElement(node.openingElement); + for (var _i = 0, _a = node.children; _i < _a.length; _i++) { + var child = _a[_i]; + switch (child.kind) { + case 237: + checkJsxExpression(child); + break; + case 230: + checkJsxElement(child); + break; + case 231: + checkJsxSelfClosingElement(child); + break; + default: + ts.Debug.assert(child.kind === 233); + } + } + return jsxElementType || anyType; + } + function isUnhyphenatedJsxName(name) { + return name.indexOf("-") < 0; + } + function isJsxIntrinsicIdentifier(tagName) { + if (tagName.kind === 132) { + return false; + } + else { + return ts.isIntrinsicJsxName(tagName.text); + } + } + function checkJsxAttribute(node, elementAttributesType, nameTable) { + var correspondingPropType = undefined; + if (elementAttributesType === emptyObjectType && isUnhyphenatedJsxName(node.name.text)) { + error(node.parent, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, getJsxElementPropertiesName()); + } + else if (elementAttributesType && !isTypeAny(elementAttributesType)) { + var correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); + correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); + if (!correspondingPropType && isUnhyphenatedJsxName(node.name.text)) { + error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); + return unknownType; + } + } + var exprType; + if (node.initializer) { + exprType = checkExpression(node.initializer); + } + else { + exprType = booleanType; + } + if (correspondingPropType) { + checkTypeAssignableTo(exprType, correspondingPropType, node); + } + nameTable[node.name.text] = true; + return exprType; + } + function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { + var type = checkExpression(node.expression); + var props = getPropertiesOfType(type); + for (var _i = 0; _i < props.length; _i++) { + var prop = props[_i]; + if (!nameTable[prop.name]) { + var targetPropSym = getPropertyOfType(elementAttributesType, prop.name); + if (targetPropSym) { + var msg = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property, prop.name); + checkTypeAssignableTo(getTypeOfSymbol(prop), getTypeOfSymbol(targetPropSym), node, undefined, msg); + } + nameTable[prop.name] = true; + } + } + return type; + } + function getJsxIntrinsicElementsType() { + if (!jsxIntrinsicElementsType) { + jsxIntrinsicElementsType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.IntrinsicElements) || unknownType; + } + return jsxIntrinsicElementsType; + } + function getJsxElementTagSymbol(node) { + var flags = 8; + var links = getNodeLinks(node); + if (!links.resolvedSymbol) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + links.resolvedSymbol = lookupIntrinsicTag(node); + } + else { + links.resolvedSymbol = lookupClassTag(node); + } + } + return links.resolvedSymbol; + function lookupIntrinsicTag(node) { + var intrinsicElementsType = getJsxIntrinsicElementsType(); + if (intrinsicElementsType !== unknownType) { + var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.text); + if (intrinsicProp) { + links.jsxFlags |= 1; + return intrinsicProp; + } + var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0); + if (indexSignatureType) { + links.jsxFlags |= 2; + return intrinsicElementsType.symbol; + } + error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, 'JSX.' + JsxNames.IntrinsicElements); + return unknownSymbol; + } + else { + if (compilerOptions.noImplicitAny) { + error(node, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, JsxNames.IntrinsicElements); + } + } + } + function lookupClassTag(node) { + var valueSymbol; + if (node.tagName.kind === 66) { + var tag = node.tagName; + var sym = getResolvedSymbol(tag); + valueSymbol = sym.exportSymbol || sym; + } + else { + valueSymbol = checkQualifiedName(node.tagName).symbol; + } + if (valueSymbol && valueSymbol !== unknownSymbol) { + links.jsxFlags |= 4; + getSymbolLinks(valueSymbol).referenced = true; + } + return valueSymbol || unknownSymbol; + } + } + function getJsxElementInstanceType(node) { + if (!(getNodeLinks(node).jsxFlags & 4)) { + return undefined; + } + var classSymbol = getJsxElementTagSymbol(node); + if (classSymbol === unknownSymbol) { + return anyType; + } + var valueType = getTypeOfSymbol(classSymbol); + if (isTypeAny(valueType)) { + return anyType; + } + var signatures = getSignaturesOfType(valueType, 1); + if (signatures.length === 0) { + signatures = getSignaturesOfType(valueType, 0); + if (signatures.length === 0) { + error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); + return undefined; + } + } + var returnType = getUnionType(signatures.map(function (s) { return getReturnTypeOfSignature(s); })); + if (!isTypeAny(returnType) && !(returnType.flags & 80896)) { + error(node.tagName, ts.Diagnostics.The_return_type_of_a_JSX_element_constructor_must_return_an_object_type); + return undefined; + } + var elemClassType = getJsxGlobalElementClassType(); + if (elemClassType) { + checkTypeRelatedTo(returnType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + } + return returnType; + } + function getJsxElementPropertiesName() { + var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1536, undefined); + var attribsPropTypeSym = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.ElementAttributesPropertyNameContainer, 793056); + var attribPropType = attribsPropTypeSym && getDeclaredTypeOfSymbol(attribsPropTypeSym); + var attribProperties = attribPropType && getPropertiesOfType(attribPropType); + if (attribProperties) { + if (attribProperties.length === 0) { + return ""; + } + else if (attribProperties.length === 1) { + return attribProperties[0].name; + } + else { + error(attribsPropTypeSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, JsxNames.ElementAttributesPropertyNameContainer); + return undefined; + } + } + else { + return undefined; + } + } + function getJsxElementAttributesType(node) { + var links = getNodeLinks(node); + if (!links.resolvedJsxType) { + var sym = getJsxElementTagSymbol(node); + if (links.jsxFlags & 4) { + var elemInstanceType = getJsxElementInstanceType(node); + if (isTypeAny(elemInstanceType)) { + return links.resolvedJsxType = anyType; + } + var propsName = getJsxElementPropertiesName(); + if (propsName === undefined) { + return links.resolvedJsxType = anyType; + } + else if (propsName === "") { + return links.resolvedJsxType = elemInstanceType; + } + else { + var attributesType = getTypeOfPropertyOfType(elemInstanceType, propsName); + if (!attributesType) { + return links.resolvedJsxType = emptyObjectType; + } + else if (isTypeAny(attributesType) || (attributesType === unknownType)) { + return links.resolvedJsxType = attributesType; + } + else if (!(attributesType.flags & 80896)) { + error(node.tagName, ts.Diagnostics.JSX_element_attributes_type_0_must_be_an_object_type, typeToString(attributesType)); + return links.resolvedJsxType = anyType; + } + else { + return links.resolvedJsxType = attributesType; + } + } + } + else if (links.jsxFlags & 1) { + return links.resolvedJsxType = getTypeOfSymbol(sym); + } + else if (links.jsxFlags & 2) { + return links.resolvedJsxType = getIndexTypeOfSymbol(sym, 0); + } + else { + return links.resolvedJsxType = anyType; + } + } + return links.resolvedJsxType; + } + function getJsxAttributePropertySymbol(attrib) { + var attributesType = getJsxElementAttributesType(attrib.parent); + var prop = getPropertyOfType(attributesType, attrib.name.text); + return prop || unknownSymbol; + } + var jsxElementClassType = undefined; + function getJsxGlobalElementClassType() { + if (!jsxElementClassType) { + jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); + } + return jsxElementClassType; + } + function getJsxIntrinsicTagNames() { + var intrinsics = getJsxIntrinsicElementsType(); + return intrinsics ? getPropertiesOfType(intrinsics) : emptyArray; + } + function checkJsxPreconditions(errorNode) { + if ((compilerOptions.jsx || 0) === 0) { + error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided); + } + if (jsxElementType === undefined) { + if (compilerOptions.noImplicitAny) { + error(errorNode, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist); + } + } + } + function checkJsxOpeningLikeElement(node) { + checkGrammarJsxElement(node); + checkJsxPreconditions(node); + if (compilerOptions.jsx === 2) { + var reactSym = resolveName(node.tagName, 'React', 107455, ts.Diagnostics.Cannot_find_name_0, 'React'); + if (reactSym) { + getSymbolLinks(reactSym).referenced = true; + } + } + var targetAttributesType = getJsxElementAttributesType(node); + var nameTable = {}; + var sawSpreadedAny = false; + for (var i = node.attributes.length - 1; i >= 0; i--) { + if (node.attributes[i].kind === 235) { + checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); + } + else { + ts.Debug.assert(node.attributes[i].kind === 236); + var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); + if (isTypeAny(spreadType)) { + sawSpreadedAny = true; + } + } + } + if (targetAttributesType && !sawSpreadedAny) { + var targetProperties = getPropertiesOfType(targetAttributesType); + for (var i = 0; i < targetProperties.length; i++) { + if (!(targetProperties[i].flags & 536870912) && + nameTable[targetProperties[i].name] === undefined) { + error(node, ts.Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType)); + } + } + } + } + function checkJsxExpression(node) { + if (node.expression) { + return checkExpression(node.expression); + } + else { + return unknownType; + } + } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 134; + return s.valueDeclaration ? s.valueDeclaration.kind : 138; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 16 | 128 : 0; } function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); + var declaringClass = getDeclaredTypeOfSymbol(prop.parent); + if (left.kind === 92) { + var errorNode = node.kind === 163 ? + node.name : + node.right; + if (getDeclarationKindFromSymbol(prop) !== 140) { + error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + return false; + } + if (flags & 256) { + error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(declaringClass)); + return false; + } + } if (!(flags & (32 | 64))) { - return; + return true; } var enclosingClassDeclaration = ts.getContainingClass(node); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; - var declaringClass = getDeclaredTypeOfSymbol(prop.parent); if (flags & 32) { if (declaringClass !== enclosingClass) { error(node, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); + return false; } - return; + return true; } - if (left.kind === 91) { - return; + if (left.kind === 92) { + return true; } if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass)); - return; + return false; } if (flags & 128) { - return; + return true; } 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; } + return true; } function checkPropertyAccessExpression(node) { return checkPropertyAccessExpressionOrQualifiedName(node, node.expression, node.name); @@ -15114,31 +16085,19 @@ var ts; } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32) { - if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 136) { - error(right, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); - } - else { - checkClassPropertyAccess(node, left, type, prop); - } + checkClassPropertyAccess(node, left, type, prop); } return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 158 + var left = node.kind === 163 ? node.expression : node.left; var type = checkExpression(left); if (type !== unknownType && !isTypeAny(type)) { var prop = getPropertyOfType(getWidenedType(type), propertyName); if (prop && prop.parent && prop.parent.flags & 32) { - if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 136) { - return false; - } - else { - var modificationCount = diagnostics.getModificationCount(); - checkClassPropertyAccess(node, left, type, prop); - return diagnostics.getModificationCount() === modificationCount; - } + return checkClassPropertyAccess(node, left, type, prop); } } return true; @@ -15146,7 +16105,7 @@ var ts; function checkIndexedAccess(node) { if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 161 && node.parent.expression === node) { + if (node.parent.kind === 166 && 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); @@ -15169,20 +16128,20 @@ var ts; return unknownType; } if (node.argumentExpression) { - var name_10 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); - if (name_10 !== undefined) { - var prop = getPropertyOfType(objectType, name_10); + var name_11 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); + if (name_11 !== undefined) { + var prop = getPropertyOfType(objectType, name_11); if (prop) { getNodeLinks(node).resolvedSymbol = prop; return getTypeOfSymbol(prop); } else if (isConstEnum) { - error(node.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_const_enum_1, name_10, symbolToString(objectType.symbol)); + error(node.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_const_enum_1, name_11, symbolToString(objectType.symbol)); return unknownType; } } } - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 | 132 | 2097152)) { + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 | 132 | 4194304)) { if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132)) { var numberIndexType = getIndexTypeOfType(objectType, 1); if (numberIndexType) { @@ -15218,7 +16177,7 @@ var ts; if (!ts.isWellKnownSymbolSyntactically(expression)) { return false; } - if ((expressionType.flags & 2097152) === 0) { + if ((expressionType.flags & 4194304) === 0) { if (reportError) { error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); } @@ -15242,10 +16201,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 162) { + if (node.kind === 167) { checkExpression(node.template); } - else if (node.kind !== 132) { + else if (node.kind !== 136) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -15296,7 +16255,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 176) { + if (arg && arg.kind === 182) { return i; } } @@ -15308,11 +16267,11 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 162) { + if (node.kind === 167) { var tagExpression = node; adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 174) { + if (tagExpression.template.kind === 180) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -15324,7 +16283,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 132) { + else if (node.kind === 136) { isDecorator = true; typeArguments = undefined; adjustedArgCount = getEffectiveArgumentCount(node, undefined, signature); @@ -15332,7 +16291,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 161); + ts.Debug.assert(callExpression.kind === 166); return signature.minArgumentCount === 0; } adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; @@ -15355,8 +16314,8 @@ var ts; return callIsIncomplete || hasEnoughArguments; } function getSingleCallSignature(type) { - if (type.flags & 48128) { - var resolved = resolveObjectOrUnionTypeMembers(type); + if (type.flags & 80896) { + var resolved = resolveStructuredTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && resolved.properties.length === 0 && !resolved.stringIndexType && !resolved.numberIndexType) { return resolved.callSignatures[0]; @@ -15385,7 +16344,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 !== 178) { + if (arg === undefined || arg.kind !== 184) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { @@ -15432,7 +16391,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 !== 178) { + if (arg === undefined || arg.kind !== 184) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { @@ -15451,16 +16410,16 @@ var ts; } function getEffectiveCallArguments(node) { var args; - if (node.kind === 162) { + if (node.kind === 167) { var template = node.template; args = [undefined]; - if (template.kind === 174) { + if (template.kind === 180) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 132) { + else if (node.kind === 136) { return undefined; } else { @@ -15469,18 +16428,18 @@ var ts; return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 132) { + if (node.kind === 136) { switch (node.parent.kind) { - case 204: - case 177: + case 211: + case 183: return 1; - case 134: - return 2; - case 136: case 138: - case 139: + return 2; + case 140: + case 142: + case 143: return signature.parameters.length >= 3 ? 3 : 2; - case 131: + case 135: return 3; } } @@ -15490,20 +16449,20 @@ var ts; } function getEffectiveDecoratorFirstArgumentType(node) { switch (node.kind) { - case 204: - case 177: + case 211: + case 183: var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); - case 131: + case 135: node = node.parent; - if (node.kind === 137) { + if (node.kind === 141) { var classSymbol_1 = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol_1); } - case 134: - case 136: case 138: - case 139: + case 140: + case 142: + case 143: return getParentTypeOfClassElement(node); default: ts.Debug.fail("Unsupported decorator target."); @@ -15512,27 +16471,27 @@ var ts; } function getEffectiveDecoratorSecondArgumentType(node) { switch (node.kind) { - case 204: + case 211: ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; - case 131: + case 135: node = node.parent; - if (node.kind === 137) { + if (node.kind === 141) { return anyType; } - case 134: - case 136: case 138: - case 139: + case 140: + case 142: + case 143: var element = node; switch (element.name.kind) { - case 65: + case 66: case 7: case 8: return getStringLiteralType(element.name); - case 129: + case 133: var nameType = checkComputedPropertyName(element.name); - if (allConstituentTypesHaveKind(nameType, 2097152)) { + if (allConstituentTypesHaveKind(nameType, 4194304)) { return nameType; } else { @@ -15549,17 +16508,17 @@ var ts; } function getEffectiveDecoratorThirdArgumentType(node) { switch (node.kind) { - case 204: + case 211: ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; - case 131: + case 135: return numberType; - case 134: + case 138: ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; - case 136: - case 138: - case 139: + case 140: + case 142: + case 143: var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); default: @@ -15581,26 +16540,26 @@ var ts; return unknownType; } function getEffectiveArgumentType(node, argIndex, arg) { - if (node.kind === 132) { + if (node.kind === 136) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 162) { + else if (argIndex === 0 && node.kind === 167) { return globalTemplateStringsArrayType; } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 132 || - (argIndex === 0 && node.kind === 162)) { + if (node.kind === 136 || + (argIndex === 0 && node.kind === 167)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 132) { + if (node.kind === 136) { return node.expression; } - else if (argIndex === 0 && node.kind === 162) { + else if (argIndex === 0 && node.kind === 167) { return node.template; } else { @@ -15608,12 +16567,12 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 162; - var isDecorator = node.kind === 132; + var isTaggedTemplate = node.kind === 167; + var isDecorator = node.kind === 136; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; - if (node.expression.kind !== 91) { + if (node.expression.kind !== 92) { ts.forEach(typeArguments, checkSourceElement); } } @@ -15748,7 +16707,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 91) { + if (node.expression.kind === 92) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); @@ -15793,6 +16752,11 @@ var ts; if (expressionType === unknownType) { return resolveErrorCall(node); } + var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 211); + 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); + } if (isTypeAny(expressionType)) { if (node.typeArguments) { error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); @@ -15832,16 +16796,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 204: - case 177: + case 211: + case 183: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 131: + case 135: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 134: - return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 136: case 138: - case 139: + return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; + case 140: + case 142: + case 143: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -15869,16 +16833,16 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 160) { + if (node.kind === 165) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 161) { + else if (node.kind === 166) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 162) { + else if (node.kind === 167) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } - else if (node.kind === 132) { + else if (node.kind === 136) { links.resolvedSignature = resolveDecorator(node, candidatesOutArray); } else { @@ -15890,15 +16854,15 @@ var ts; function checkCallExpression(node) { checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 91) { + if (node.expression.kind === 92) { return voidType; } - if (node.kind === 161) { + if (node.kind === 166) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 137 && declaration.kind !== 141 && - declaration.kind !== 146) { + declaration.kind !== 145 && + declaration.kind !== 150) { if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } @@ -15910,7 +16874,7 @@ var ts; function checkTaggedTemplateExpression(node) { return getReturnTypeOfSignature(getResolvedSignature(node)); } - function checkTypeAssertion(node) { + function checkAssertion(node) { var exprType = checkExpression(node.expression); var targetType = getTypeFromTypeNode(node.type); if (produceDiagnostics && targetType !== unknownType) { @@ -15939,14 +16903,26 @@ var ts; links.type = instantiateType(getTypeOfSymbol(ts.lastOrUndefined(context.parameters)), mapper); } } + function createPromiseType(promisedType) { + var globalPromiseType = getGlobalPromiseType(); + if (globalPromiseType !== emptyObjectType) { + promisedType = getAwaitedType(promisedType); + return createTypeReference(globalPromiseType, [promisedType]); + } + return emptyObjectType; + } function getReturnTypeFromBody(func, contextualMapper) { var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); if (!func.body) { return unknownType; } + var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 182) { + if (func.body.kind !== 189) { 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); + } } else { var types; @@ -15962,9 +16938,19 @@ var ts; } } else { - types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper); + types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper, isAsync); if (types.length === 0) { - return voidType; + if (isAsync) { + var promiseType = createPromiseType(voidType); + if (promiseType === emptyObjectType) { + error(func, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return unknownType; + } + return promiseType; + } + else { + return voidType; + } } } type = contextualSignature ? getUnionType(types) : getCommonSupertype(types); @@ -15985,7 +16971,18 @@ var ts; if (!contextualSignature) { reportErrorsFromWidening(func, type); } - return getWidenedType(type); + var widenedType = getWidenedType(type); + if (isAsync) { + var promiseType = createPromiseType(widenedType); + if (promiseType === emptyObjectType) { + error(func, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return unknownType; + } + return promiseType; + } + else { + return widenedType; + } } function checkAndAggregateYieldOperandTypes(body, contextualMapper) { var aggregatedTypes = []; @@ -16003,12 +17000,15 @@ var ts; }); return aggregatedTypes; } - function checkAndAggregateReturnExpressionTypes(body, contextualMapper) { + function checkAndAggregateReturnExpressionTypes(body, contextualMapper, isAsync) { var aggregatedTypes = []; ts.forEachReturnStatement(body, function (returnStatement) { var expr = returnStatement.expression; if (expr) { var type = checkExpressionCached(expr, contextualMapper); + if (isAsync) { + type = checkAwaitedType(type, body.parent, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + } if (!ts.contains(aggregatedTypes, type)) { aggregatedTypes.push(type); } @@ -16022,7 +17022,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 198); + return (body.statements.length === 1) && (body.statements[0].kind === 205); } function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { if (!produceDiagnostics) { @@ -16031,7 +17031,7 @@ var ts; if (returnType === voidType || isTypeAny(returnType)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 182) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 189) { return; } var bodyBlock = func.body; @@ -16044,20 +17044,24 @@ 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 !== 136 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 140 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 165) { + if (!hasGrammarError && node.kind === 170) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { return anyFunctionType; } + var isAsync = ts.isAsyncFunctionLike(node); + if (isAsync) { + emitAwaiter = true; + } var links = getNodeLinks(node); var type = getTypeOfSymbol(node.symbol); - if (!(links.flags & 64)) { + if (!(links.flags & 1024)) { var contextualSignature = getContextualSignature(node); - if (!(links.flags & 64)) { - links.flags |= 64; + if (!(links.flags & 1024)) { + links.flags |= 1024; if (contextualSignature) { var signature = getSignaturesOfType(type, 0)[0]; if (isContextSensitive(node)) { @@ -16073,28 +17077,43 @@ var ts; checkSignatureDeclaration(node); } } - if (produceDiagnostics && node.kind !== 136 && node.kind !== 135) { + if (produceDiagnostics && node.kind !== 140 && node.kind !== 139) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 136 || ts.isObjectLiteralMethod(node)); - if (node.type && !node.asteriskToken) { - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); + ts.Debug.assert(node.kind !== 140 || ts.isObjectLiteralMethod(node)); + var isAsync = ts.isAsyncFunctionLike(node); + if (isAsync) { + emitAwaiter = true; + } + var returnType = node.type && getTypeFromTypeNode(node.type); + var promisedType; + if (returnType && isAsync) { + promisedType = checkAsyncFunctionReturnType(node); + } + if (returnType && !node.asteriskToken) { + checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); } if (node.body) { if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 182) { + if (node.body.kind === 189) { checkSourceElement(node.body); } else { var exprType = checkExpression(node.body); - if (node.type) { - checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), node.body, undefined); + if (returnType) { + if (isAsync) { + var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member); + checkTypeAssignableTo(awaitedType, promisedType, node.body); + } + else { + checkTypeAssignableTo(exprType, returnType, node.body); + } } checkFunctionAndClassExpressionBodies(node.body); } @@ -16114,17 +17133,17 @@ var ts; } function isReferenceOrErrorExpression(n) { switch (n.kind) { - case 65: { + case 66: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3) !== 0; } - case 158: { + case 163: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || (symbol.flags & ~8) !== 0; } - case 159: - return true; case 164: + return true; + case 169: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -16132,22 +17151,22 @@ var ts; } function isConstVariableReference(n) { switch (n.kind) { - case 65: - case 158: { + case 66: + case 163: { var symbol = findSymbol(n); - return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 8192) !== 0; + return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768) !== 0; } - case 159: { + case 164: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); if (symbol && index && index.kind === 8) { - var name_11 = index.text; - var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_11); - return prop && (prop.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 8192) !== 0; + var name_12 = index.text; + var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_12); + return prop && (prop.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 32768) !== 0; } return false; } - case 164: + case 169: return isConstVariableReference(n.expression); default: return false; @@ -16168,27 +17187,39 @@ var ts; return booleanType; } function checkTypeOfExpression(node) { - var operandType = checkExpression(node.expression); + checkExpression(node.expression); return stringType; } function checkVoidExpression(node) { - var operandType = checkExpression(node.expression); + checkExpression(node.expression); return undefinedType; } + function checkAwaitExpression(node) { + if (produceDiagnostics) { + if (!(node.parserContextFlags & 8)) { + grammarErrorOnFirstToken(node, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); + } + if (isInParameterInitializerBeforeContainingFunction(node)) { + error(node, ts.Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer); + } + } + var operandType = checkExpression(node.expression); + return checkAwaitedType(operandType, node); + } function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); switch (node.operator) { - case 33: case 34: - case 47: - if (someConstituentTypeHasKind(operandType, 2097152)) { + case 35: + case 48: + if (someConstituentTypeHasKind(operandType, 4194304)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 46: + case 47: return booleanType; - case 38: case 39: + case 40: 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); @@ -16209,7 +17240,7 @@ var ts; if (type.flags & kind) { return true; } - if (type.flags & 16384) { + if (type.flags & 49152) { var types = type.types; for (var _i = 0; _i < types.length; _i++) { var current = types[_i]; @@ -16225,7 +17256,7 @@ var ts; if (type.flags & kind) { return true; } - if (type.flags & 16384) { + if (type.flags & 49152) { var types = type.types; for (var _i = 0; _i < types.length; _i++) { var current = types[_i]; @@ -16238,13 +17269,13 @@ var ts; return false; } function isConstEnumObjectType(type) { - return type.flags & (48128 | 32768) && type.symbol && isConstEnumSymbol(type.symbol); + return type.flags & (80896 | 65536) && type.symbol && isConstEnumSymbol(type.symbol); } function isConstEnumSymbol(symbol) { return (symbol.flags & 128) !== 0; } function checkInstanceOfExpression(node, leftType, rightType) { - if (allConstituentTypesHaveKind(leftType, 2097662)) { + if (allConstituentTypesHaveKind(leftType, 4194814)) { 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); } if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { @@ -16253,10 +17284,10 @@ var ts; return booleanType; } function checkInExpression(node, leftType, rightType) { - if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 | 132 | 2097152)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 | 132 | 4194304)) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 48128 | 512)) { + 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); } return booleanType; @@ -16265,18 +17296,18 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 227 || p.kind === 228) { - var name_12 = p.name; + if (p.kind === 242 || p.kind === 243) { + var name_13 = p.name; var type = isTypeAny(sourceType) ? sourceType - : getTypeOfPropertyOfType(sourceType, name_12.text) || - isNumericLiteralName(name_12.text) && getIndexTypeOfType(sourceType, 1) || + : getTypeOfPropertyOfType(sourceType, name_13.text) || + isNumericLiteralName(name_13.text) && getIndexTypeOfType(sourceType, 1) || getIndexTypeOfType(sourceType, 0); if (type) { - checkDestructuringAssignment(p.initializer || name_12, type); + checkDestructuringAssignment(p.initializer || name_13, type); } else { - error(name_12, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_12)); + error(name_13, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_13)); } } else { @@ -16290,8 +17321,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 178) { - if (e.kind !== 176) { + if (e.kind !== 184) { + if (e.kind !== 182) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -16316,7 +17347,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 172 && restExpression.operatorToken.kind === 53) { + if (restExpression.kind === 178 && restExpression.operatorToken.kind === 54) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -16329,14 +17360,14 @@ var ts; return sourceType; } function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 172 && target.operatorToken.kind === 53) { + if (target.kind === 178 && target.operatorToken.kind === 54) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 157) { + if (target.kind === 162) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 156) { + if (target.kind === 161) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -16350,32 +17381,32 @@ var ts; } function checkBinaryExpression(node, contextualMapper) { var operator = node.operatorToken.kind; - if (operator === 53 && (node.left.kind === 157 || node.left.kind === 156)) { + if (operator === 54 && (node.left.kind === 162 || node.left.kind === 161)) { return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); } var leftType = checkExpression(node.left, contextualMapper); var rightType = checkExpression(node.right, contextualMapper); switch (operator) { - case 35: - case 56: case 36: case 57: case 37: case 58: - case 34: - case 55: - case 40: + case 38: case 59: + case 35: + case 56: case 41: case 60: case 42: case 61: - case 44: - case 63: - case 45: - case 64: case 43: case 62: + case 45: + case 64: + case 46: + case 65: + case 44: + case 63: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -16394,8 +17425,8 @@ var ts; } } return numberType; - case 33: - case 54: + case 34: + case 55: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -16419,42 +17450,42 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 54) { + if (operator === 55) { checkAssignmentOperator(resultType); } return resultType; case 24: - case 25: case 26: case 27: + case 28: if (!checkForDisallowedESSymbolOperand(operator)) { return booleanType; } - case 28: case 29: case 30: case 31: + case 32: if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { reportOperatorError(); } return booleanType; - case 87: + case 88: return checkInstanceOfExpression(node, leftType, rightType); - case 86: + case 87: return checkInExpression(node, leftType, rightType); - case 48: - return rightType; case 49: + return rightType; + case 50: return getUnionType([leftType, rightType]); - case 53: + case 54: checkAssignmentOperator(rightType); return rightType; case 23: return rightType; } function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 2097152) ? node.left : - someConstituentTypeHasKind(rightType, 2097152) ? node.right : + var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 4194304) ? node.left : + someConstituentTypeHasKind(rightType, 4194304) ? node.right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -16464,21 +17495,21 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { + case 45: + case 64: + return 50; + case 46: + case 65: + return 32; case 44: case 63: return 49; - case 45: - case 64: - return 31; - case 43: - case 62: - return 48; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 53 && operator <= 64) { + if (produceDiagnostics && operator >= 54 && operator <= 65) { 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 (ok) { checkTypeAssignableTo(valueType, leftType, node.left, undefined); @@ -16505,8 +17536,13 @@ var ts; return false; } function checkYieldExpression(node) { - if (!(node.parserContextFlags & 4) || isYieldExpressionInClass(node)) { - grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); + if (produceDiagnostics) { + if (!(node.parserContextFlags & 2) || isYieldExpressionInClass(node)) { + grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); + } + if (isInParameterInitializerBeforeContainingFunction(node)) { + error(node, ts.Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer); + } } if (node.expression) { var func = ts.getContainingFunction(node); @@ -16557,14 +17593,14 @@ var ts; return links.resolvedType; } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 129) { + if (node.name.kind === 133) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 129) { + if (node.name.kind === 133) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -16587,7 +17623,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 128) { + if (node.kind === 132) { type = checkQualifiedName(node); } else { @@ -16595,9 +17631,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 158 && node.parent.expression === node) || - (node.parent.kind === 159 && node.parent.expression === node) || - ((node.kind === 65 || node.kind === 128) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 163 && node.parent.expression === node) || + (node.parent.kind === 164 && node.parent.expression === node) || + ((node.kind === 66 || node.kind === 132) && 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); } @@ -16610,68 +17646,79 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 65: + case 66: return checkIdentifier(node); - case 93: + case 94: return checkThisExpression(node); - case 91: + case 92: return checkSuperExpression(node); - case 89: + case 90: return nullType; - case 95: - case 80: + case 96: + case 81: return booleanType; case 7: return checkNumericLiteral(node); - case 174: + case 180: return checkTemplateExpression(node); case 8: case 10: return stringType; case 9: return globalRegExpType; - case 156: - return checkArrayLiteral(node, contextualMapper); - case 157: - return checkObjectLiteral(node, contextualMapper); - case 158: - return checkPropertyAccessExpression(node); - case 159: - return checkIndexedAccess(node); - case 160: case 161: - return checkCallExpression(node); + return checkArrayLiteral(node, contextualMapper); case 162: - return checkTaggedTemplateExpression(node); + return checkObjectLiteral(node, contextualMapper); case 163: - return checkTypeAssertion(node); + return checkPropertyAccessExpression(node); case 164: - return checkExpression(node.expression, contextualMapper); - case 177: - return checkClassExpression(node); + return checkIndexedAccess(node); case 165: case 166: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 168: - return checkTypeOfExpression(node); + return checkCallExpression(node); case 167: - return checkDeleteExpression(node); + return checkTaggedTemplateExpression(node); case 169: - return checkVoidExpression(node); + return checkExpression(node.expression, contextualMapper); + case 183: + return checkClassExpression(node); case 170: - return checkPrefixUnaryExpression(node); case 171: - return checkPostfixUnaryExpression(node); - case 172: - return checkBinaryExpression(node, contextualMapper); + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); case 173: - return checkConditionalExpression(node, contextualMapper); - case 176: - return checkSpreadElementExpression(node, contextualMapper); - case 178: - return undefinedType; + return checkTypeOfExpression(node); + case 168: + case 186: + return checkAssertion(node); + case 172: + return checkDeleteExpression(node); + case 174: + return checkVoidExpression(node); case 175: + return checkAwaitExpression(node); + case 176: + return checkPrefixUnaryExpression(node); + case 177: + return checkPostfixUnaryExpression(node); + case 178: + return checkBinaryExpression(node, contextualMapper); + case 179: + return checkConditionalExpression(node, contextualMapper); + case 182: + return checkSpreadElementExpression(node, contextualMapper); + case 184: + return undefinedType; + case 181: return checkYieldExpression(node); + case 237: + return checkJsxExpression(node); + case 230: + return checkJsxElement(node); + case 231: + return checkJsxSelfClosingElement(node); + case 232: + ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; } @@ -16695,7 +17742,7 @@ var ts; var func = ts.getContainingFunction(node); if (node.flags & 112) { func = ts.getContainingFunction(node); - if (!(func.kind === 137 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 141 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -16710,15 +17757,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 136 || - node.kind === 203 || - node.kind === 165; + return node.kind === 140 || + node.kind === 210 || + node.kind === 170; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 65 && + if (param.name.kind === 66 && param.name.text === parameter.text) { return i; } @@ -16728,30 +17775,30 @@ var ts; } function isInLegalTypePredicatePosition(node) { switch (node.parent.kind) { - case 166: + case 171: + case 144: + case 210: + case 170: + case 149: case 140: - case 203: - case 165: - case 145: - case 136: - case 135: + case 139: return node === node.parent.type; } return false; } function checkSignatureDeclaration(node) { - if (node.kind === 142) { + if (node.kind === 146) { checkGrammarIndexSignature(node); } - else if (node.kind === 145 || node.kind === 203 || node.kind === 146 || - node.kind === 140 || node.kind === 137 || - node.kind === 141) { + else if (node.kind === 149 || node.kind === 210 || node.kind === 150 || + node.kind === 144 || node.kind === 141 || + node.kind === 145) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { - if (node.type.kind === 143) { + if (node.type.kind === 147) { var typePredicate = getSignatureFromDeclaration(node).typePredicate; var typePredicateNode = node.type; if (isInLegalTypePredicatePosition(typePredicateNode)) { @@ -16770,19 +17817,19 @@ var ts; if (hasReportedError) { break; } - if (param.name.kind === 153 || - param.name.kind === 154) { + if (param.name.kind === 158 || + param.name.kind === 159) { (function checkBindingPattern(pattern) { for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.name.kind === 65 && + if (element.name.kind === 66 && element.name.text === typePredicate.parameterName) { error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); hasReportedError = true; break; } - else if (element.name.kind === 154 || - element.name.kind === 153) { + else if (element.name.kind === 159 || + element.name.kind === 158) { checkBindingPattern(element.name); } } @@ -16806,10 +17853,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 141: + case 145: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 140: + case 144: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -16831,7 +17878,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 205) { + if (node.kind === 212) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -16846,7 +17893,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 123: + case 127: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -16854,7 +17901,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 121: + case 125: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -16874,6 +17921,9 @@ var ts; function checkMethodDeclaration(node) { checkGrammarMethod(node) || checkGrammarComputedPropertyName(node.name); checkFunctionLikeDeclaration(node); + if (node.flags & 256 && node.body) { + error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); + } } function checkConstructorDeclaration(node) { checkSignatureDeclaration(node); @@ -16891,30 +17941,30 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 160 && n.expression.kind === 91; + return n.kind === 165 && n.expression.kind === 92; } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } switch (n.kind) { - case 165: - case 203: - case 166: - case 157: return false; + case 170: + case 210: + case 171: + case 162: return false; default: return ts.forEachChild(n, containsSuperCall); } } function markThisReferencesAsErrors(n) { - if (n.kind === 93) { + if (n.kind === 94) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 165 && n.kind !== 203) { + else if (n.kind !== 170 && n.kind !== 210) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 134 && + return n.kind === 138 && !(n.flags & 128) && !!n.initializer; } @@ -16924,7 +17974,7 @@ var ts; ts.forEach(node.parameters, function (p) { return p.flags & (16 | 32 | 64); }); if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 185 || !isSuperCallExpression(statements[0].expression)) { + if (!statements.length || statements[0].kind !== 192 || !isSuperCallExpression(statements[0].expression)) { error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); } else { @@ -16940,13 +17990,13 @@ var ts; function checkAccessorDeclaration(node) { if (produceDiagnostics) { checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 138) { + if (node.kind === 142) { 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 === 138 ? 139 : 138; + var otherKind = node.kind === 142 ? 143 : 142; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112) !== (otherAccessor.flags & 112))) { @@ -17012,7 +18062,7 @@ var ts; } ts.forEach(node.elementTypes, checkSourceElement); } - function checkUnionType(node) { + function checkUnionOrIntersectionType(node) { ts.forEach(node.types, checkSourceElement); } function isPrivateWithinAmbient(node) { @@ -17031,9 +18081,9 @@ var ts; return; } var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 205) { - ts.Debug.assert(signatureDeclarationNode.kind === 140 || signatureDeclarationNode.kind === 141); - var signatureKind = signatureDeclarationNode.kind === 140 ? 0 : 1; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 212) { + ts.Debug.assert(signatureDeclarationNode.kind === 144 || signatureDeclarationNode.kind === 145); + var signatureKind = signatureDeclarationNode.kind === 144 ? 0 : 1; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -17051,7 +18101,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 205 && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 212 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; } @@ -17082,6 +18132,9 @@ var ts; else if (deviation & (32 | 64)) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } + else if (deviation & 256) { + error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract); + } }); } } @@ -17096,7 +18149,7 @@ var ts; }); } } - var flagsToCheck = 1 | 2 | 32 | 64; + var flagsToCheck = 1 | 2 | 32 | 64 | 256; var someNodeFlags = 0; var allNodeFlags = flagsToCheck; var someHaveQuestionToken = false; @@ -17124,7 +18177,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 === 136 || node.kind === 135); + ts.Debug.assert(node.kind === 140 || node.kind === 139); 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); @@ -17141,7 +18194,12 @@ var ts; error(errorNode, ts.Diagnostics.Constructor_implementation_is_missing); } else { - error(errorNode, ts.Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration); + if (node.flags & 256) { + error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); + } + else { + error(errorNode, ts.Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration); + } } } var isExportSymbolInsideModule = symbol.parent && symbol.parent.flags & 1536; @@ -17151,11 +18209,11 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 205 || node.parent.kind === 148 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 212 || node.parent.kind === 152 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 203 || node.kind === 136 || node.kind === 135 || node.kind === 137) { + if (node.kind === 210 || node.kind === 140 || node.kind === 139 || node.kind === 141) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -17196,7 +18254,8 @@ var ts; error(declaration.name, ts.Diagnostics.Duplicate_function_implementation); }); } - if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body) { + if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && + !(lastSeenNonAmbientDeclaration.flags & 256)) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { @@ -17252,16 +18311,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 205: + case 212: return 2097152; - case 208: + case 215: return d.name.kind === 8 || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 204: - case 207: - return 2097152 | 1048576; case 211: + case 214: + return 2097152 | 1048576; + case 218: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -17271,6 +18330,121 @@ var ts; } } } + function checkNonThenableType(type, location, message) { + if (!(type.flags & 1) && isTypeAssignableTo(type, getGlobalThenableType())) { + if (location) { + if (!message) { + message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; + } + error(location, message); + } + return unknownType; + } + return type; + } + function getPromisedType(promise) { + // + // { // promise + // then( // thenFunction + // onfulfilled: ( // onfulfilledParameterType + // value: T // valueParameterType + // ) => any + // ): any; + // } + // + if (promise.flags & 1) { + return undefined; + } + if ((promise.flags & 4096) && promise.target === tryGetGlobalPromiseType()) { + return promise.typeArguments[0]; + } + var globalPromiseLikeType = getInstantiatedGlobalPromiseLikeType(); + if (globalPromiseLikeType === emptyObjectType || !isTypeAssignableTo(promise, globalPromiseLikeType)) { + return undefined; + } + var thenFunction = getTypeOfPropertyOfType(promise, "then"); + if (thenFunction && (thenFunction.flags & 1)) { + return undefined; + } + var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0) : emptyArray; + if (thenSignatures.length === 0) { + return undefined; + } + var onfulfilledParameterType = getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)); + if (onfulfilledParameterType.flags & 1) { + return undefined; + } + var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0); + if (onfulfilledParameterSignatures.length === 0) { + return undefined; + } + var valueParameterType = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature)); + return valueParameterType; + } + function getTypeOfFirstParameterOfSignature(signature) { + return getTypeAtPosition(signature, 0); + } + function getAwaitedType(type) { + return checkAwaitedType(type, undefined, undefined); + } + function checkAwaitedType(type, location, message) { + return checkAwaitedTypeWorker(type); + function checkAwaitedTypeWorker(type) { + if (type.flags & 16384) { + var types = []; + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var constituentType = _a[_i]; + types.push(checkAwaitedTypeWorker(constituentType)); + } + return getUnionType(types); + } + else { + var promisedType = getPromisedType(type); + if (promisedType === undefined) { + return checkNonThenableType(type, location, message); + } + else { + if (type.id === promisedType.id || awaitedTypeStack.indexOf(promisedType.id) >= 0) { + if (location) { + error(location, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method, symbolToString(type.symbol)); + } + return unknownType; + } + awaitedTypeStack.push(type.id); + var awaitedType = checkAwaitedTypeWorker(promisedType); + awaitedTypeStack.pop(); + return awaitedType; + } + } + } + } + function checkAsyncFunctionReturnType(node) { + var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); + if (globalPromiseConstructorLikeType === emptyObjectType) { + return unknownType; + } + var promiseType = getTypeFromTypeNode(node.type); + if (promiseType === unknownType && compilerOptions.isolatedModules) { + return unknownType; + } + var promiseConstructor = getMergedSymbol(promiseType.symbol); + if (!promiseConstructor || !symbolIsValue(promiseConstructor)) { + error(node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeToString(promiseType)); + return unknownType; + } + var promiseConstructorType = getTypeOfSymbol(promiseConstructor); + if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type)) { + return unknownType; + } + var promiseName = ts.getEntityNameFromTypeNode(node.type); + var root = getFirstIdentifier(promiseName); + var rootSymbol = getSymbol(node.locals, root.text, 107455); + if (rootSymbol) { + error(rootSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, root.text, getFullyQualifiedName(promiseConstructor)); + return unknownType; + } + return checkAwaitedType(promiseType, node, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + } function checkDecorator(node) { var signature = getResolvedSignature(node); var returnType = getReturnTypeOfSignature(signature); @@ -17281,22 +18455,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 204: + case 211: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 131: + case 135: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 134: + case 138: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 136: - case 138: - case 139: + case 140: + case 142: + case 143: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -17305,33 +18479,30 @@ var ts; checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); } function checkTypeNodeAsExpression(node) { - if (node && node.kind === 144) { - var type = getTypeFromTypeNode(node); - var shouldCheckIfUnknownType = type === unknownType && compilerOptions.isolatedModules; - if (!type || (!shouldCheckIfUnknownType && type.flags & (2097279 | 132 | 258))) { - return; - } - if (shouldCheckIfUnknownType || type.symbol.valueDeclaration) { - checkExpression(node.typeName); + if (node && node.kind === 148) { + var root = getFirstIdentifier(node.typeName); + var rootSymbol = resolveName(root, root.text, 107455, undefined, undefined); + if (rootSymbol && rootSymbol.flags & 8388608 && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { + markAliasSymbolAsReferenced(rootSymbol); } } } function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 134: - checkTypeNodeAsExpression(node.type); - break; - case 131: - checkTypeNodeAsExpression(node.type); - break; - case 136: - checkTypeNodeAsExpression(node.type); - break; case 138: checkTypeNodeAsExpression(node.type); break; - case 139: - checkTypeNodeAsExpression(getSetAccessorTypeAnnotationNode(node)); + case 135: + checkTypeNodeAsExpression(node.type); + break; + case 140: + checkTypeNodeAsExpression(node.type); + break; + case 142: + checkTypeNodeAsExpression(node.type); + break; + case 143: + checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node)); break; } } @@ -17353,24 +18524,24 @@ var ts; } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 204: + case 211: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 136: + case 140: checkParameterTypeAnnotationsAsExpressions(node); - case 139: + case 143: + case 142: case 138: - case 134: - case 131: + case 135: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 131) { + if (node.kind === 135) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); @@ -17386,7 +18557,14 @@ var ts; function checkFunctionLikeDeclaration(node) { checkDecorators(node); checkSignatureDeclaration(node); - if (node.name && node.name.kind === 129) { + 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 === 133) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -17404,7 +18582,12 @@ var ts; } checkSourceElement(node.body); if (node.type && !isAccessor(node.kind) && !node.asteriskToken) { - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); + var returnType = getTypeFromTypeNode(node.type); + var promisedType; + if (isAsync) { + promisedType = checkAsyncFunctionReturnType(node); + } + checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); } if (produceDiagnostics && !node.type) { if (compilerOptions.noImplicitAny && ts.nodeIsMissing(node.body) && !isPrivateWithinAmbient(node)) { @@ -17416,11 +18599,11 @@ var ts; } } function checkBlock(node) { - if (node.kind === 182) { + if (node.kind === 189) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 209) { + if (ts.isFunctionBlock(node) || node.kind === 216) { checkFunctionAndClassExpressionBodies(node); } } @@ -17438,19 +18621,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 134 || - node.kind === 133 || - node.kind === 136 || - node.kind === 135 || - node.kind === 138 || - node.kind === 139) { + if (node.kind === 138 || + node.kind === 137 || + node.kind === 140 || + node.kind === 139 || + node.kind === 142 || + node.kind === 143) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 131 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 135 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -17464,7 +18647,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4) { - var isDeclaration_1 = node.kind !== 65; + var isDeclaration_1 = node.kind !== 66; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -17485,7 +18668,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 65; + var isDeclaration_2 = node.kind !== 66; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -17498,11 +18681,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 208 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 215 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 230 && ts.isExternalModule(parent)) { + if (parent.kind === 245 && 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)); } } @@ -17510,10 +18693,10 @@ var ts; // - 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) & 12288) !== 0 || ts.isParameterDeclaration(node)) { + if ((ts.getCombinedNodeFlags(node) & 49152) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 201 && !node.initializer) { + if (node.kind === 208 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -17522,35 +18705,35 @@ var ts; if (localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { - if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 12288) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 202); - var container = varDeclList.parent.kind === 183 && varDeclList.parent.parent + if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152) { + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 209); + var container = varDeclList.parent.kind === 190 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 182 && ts.isFunctionLike(container.parent) || - container.kind === 209 || - container.kind === 208 || - container.kind === 230); + (container.kind === 189 && ts.isFunctionLike(container.parent) || + container.kind === 216 || + container.kind === 215 || + container.kind === 245); if (!namesShareScope) { - var name_13 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_13, name_13); + 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); } } } } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 131) { + if (ts.getRootDeclaration(node).kind !== 135) { return; } var func = ts.getContainingFunction(node); visit(node.initializer); function visit(n) { - if (n.kind === 65) { + if (n.kind === 66) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 131) { + if (referencedSymbol.valueDeclaration.kind === 135) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -17570,7 +18753,7 @@ var ts; function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 129) { + if (node.name.kind === 133) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -17579,7 +18762,7 @@ var ts; if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 131 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 135 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -17607,9 +18790,9 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 134 && node.kind !== 133) { + if (node.kind !== 138 && node.kind !== 137) { checkExportsOnMergedDeclarations(node); - if (node.kind === 201 || node.kind === 155) { + if (node.kind === 208 || node.kind === 160) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -17629,21 +18812,18 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarVariableDeclarationList(node.declarationList) || checkGrammarForDisallowedLetOrConstStatement(node); ts.forEach(node.declarationList.declarations, checkSourceElement); } - function checkGrammarDisallowedModifiersInBlockOrObjectLiteralExpression(node) { - if (node.modifiers) { - if (inBlockOrObjectLiteralExpression(node)) { + function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { + if (node.modifiers && node.parent.kind === 162) { + if (ts.isAsyncFunctionLike(node)) { + if (node.modifiers.length > 1) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + } + else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } } } - function inBlockOrObjectLiteralExpression(node) { - while (node) { - if (node.kind === 182 || node.kind === 157) { - return true; - } - node = node.parent; - } - } function checkExpressionStatement(node) { checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); @@ -17666,12 +18846,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 202) { + if (node.initializer && node.initializer.kind === 209) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 202) { + if (node.initializer.kind === 209) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -17686,13 +18866,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 202) { + if (node.initializer.kind === 209) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 156 || varExpr.kind === 157) { + if (varExpr.kind === 161 || varExpr.kind === 162) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -17707,7 +18887,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 202) { + if (node.initializer.kind === 209) { 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); @@ -17717,7 +18897,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 156 || varExpr.kind === 157) { + if (varExpr.kind === 161 || varExpr.kind === 162) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258)) { @@ -17728,7 +18908,7 @@ var ts; } } var rightType = checkExpression(node.expression); - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 48128 | 512)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 | 512)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); } checkSourceElement(node.statement); @@ -17879,7 +19059,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 138 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 139))); + return !!(node.kind === 142 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 143))); } function checkReturnStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { @@ -17897,22 +19077,33 @@ var ts; if (func.asteriskToken) { return; } - if (func.kind === 139) { + if (func.kind === 143) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 137) { + else if (func.kind === 141) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func) || signature.typePredicate) { - checkTypeAssignableTo(exprType, returnType, node.expression, undefined); + 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); + } + else { + checkTypeAssignableTo(exprType, returnType, node.expression); + } } } } } function checkWithStatement(node) { - checkGrammarStatementInAmbientContext(node); + if (!checkGrammarStatementInAmbientContext(node)) { + if (node.parserContextFlags & 8) { + grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); + } + } checkExpression(node.expression); error(node.expression, ts.Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any); } @@ -17922,7 +19113,7 @@ var ts; var hasDuplicateDefaultClause = false; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 224 && !hasDuplicateDefaultClause) { + if (clause.kind === 239 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -17934,7 +19125,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 223) { + if (produceDiagnostics && clause.kind === 238) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { @@ -17951,7 +19142,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 197 && current.label.text === node.label.text) { + if (current.kind === 204 && 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; @@ -17977,7 +19168,7 @@ var ts; var catchClause = node.catchClause; if (catchClause) { if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 65) { + if (catchClause.variableDeclaration.name.kind !== 66) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -18045,7 +19236,7 @@ var ts; return; } var errorNode; - if (prop.valueDeclaration.name.kind === 129 || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 133 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -18094,10 +19285,13 @@ var ts; return getTypeOfSymbol(getSymbolOfNode(node)); } function checkClassDeclaration(node) { - if (!node.name && !(node.flags & 256)) { + if (!node.name && !(node.flags & 1024)) { 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) { @@ -18191,43 +19385,52 @@ var ts; continue; } var derived = getTargetSymbol(getPropertyOfObjectType(type, base.name)); + var baseDeclarationFlags = getDeclarationFlagsFromSymbol(base); + ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); if (derived) { - var baseDeclarationFlags = getDeclarationFlagsFromSymbol(base); - var derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); - if ((baseDeclarationFlags & 32) || (derivedDeclarationFlags & 32)) { - continue; - } - if ((baseDeclarationFlags & 128) !== (derivedDeclarationFlags & 128)) { - continue; - } - if ((base.flags & derived.flags & 8192) || ((base.flags & 98308) && (derived.flags & 98308))) { - continue; - } - var errorMessage = void 0; - if (base.flags & 8192) { - if (derived.flags & 98304) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; + if (derived === base) { + var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 211); + 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)); } - else { - ts.Debug.assert((derived.flags & 4) !== 0); - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; - } - } - else if (base.flags & 4) { - ts.Debug.assert((derived.flags & 8192) !== 0); - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; } else { - ts.Debug.assert((base.flags & 98304) !== 0); - ts.Debug.assert((derived.flags & 8192) !== 0); - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + var derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); + if ((baseDeclarationFlags & 32) || (derivedDeclarationFlags & 32)) { + continue; + } + if ((baseDeclarationFlags & 128) !== (derivedDeclarationFlags & 128)) { + continue; + } + if ((base.flags & derived.flags & 8192) || ((base.flags & 98308) && (derived.flags & 98308))) { + continue; + } + var errorMessage = void 0; + if (base.flags & 8192) { + if (derived.flags & 98304) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; + } + else { + ts.Debug.assert((derived.flags & 4) !== 0); + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; + } + } + else if (base.flags & 4) { + ts.Debug.assert((derived.flags & 8192) !== 0); + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + } + else { + ts.Debug.assert((base.flags & 98304) !== 0); + ts.Debug.assert((derived.flags & 8192) !== 0); + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } + error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } - error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } } } function isAccessor(kind) { - return kind === 138 || kind === 139; + return kind === 142 || kind === 143; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -18293,7 +19496,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 205); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 212); 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); @@ -18308,6 +19511,15 @@ var ts; checkIndexConstraints(type); } } + if (symbol && symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 211 && !ts.isInAmbientContext(declaration)) { + error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); + break; + } + } + } } ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) { if (!ts.isSupportedExpressionWithTypeArguments(heritageElement)) { @@ -18327,14 +19539,14 @@ var ts; } function computeEnumMemberValues(node) { var nodeLinks = getNodeLinks(node); - if (!(nodeLinks.flags & 128)) { + if (!(nodeLinks.flags & 8192)) { var enumSymbol = getSymbolOfNode(node); var enumType = getDeclaredTypeOfSymbol(enumSymbol); var autoValue = 0; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); ts.forEach(node.members, function (member) { - if (member.name.kind !== 129 && isNumericLiteralName(member.name.text)) { + if (member.name.kind !== 133 && isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } var initializer = member.initializer; @@ -18364,24 +19576,24 @@ var ts; getNodeLinks(member).enumMemberValue = autoValue++; } }); - nodeLinks.flags |= 128; + nodeLinks.flags |= 8192; } function getConstantValueForEnumMemberInitializer(initializer) { return evalConstant(initializer); function evalConstant(e) { switch (e.kind) { - case 170: + case 176: var value = evalConstant(e.operand); if (value === undefined) { return undefined; } switch (e.operator) { - case 33: return value; - case 34: return -value; - case 47: return ~value; + case 34: return value; + case 35: return -value; + case 48: return ~value; } return undefined; - case 172: + case 178: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -18391,37 +19603,37 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 44: return left | right; - case 43: return left & right; - case 41: return left >> right; - case 42: return left >>> right; - case 40: return left << right; - case 45: return left ^ right; - case 35: return left * right; - case 36: return left / right; - case 33: return left + right; - case 34: return left - right; - case 37: return left % right; + case 45: return left | right; + case 44: return left & right; + case 42: return left >> right; + case 43: return left >>> right; + case 41: return left << right; + case 46: return left ^ right; + case 36: return left * right; + case 37: return left / right; + case 34: return left + right; + case 35: return left - right; + case 38: return left % right; } return undefined; case 7: return +e.text; - case 164: + case 169: return evalConstant(e.expression); - case 65: - case 159: - case 158: + case 66: + case 164: + case 163: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType; var propertyName; - if (e.kind === 65) { + if (e.kind === 66) { enumType = currentType; propertyName = e.text; } else { var expression; - if (e.kind === 159) { + if (e.kind === 164) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 8) { return undefined; @@ -18435,10 +19647,10 @@ var ts; } var current = expression; while (current) { - if (current.kind === 65) { + if (current.kind === 66) { break; } - else if (current.kind === 158) { + else if (current.kind === 163) { current = current.expression; } else { @@ -18495,7 +19707,7 @@ var ts; } var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 207) { + if (declaration.kind !== 214) { return false; } var enumDeclaration = declaration; @@ -18518,8 +19730,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 204 || - (declaration.kind === 203 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 211 || + (declaration.kind === 210 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -18570,10 +19782,10 @@ 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, 204); + var mergedClass = ts.getDeclarationOfKind(symbol, 211); if (mergedClass && inSameLexicalScope(node, mergedClass)) { - getNodeLinks(node).flags |= 2048; + getNodeLinks(node).flags |= 32768; } } if (isAmbientExternalModule) { @@ -18589,17 +19801,17 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 128) { + if (node.kind === 132) { node = node.left; } - else if (node.kind === 158) { + else if (node.kind === 163) { node = node.expression; } else { break; } } - ts.Debug.assert(node.kind === 65); + ts.Debug.assert(node.kind === 66); return node; } function checkExternalImportOrExportDeclaration(node) { @@ -18608,9 +19820,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 209 && node.parent.parent.name.kind === 8; - if (node.parent.kind !== 230 && !inAmbientExternalModule) { - error(moduleName, node.kind === 218 ? + var inAmbientExternalModule = node.parent.kind === 216 && node.parent.parent.name.kind === 8; + if (node.parent.kind !== 245 && !inAmbientExternalModule) { + error(moduleName, node.kind === 225 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -18629,7 +19841,7 @@ var ts; (symbol.flags & 793056 ? 793056 : 0) | (symbol.flags & 1536 ? 1536 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 220 ? + var message = node.kind === 227 ? 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)); @@ -18645,7 +19857,7 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -18655,7 +19867,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 214) { + if (importClause.namedBindings.kind === 221) { checkImportBinding(importClause.namedBindings); } else { @@ -18700,14 +19912,14 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) { return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 209 && node.parent.parent.name.kind === 8; - if (node.parent.kind !== 230 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 216 && node.parent.parent.name.kind === 8; + if (node.parent.kind !== 245 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -18720,7 +19932,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 230 && node.parent.kind !== 209 && node.parent.kind !== 208) { + if (node.parent.kind !== 245 && node.parent.kind !== 216 && node.parent.kind !== 215) { return grammarErrorOnFirstToken(node, errorMessage); } } @@ -18734,15 +19946,15 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 230 ? node.parent : node.parent.parent; - if (container.kind === 208 && container.name.kind === 65) { + var container = node.parent.kind === 245 ? node.parent : node.parent.parent; + if (container.kind === 215 && container.name.kind === 66) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 65) { + if (node.expression.kind === 66) { markExportAsReferenced(node); } else { @@ -18759,10 +19971,10 @@ var ts; } } function getModuleStatements(node) { - if (node.kind === 230) { + if (node.kind === 245) { return node.statements; } - if (node.kind === 208 && node.body.kind === 209) { + if (node.kind === 215 && node.body.kind === 216) { return node.body.statements; } return emptyArray; @@ -18793,197 +20005,218 @@ var ts; } } function checkSourceElement(node) { - if (!node) + if (!node) { return; - switch (node.kind) { - case 130: - return checkTypeParameter(node); - case 131: - return checkParameter(node); + } + var kind = node.kind; + if (cancellationToken) { + switch (kind) { + case 215: + case 211: + case 212: + case 210: + cancellationToken.throwIfCancellationRequested(); + } + } + switch (kind) { case 134: - case 133: - return checkPropertyDeclaration(node); - case 145: - case 146: - case 140: - case 141: - return checkSignatureDeclaration(node); - case 142: - return checkSignatureDeclaration(node); - case 136: + return checkTypeParameter(node); case 135: - return checkMethodDeclaration(node); - case 137: - return checkConstructorDeclaration(node); + return checkParameter(node); case 138: - case 139: - return checkAccessorDeclaration(node); - case 144: - return checkTypeReferenceNode(node); - case 143: - return checkTypePredicate(node); - case 147: - return checkTypeQuery(node); - case 148: - return checkTypeLiteral(node); + case 137: + return checkPropertyDeclaration(node); case 149: - return checkArrayType(node); case 150: - return checkTupleType(node); + case 144: + case 145: + return checkSignatureDeclaration(node); + case 146: + return checkSignatureDeclaration(node); + case 140: + case 139: + return checkMethodDeclaration(node); + case 141: + return checkConstructorDeclaration(node); + case 142: + case 143: + return checkAccessorDeclaration(node); + case 148: + return checkTypeReferenceNode(node); + case 147: + return checkTypePredicate(node); case 151: - return checkUnionType(node); + return checkTypeQuery(node); case 152: - return checkSourceElement(node.type); - case 203: - return checkFunctionDeclaration(node); - case 182: - case 209: - return checkBlock(node); - case 183: - return checkVariableStatement(node); - case 185: - return checkExpressionStatement(node); - case 186: - return checkIfStatement(node); - case 187: - return checkDoStatement(node); - case 188: - return checkWhileStatement(node); - case 189: - return checkForStatement(node); - case 190: - return checkForInStatement(node); - case 191: - return checkForOfStatement(node); - case 192: - case 193: - return checkBreakOrContinueStatement(node); - case 194: - return checkReturnStatement(node); - case 195: - return checkWithStatement(node); - case 196: - return checkSwitchStatement(node); - case 197: - return checkLabeledStatement(node); - case 198: - return checkThrowStatement(node); - case 199: - return checkTryStatement(node); - case 201: - return checkVariableDeclaration(node); + return checkTypeLiteral(node); + case 153: + return checkArrayType(node); + case 154: + return checkTupleType(node); case 155: - return checkBindingElement(node); - case 204: - return checkClassDeclaration(node); - case 205: - return checkInterfaceDeclaration(node); - case 206: - return checkTypeAliasDeclaration(node); - case 207: - return checkEnumDeclaration(node); - case 208: - return checkModuleDeclaration(node); - case 212: - return checkImportDeclaration(node); - case 211: - return checkImportEqualsDeclaration(node); - case 218: - return checkExportDeclaration(node); - case 217: - return checkExportAssignment(node); - case 184: - checkGrammarStatementInAmbientContext(node); - return; + case 156: + return checkUnionOrIntersectionType(node); + case 157: + return checkSourceElement(node.type); + case 210: + return checkFunctionDeclaration(node); + case 189: + case 216: + return checkBlock(node); + case 190: + return checkVariableStatement(node); + case 192: + return checkExpressionStatement(node); + case 193: + return checkIfStatement(node); + case 194: + return checkDoStatement(node); + case 195: + return checkWhileStatement(node); + case 196: + return checkForStatement(node); + case 197: + return checkForInStatement(node); + case 198: + return checkForOfStatement(node); + case 199: case 200: + return checkBreakOrContinueStatement(node); + case 201: + return checkReturnStatement(node); + case 202: + return checkWithStatement(node); + case 203: + return checkSwitchStatement(node); + case 204: + return checkLabeledStatement(node); + case 205: + return checkThrowStatement(node); + case 206: + return checkTryStatement(node); + case 208: + return checkVariableDeclaration(node); + case 160: + return checkBindingElement(node); + case 211: + return checkClassDeclaration(node); + case 212: + return checkInterfaceDeclaration(node); + case 213: + return checkTypeAliasDeclaration(node); + case 214: + return checkEnumDeclaration(node); + case 215: + return checkModuleDeclaration(node); + case 219: + return checkImportDeclaration(node); + case 218: + return checkImportEqualsDeclaration(node); + case 225: + return checkExportDeclaration(node); + case 224: + return checkExportAssignment(node); + case 191: checkGrammarStatementInAmbientContext(node); return; - case 221: + case 207: + checkGrammarStatementInAmbientContext(node); + return; + case 228: return checkMissingDeclaration(node); } } function checkFunctionAndClassExpressionBodies(node) { switch (node.kind) { - case 165: - case 166: + case 170: + case 171: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 177: + case 183: ts.forEach(node.members, checkSourceElement); break; - case 136: - case 135: + case 140: + case 139: ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 137: - case 138: - case 139: - case 203: + case 141: + case 142: + case 143: + case 210: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); break; - case 195: + case 202: checkFunctionAndClassExpressionBodies(node.expression); break; - case 132: - case 131: - case 134: - case 133: - case 153: - case 154: - case 155: - case 156: - case 157: - case 227: + case 136: + case 135: + case 138: + case 137: case 158: case 159: case 160: case 161: case 162: - case 174: - case 180: + case 242: case 163: case 164: - case 168: - case 169: + case 165: + case 166: case 167: - case 170: - case 171: - case 172: - case 173: - case 176: - case 182: - case 209: - case 183: - case 185: - case 186: + case 180: case 187: - case 188: + case 168: + case 186: + case 169: + case 173: + case 174: + case 175: + case 172: + case 176: + case 177: + case 178: + case 179: + case 182: + case 181: case 189: + case 216: case 190: - case 191: case 192: case 193: case 194: + case 195: case 196: - case 210: - case 223: - case 224: case 197: case 198: case 199: - case 226: + case 200: case 201: - case 202: - case 204: - case 207: - case 229: + case 203: case 217: + case 238: + case 239: + case 204: + case 205: + case 206: + case 241: + case 208: + case 209: + case 211: + case 214: + case 244: + case 224: + case 245: + case 237: case 230: + case 231: + case 235: + case 236: + case 232: ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; } @@ -19017,15 +20250,30 @@ var ts; links.flags |= 8; } if (emitDecorate) { - links.flags |= 512; + links.flags |= 16; } if (emitParam) { - links.flags |= 1024; + links.flags |= 32; + } + if (emitAwaiter) { + links.flags |= 64; + } + if (emitGenerator || (emitAwaiter && languageVersion < 2)) { + links.flags |= 128; } links.flags |= 1; } } - function getDiagnostics(sourceFile) { + function getDiagnostics(sourceFile, ct) { + try { + cancellationToken = ct; + return getDiagnosticsWorker(sourceFile); + } + finally { + cancellationToken = undefined; + } + } + function getDiagnosticsWorker(sourceFile) { throwIfNonDiagnosticsProducing(); if (sourceFile) { checkSourceFile(sourceFile); @@ -19046,7 +20294,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 195 && node.parent.statement === node) { + if (node.parent.kind === 202 && node.parent.statement === node) { return true; } node = node.parent; @@ -19068,28 +20316,30 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 230: + case 245: if (!ts.isExternalModule(location)) { break; } - case 208: + case 215: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 207: + case 214: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 177: - if (location.name) { + case 183: + var className = location.name; + if (className) { copySymbol(location.symbol, meaning); } - case 204: - case 205: + case 211: + case 212: if (!(memberFlags & 128)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; - case 165: - if (location.name) { + case 170: + var funcName = location.name; + if (funcName) { copySymbol(location.symbol, meaning); } break; @@ -19102,7 +20352,7 @@ var ts; function copySymbol(symbol, meaning) { if (symbol.flags & meaning) { var id = symbol.name; - if (!isReservedMemberName(id) && !ts.hasProperty(symbols, id)) { + if (!ts.hasProperty(symbols, id)) { symbols[id] = symbol; } } @@ -19110,50 +20360,49 @@ var ts; function copySymbols(source, meaning) { if (meaning) { for (var id in source) { - if (ts.hasProperty(source, id)) { - copySymbol(source[id], meaning); - } + var symbol = source[id]; + copySymbol(symbol, meaning); } } } } function isTypeDeclarationName(name) { - return name.kind === 65 && + return name.kind === 66 && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 130: - case 204: - case 205: - case 206: - case 207: + case 134: + case 211: + case 212: + case 213: + case 214: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 128) { + while (node.parent && node.parent.kind === 132) { node = node.parent; } - return node.parent && node.parent.kind === 144; + return node.parent && node.parent.kind === 148; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 158) { + while (node.parent && node.parent.kind === 163) { node = node.parent; } - return node.parent && node.parent.kind === 179; + return node.parent && node.parent.kind === 185; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 128) { + while (nodeOnRightSide.parent.kind === 132) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 211) { + if (nodeOnRightSide.parent.kind === 218) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 217) { + if (nodeOnRightSide.parent.kind === 224) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -19165,10 +20414,10 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 217) { + if (entityName.parent.kind === 224) { return resolveEntityName(entityName, 107455 | 793056 | 1536 | 8388608); } - if (entityName.kind !== 158) { + if (entityName.kind !== 163) { if (isInRightSideOfImportOrExportAssignment(entityName)) { return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); } @@ -19177,26 +20426,29 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 179 ? 793056 : 1536; + var meaning = entityName.parent.kind === 185 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } + else if ((entityName.parent.kind === 232) || (entityName.parent.kind === 231)) { + return getJsxElementTagSymbol(entityName.parent); + } else if (ts.isExpression(entityName)) { if (ts.nodeIsMissing(entityName)) { return undefined; } - if (entityName.kind === 65) { + if (entityName.kind === 66) { var meaning = 107455 | 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 158) { + else if (entityName.kind === 163) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 128) { + else if (entityName.kind === 132) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -19205,11 +20457,14 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 144 ? 793056 : 1536; + var meaning = entityName.parent.kind === 148 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } - if (entityName.parent.kind === 143) { + else if (entityName.parent.kind === 235) { + return getJsxAttributePropertySymbol(entityName.parent); + } + if (entityName.parent.kind === 147) { return resolveEntityName(entityName, 1); } return undefined; @@ -19221,36 +20476,35 @@ var ts; if (ts.isDeclarationName(node)) { return getSymbolOfNode(node.parent); } - if (node.kind === 65 && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 217 + if (node.kind === 66 && isInRightSideOfImportOrExportAssignment(node)) { + return node.parent.kind === 224 ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } switch (node.kind) { - case 65: - case 158: - case 128: + case 66: + case 163: + case 132: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 93: - case 91: + case 94: + case 92: var type = checkExpression(node); return type.symbol; - case 114: + case 118: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 137) { + if (constructorDeclaration && constructorDeclaration.kind === 141) { return constructorDeclaration.parent.symbol; } return undefined; case 8: - var moduleName; if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 212 || node.parent.kind === 218) && + ((node.parent.kind === 219 || node.parent.kind === 225) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } case 7: - if (node.parent.kind === 159 && node.parent.argumentExpression === node) { + if (node.parent.kind === 164 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -19264,7 +20518,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 228) { + if (location && location.kind === 243) { return resolveEntityName(location.name, 107455); } return undefined; @@ -19298,6 +20552,9 @@ var ts; var symbol = getSymbolInfo(node); return symbol && getTypeOfSymbol(symbol); } + if (ts.isBindingPattern(node)) { + return getTypeForVariableLikeDeclaration(node.parent); + } if (isInRightSideOfImportOrExportAssignment(node)) { var symbol = getSymbolInfo(node); var declaredType = symbol && getDeclaredTypeOfSymbol(symbol); @@ -19332,9 +20589,9 @@ var ts; function getRootSymbols(symbol) { if (symbol.flags & 268435456) { var symbols = []; - var name_14 = symbol.name; - ts.forEach(getSymbolLinks(symbol).unionType.types, function (t) { - symbols.push(getPropertyOfType(t, name_14)); + var name_15 = symbol.name; + ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { + symbols.push(getPropertyOfType(t, name_15)); }); return symbols; } @@ -19358,11 +20615,11 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 230) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 245) { return parentSymbol.valueDeclaration; } for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 208 || n.kind === 207) && getSymbolOfNode(n) === parentSymbol) { + if ((n.kind === 215 || n.kind === 214) && getSymbolOfNode(n) === parentSymbol) { return n; } } @@ -19375,11 +20632,11 @@ var ts; } function isStatementWithLocals(node) { switch (node.kind) { - case 182: - case 210: case 189: - case 190: - case 191: + case 217: + case 196: + case 197: + case 198: return true; } return false; @@ -19405,22 +20662,22 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 211: - case 213: - case 214: - case 216: - case 220: - return isAliasResolvedToValue(getSymbolOfNode(node)); case 218: + case 220: + case 221: + case 223: + case 227: + return isAliasResolvedToValue(getSymbolOfNode(node)); + case 225: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 217: - return node.expression && node.expression.kind === 65 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + case 224: + return node.expression && node.expression.kind === 66 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 230 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 245 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -19465,7 +20722,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 229) { + if (node.kind === 244) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -19476,149 +20733,50 @@ var ts; } return undefined; } - function serializeEntityName(node, fallbackPath) { - if (node.kind === 65) { - var text = node.text; - if (fallbackPath) { - fallbackPath.push(text); - } - else { - return text; - } + function isFunctionType(type) { + return type.flags & 80896 && getSignaturesOfType(type, 0).length > 0; + } + function getTypeReferenceSerializationKind(node) { + var symbol = resolveEntityName(node.typeName, 107455, true); + var constructorType = symbol ? getTypeOfSymbol(symbol) : undefined; + if (constructorType && isConstructorType(constructorType)) { + return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; + } + var type = getTypeFromTypeNode(node); + if (type === unknownType) { + return ts.TypeReferenceSerializationKind.Unknown; + } + else if (type.flags & 1) { + return ts.TypeReferenceSerializationKind.ObjectType; + } + else if (allConstituentTypesHaveKind(type, 16)) { + return ts.TypeReferenceSerializationKind.VoidType; + } + else if (allConstituentTypesHaveKind(type, 8)) { + return ts.TypeReferenceSerializationKind.BooleanType; + } + else if (allConstituentTypesHaveKind(type, 132)) { + return ts.TypeReferenceSerializationKind.NumberLikeType; + } + else if (allConstituentTypesHaveKind(type, 258)) { + return ts.TypeReferenceSerializationKind.StringLikeType; + } + else if (allConstituentTypesHaveKind(type, 8192)) { + return ts.TypeReferenceSerializationKind.ArrayLikeType; + } + else if (allConstituentTypesHaveKind(type, 4194304)) { + return ts.TypeReferenceSerializationKind.ESSymbolType; + } + else if (isFunctionType(type)) { + return ts.TypeReferenceSerializationKind.TypeWithCallSignature; + } + else if (isArrayType(type)) { + return ts.TypeReferenceSerializationKind.ArrayLikeType; } else { - var left = serializeEntityName(node.left, fallbackPath); - var right = serializeEntityName(node.right, fallbackPath); - if (!fallbackPath) { - return left + "." + right; - } + return ts.TypeReferenceSerializationKind.ObjectType; } } - function serializeTypeReferenceNode(node) { - var type = getTypeFromTypeNode(node); - if (type.flags & 16) { - return "void 0"; - } - else if (type.flags & 8) { - return "Boolean"; - } - else if (type.flags & 132) { - return "Number"; - } - else if (type.flags & 258) { - return "String"; - } - else if (type.flags & 8192) { - return "Array"; - } - else if (type.flags & 2097152) { - return "Symbol"; - } - else if (type === unknownType) { - var fallbackPath = []; - serializeEntityName(node.typeName, fallbackPath); - return fallbackPath; - } - else if (type.symbol && type.symbol.valueDeclaration) { - return serializeEntityName(node.typeName); - } - else if (typeHasCallOrConstructSignatures(type)) { - return "Function"; - } - return "Object"; - } - function serializeTypeNode(node) { - if (node) { - switch (node.kind) { - case 99: - return "void 0"; - case 152: - return serializeTypeNode(node.type); - case 145: - case 146: - return "Function"; - case 149: - case 150: - return "Array"; - case 113: - return "Boolean"; - case 123: - case 8: - return "String"; - case 121: - return "Number"; - case 144: - return serializeTypeReferenceNode(node); - case 147: - case 148: - case 151: - case 112: - break; - default: - ts.Debug.fail("Cannot serialize unexpected type node."); - break; - } - } - return "Object"; - } - function serializeTypeOfNode(node) { - switch (node.kind) { - case 204: return "Function"; - case 134: return serializeTypeNode(node.type); - case 131: return serializeTypeNode(node.type); - case 138: return serializeTypeNode(node.type); - case 139: return serializeTypeNode(getSetAccessorTypeAnnotationNode(node)); - } - if (ts.isFunctionLike(node)) { - return "Function"; - } - return "void 0"; - } - function serializeParameterTypesOfNode(node) { - if (node) { - var valueDeclaration; - if (node.kind === 204) { - valueDeclaration = ts.getFirstConstructorWithBody(node); - } - else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { - valueDeclaration = node; - } - if (valueDeclaration) { - var result; - var parameters = valueDeclaration.parameters; - var parameterCount = parameters.length; - if (parameterCount > 0) { - result = new Array(parameterCount); - for (var i = 0; i < parameterCount; i++) { - if (parameters[i].dotDotDotToken) { - var parameterType = parameters[i].type; - if (parameterType.kind === 149) { - parameterType = parameterType.elementType; - } - else if (parameterType.kind === 144 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { - parameterType = parameterType.typeArguments[0]; - } - else { - parameterType = undefined; - } - result[i] = serializeTypeNode(parameterType); - } - else { - result[i] = serializeTypeOfNode(parameters[i]); - } - } - return result; - } - } - } - return emptyArray; - } - function serializeReturnTypeOfNode(node) { - if (node && ts.isFunctionLike(node)) { - return serializeTypeNode(node.type); - } - return "void 0"; - } function writeTypeOfDeclaration(declaration, enclosingDeclaration, flags, writer) { var symbol = getSymbolOfNode(declaration); var type = symbol && !(symbol.flags & (2048 | 131072)) @@ -19648,13 +20806,13 @@ var ts; } function getBlockScopedVariableId(n) { ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 155 || (n.parent.kind === 201 && n.parent.name === n); + var isVariableDeclarationOrBindingElement = n.parent.kind === 160 || (n.parent.kind === 208 && 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 !== 226; + symbol.valueDeclaration.parent.kind !== 241; if (isLetOrConst) { getSymbolLinks(symbol); return symbol.id; @@ -19694,9 +20852,7 @@ var ts; collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, - serializeTypeOfNode: serializeTypeOfNode, - serializeParameterTypesOfNode: serializeParameterTypesOfNode, - serializeReturnTypeOfNode: serializeReturnTypeOfNode + getTypeReferenceSerializationKind: getTypeReferenceSerializationKind }; } function initializeTypeChecker() { @@ -19719,7 +20875,19 @@ var ts; globalNumberType = getGlobalType("Number"); globalBooleanType = getGlobalType("Boolean"); globalRegExpType = getGlobalType("RegExp"); + jsxElementType = getExportedTypeFromNamespace("JSX", JsxNames.Element); + getGlobalClassDecoratorType = ts.memoize(function () { return getGlobalType("ClassDecorator"); }); + getGlobalPropertyDecoratorType = ts.memoize(function () { return getGlobalType("PropertyDecorator"); }); + getGlobalMethodDecoratorType = ts.memoize(function () { return getGlobalType("MethodDecorator"); }); + getGlobalParameterDecoratorType = ts.memoize(function () { return getGlobalType("ParameterDecorator"); }); getGlobalTypedPropertyDescriptorType = ts.memoize(function () { return getGlobalType("TypedPropertyDescriptor", 1); }); + getGlobalPromiseType = ts.memoize(function () { return getGlobalType("Promise", 1); }); + tryGetGlobalPromiseType = ts.memoize(function () { return getGlobalSymbol("Promise", 793056, undefined) && getGlobalPromiseType(); }); + getGlobalPromiseLikeType = ts.memoize(function () { return getGlobalType("PromiseLike", 1); }); + getInstantiatedGlobalPromiseLikeType = ts.memoize(createInstantiatedPromiseLikeType); + getGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Promise"); }); + getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); + getGlobalThenableType = ts.memoize(createThenableType); if (languageVersion >= 2) { globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray"); globalESSymbolType = getGlobalType("Symbol"); @@ -19738,6 +20906,23 @@ var ts; } anyArrayType = createArrayType(anyType); } + function createInstantiatedPromiseLikeType() { + var promiseLikeType = getGlobalPromiseLikeType(); + if (promiseLikeType !== emptyObjectType) { + return createTypeReference(promiseLikeType, [anyType]); + } + return emptyObjectType; + } + function createThenableType() { + var thenPropertySymbol = createSymbol(67108864 | 4, "then"); + getSymbolLinks(thenPropertySymbol).type = globalFunctionType; + var thenableType = createObjectType(65536); + thenableType.properties = [thenPropertySymbol]; + thenableType.members = createSymbolTable(thenableType.properties); + thenableType.callSignatures = []; + thenableType.constructSignatures = []; + return thenableType; + } function checkGrammarDecorators(node) { if (!node.decorators) { return false; @@ -19748,7 +20933,7 @@ var ts; else if (languageVersion < 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); } - else if (node.kind === 138 || node.kind === 139) { + else if (node.kind === 142 || node.kind === 143) { 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); @@ -19758,33 +20943,38 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 138: - case 139: - case 137: - case 134: - case 133: - case 136: - case 135: case 142: - case 208: - case 212: - case 211: + case 143: + case 141: + case 138: + case 137: + case 140: + case 139: + case 146: + case 215: + case 219: case 218: - case 217: - case 131: + case 225: + case 224: + case 135: break; - case 204: - case 205: - case 183: - case 203: - case 206: - if (node.modifiers && node.parent.kind !== 209 && node.parent.kind !== 230) { + case 210: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 115) && + node.parent.kind !== 216 && node.parent.kind !== 245) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 207: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 70) && - node.parent.kind !== 209 && node.parent.kind !== 230) { + case 211: + case 212: + case 190: + case 213: + if (node.modifiers && node.parent.kind !== 216 && node.parent.kind !== 245) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + break; + case 214: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 71) && + node.parent.kind !== 216 && node.parent.kind !== 245) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -19794,19 +20984,19 @@ var ts; if (!node.modifiers) { return; } - var lastStatic, lastPrivate, lastProtected, lastDeclare; + var lastStatic, lastPrivate, lastProtected, lastDeclare, lastAsync; var flags = 0; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; switch (modifier.kind) { + case 109: case 108: case 107: - case 106: var text = void 0; - if (modifier.kind === 108) { + if (modifier.kind === 109) { text = "public"; } - else if (modifier.kind === 107) { + else if (modifier.kind === 108) { text = "protected"; lastProtected = modifier; } @@ -19820,74 +21010,159 @@ var ts; else if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (node.parent.kind === 209 || node.parent.kind === 230) { + else if (flags & 512) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); + } + else if (node.parent.kind === 216 || node.parent.kind === 245) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } + else if (flags & 256) { + if (modifier.kind === 107) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); + } + else { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract"); + } + } flags |= ts.modifierToFlag(modifier.kind); break; - case 109: + case 110: if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (node.parent.kind === 209 || node.parent.kind === 230) { + else if (flags & 512) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); + } + else if (node.parent.kind === 216 || node.parent.kind === 245) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 131) { + else if (node.kind === 135) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } + else if (flags & 256) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); + } flags |= 128; lastStatic = modifier; break; - case 78: + case 79: if (flags & 1) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } else if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (node.parent.kind === 204) { + else if (flags & 256) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); + } + else if (flags & 512) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); + } + else if (node.parent.kind === 211) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 131) { + else if (node.kind === 135) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; break; - case 115: + case 119: if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (node.parent.kind === 204) { + else if (flags & 512) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); + } + else if (node.parent.kind === 211) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 131) { + else if (node.kind === 135) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 209) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 216) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; lastDeclare = modifier; break; + case 112: + if (flags & 256) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); + } + if (node.kind !== 211) { + if (node.kind !== 140) { + return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); + } + if (!(node.parent.kind === 211 && node.parent.flags & 256)) { + return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); + } + if (flags & 128) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); + } + if (flags & 32) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); + } + } + flags |= 256; + break; + case 115: + 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 === 135) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); + } + flags |= 512; + lastAsync = modifier; + break; } } - if (node.kind === 137) { + if (node.kind === 141) { if (flags & 128) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } + if (flags & 256) { + return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); + } else if (flags & 64) { return grammarErrorOnNode(lastProtected, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected"); } else if (flags & 32) { return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } + else if (flags & 512) { + return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); + } + return; } - else if ((node.kind === 212 || node.kind === 211) && flags & 2) { - return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare"); + else if ((node.kind === 219 || node.kind === 218) && flags & 2) { + return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 131 && (flags & 112) && ts.isBindingPattern(node.name)) { + else if (node.kind === 135 && (flags & 112) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } + if (flags & 512) { + return checkGrammarAsyncModifier(node, lastAsync); + } + } + function checkGrammarAsyncModifier(node, asyncModifier) { + if (languageVersion < 2) { + return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); + } + switch (node.kind) { + case 140: + case 210: + case 170: + case 171: + if (!node.asteriskToken) { + return false; + } + break; + } + return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); } function checkGrammarForDisallowedTrailingComma(list) { if (list && list.hasTrailingComma) { @@ -19948,7 +21223,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 166) { + if (node.kind === 171) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -19971,7 +21246,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); } - if (parameter.flags & 499) { + if (parameter.flags & 2035) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); } if (parameter.questionToken) { @@ -19983,7 +21258,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 !== 123 && parameter.type.kind !== 121) { + if (parameter.type.kind !== 127 && parameter.type.kind !== 125) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -19991,7 +21266,7 @@ var ts; } } function checkGrammarForIndexSignatureModifier(node) { - if (node.flags & 499) { + if (node.flags & 2035) { grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_not_permitted_on_index_signature_members); } } @@ -20010,20 +21285,20 @@ var ts; return checkGrammarForDisallowedTrailingComma(typeArguments) || checkGrammarForAtLeastOneTypeArgument(node, typeArguments); } - function checkGrammarForOmittedArgument(node, arguments) { - if (arguments) { + function checkGrammarForOmittedArgument(node, args) { + if (args) { var sourceFile = ts.getSourceFileOfNode(node); - for (var _i = 0; _i < arguments.length; _i++) { - var arg = arguments[_i]; - if (arg.kind === 178) { + for (var _i = 0; _i < args.length; _i++) { + var arg = args[_i]; + if (arg.kind === 184) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } } } - function checkGrammarArguments(node, arguments) { - return checkGrammarForDisallowedTrailingComma(arguments) || - checkGrammarForOmittedArgument(node, arguments); + function checkGrammarArguments(node, args) { + return checkGrammarForDisallowedTrailingComma(args) || + checkGrammarForOmittedArgument(node, args); } function checkGrammarHeritageClause(node) { var types = node.types; @@ -20042,7 +21317,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 === 79) { + if (heritageClause.token === 80) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -20055,7 +21330,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 102); + ts.Debug.assert(heritageClause.token === 103); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -20070,14 +21345,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 79) { + if (heritageClause.token === 80) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 102); + ts.Debug.assert(heritageClause.token === 103); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } checkGrammarHeritageClause(heritageClause); @@ -20086,19 +21361,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 129) { + if (node.kind !== 133) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 172 && computedPropertyName.expression.operatorToken.kind === 23) { + if (computedPropertyName.expression.kind === 178 && computedPropertyName.expression.operatorToken.kind === 23) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 203 || - node.kind === 165 || - node.kind === 136); + ts.Debug.assert(node.kind === 210 || + node.kind === 170 || + node.kind === 140); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -20123,76 +21398,97 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccesor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var name_15 = prop.name; - if (prop.kind === 178 || - name_15.kind === 129) { - checkGrammarComputedPropertyName(name_15); + var name_16 = prop.name; + if (prop.kind === 184 || + name_16.kind === 133) { + checkGrammarComputedPropertyName(name_16); continue; } var currentKind = void 0; - if (prop.kind === 227 || prop.kind === 228) { + if (prop.kind === 242 || prop.kind === 243) { checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_15.kind === 7) { - checkGrammarNumericLiteral(name_15); + if (name_16.kind === 7) { + checkGrammarNumericLiteral(name_16); } currentKind = Property; } - else if (prop.kind === 136) { + else if (prop.kind === 140) { currentKind = Property; } - else if (prop.kind === 138) { + else if (prop.kind === 142) { currentKind = GetAccessor; } - else if (prop.kind === 139) { + else if (prop.kind === 143) { currentKind = SetAccesor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - if (!ts.hasProperty(seen, name_15.text)) { - seen[name_15.text] = currentKind; + if (!ts.hasProperty(seen, name_16.text)) { + seen[name_16.text] = currentKind; } else { - var existingKind = seen[name_15.text]; + var existingKind = seen[name_16.text]; if (currentKind === Property && existingKind === Property) { continue; } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[name_15.text] = currentKind | existingKind; + seen[name_16.text] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_15, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_16, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_15, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_16, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } } + function checkGrammarJsxElement(node) { + var seen = {}; + for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { + var attr = _a[_i]; + if (attr.kind === 236) { + continue; + } + var jsxAttr = attr; + var name_17 = jsxAttr.name; + if (!ts.hasProperty(seen, name_17.text)) { + seen[name_17.text] = true; + } + else { + return grammarErrorOnNode(name_17, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + } + var initializer = jsxAttr.initializer; + if (initializer && initializer.kind === 237 && !initializer.expression) { + return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); + } + } + } function checkGrammarForInOrForOfStatement(forInOrOfStatement) { if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 202) { + if (forInOrOfStatement.initializer.kind === 209) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 190 + var diagnostic = forInOrOfStatement.kind === 197 ? 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 === 190 + var diagnostic = forInOrOfStatement.kind === 197 ? 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 === 190 + var diagnostic = forInOrOfStatement.kind === 197 ? 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); @@ -20215,10 +21511,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 138 && accessor.parameters.length) { + else if (kind === 142 && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 139) { + else if (kind === 143) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -20230,7 +21526,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); } - else if (parameter.flags & 499) { + else if (parameter.flags & 2035) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } else if (parameter.questionToken) { @@ -20243,17 +21539,17 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 129 && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 133 && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } function checkGrammarMethod(node) { - if (checkGrammarDisallowedModifiersInBlockOrObjectLiteralExpression(node) || + if (checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) || checkGrammarFunctionLikeDeclaration(node) || checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 157) { + if (node.parent.kind === 162) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -20272,22 +21568,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 === 205) { + else if (node.parent.kind === 212) { 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 === 148) { + else if (node.parent.kind === 152) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 189: - case 190: - case 191: - case 187: - case 188: - return true; + case 196: case 197: + case 198: + case 194: + case 195: + return true; + case 204: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -20299,9 +21595,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 197: + case 204: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 192 + var isMisplacedContinueLabel = node.kind === 199 && !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); @@ -20309,8 +21605,8 @@ var ts; return false; } break; - case 196: - if (node.kind === 193 && !node.label) { + case 203: + if (node.kind === 200 && !node.label) { return false; } break; @@ -20323,13 +21619,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 193 + var message = node.kind === 200 ? 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 === 193 + var message = node.kind === 200 ? 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); @@ -20341,7 +21637,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 === 154 || node.name.kind === 153) { + if (node.name.kind === 159 || node.name.kind === 158) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -20350,7 +21646,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 190 && node.parent.parent.kind !== 191) { + if (node.parent.parent.kind !== 197 && node.parent.parent.kind !== 198) { if (ts.isInAmbientContext(node)) { if (node.initializer) { var equalsTokenLength = "=".length; @@ -20370,7 +21666,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 65) { + if (name.kind === 66) { if (name.text === "let") { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } @@ -20379,7 +21675,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 178) { + if (element.kind !== 184) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -20396,15 +21692,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 186: - case 187: - case 188: + case 193: + case 194: case 195: - case 189: - case 190: - case 191: - return false; + case 202: + case 196: case 197: + case 198: + return false; + case 204: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -20420,9 +21716,9 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 170) { + if (expression.kind === 176) { var unaryExpression = expression; - if (unaryExpression.operator === 33 || unaryExpression.operator === 34) { + if (unaryExpression.operator === 34 || unaryExpression.operator === 35) { expression = unaryExpression.operand; } } @@ -20432,14 +21728,14 @@ var ts; return false; } function checkGrammarEnumDeclaration(enumDecl) { - var enumIsConst = (enumDecl.flags & 8192) !== 0; + 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 === 129) { + if (node.name.kind === 133) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else if (inAmbientContext) { @@ -20481,6 +21777,10 @@ var ts; return true; } } + function isEvalOrArgumentsIdentifier(node) { + return node.kind === 66 && + (node.text === "eval" || node.text === "arguments"); + } function checkGrammarConstructorTypeParameters(node) { if (node.typeParameters) { return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); @@ -20498,12 +21798,12 @@ var ts; return true; } } - else if (node.parent.kind === 205) { + else if (node.parent.kind === 212) { 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 === 148) { + else if (node.parent.kind === 152) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -20513,13 +21813,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 205 || - node.kind === 212 || - node.kind === 211 || + if (node.kind === 212 || + node.kind === 219 || node.kind === 218 || - node.kind === 217 || + node.kind === 225 || + node.kind === 224 || (node.flags & 2) || - (node.flags & (1 | 256))) { + (node.flags & (1 | 1024))) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); @@ -20527,7 +21827,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 === 183) { + if (ts.isDeclaration(decl) || decl.kind === 190) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -20546,7 +21846,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 === 182 || node.parent.kind === 209 || node.parent.kind === 230) { + if (node.parent.kind === 189 || node.parent.kind === 216 || node.parent.kind === 245) { 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); @@ -20557,7 +21857,7 @@ var ts; } } function checkGrammarNumericLiteral(node) { - if (node.flags & 16384 && languageVersion >= 1) { + if (node.flags & 65536 && languageVersion >= 1) { return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); } } @@ -20585,7 +21885,6 @@ var ts; function emitDeclarations(host, resolver, diagnostics, jsFilePath, root) { var newLine = host.getNewLine(); var compilerOptions = host.getCompilerOptions(); - var languageVersion = compilerOptions.target || 0; var write; var writeLine; var increaseIndent; @@ -20605,7 +21904,7 @@ var ts; var addedGlobalFileReference = false; ts.forEach(root.referencedFiles, function (fileReference) { var referencedFile = ts.tryResolveScriptReference(host, root, fileReference); - if (referencedFile && ((referencedFile.flags & 2048) || + if (referencedFile && ((referencedFile.flags & 8192) || ts.shouldEmitToOwnFile(referencedFile, compilerOptions) || !addedGlobalFileReference)) { writeReferencePath(referencedFile); @@ -20620,7 +21919,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 212); + ts.Debug.assert(aliasEmitInfo.node.kind === 219); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -20693,10 +21992,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 201) { + if (declaration.kind === 208) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 215 || declaration.kind === 216 || declaration.kind === 213) { + else if (declaration.kind === 222 || declaration.kind === 223 || declaration.kind === 220) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -20707,7 +22006,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 212) { + if (moduleElementEmitInfo.node.kind === 219) { moduleElementEmitInfo.isVisible = true; } else { @@ -20715,12 +22014,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 208) { + if (nodeToCheck.kind === 215) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 208) { + if (nodeToCheck.kind === 215) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -20807,58 +22106,62 @@ var ts; } function emitType(type) { switch (type.kind) { - case 112: - case 123: - case 121: - case 113: - case 124: - case 99: + case 114: + case 127: + case 125: + case 117: + case 128: + case 100: case 8: return writeTextOfNode(currentSourceFile, type); - case 179: + case 185: return emitExpressionWithTypeArguments(type); - case 144: - return emitTypeReference(type); - case 147: - return emitTypeQuery(type); - case 149: - return emitArrayType(type); - case 150: - return emitTupleType(type); - case 151: - return emitUnionType(type); - case 152: - return emitParenType(type); - case 145: - case 146: - return emitSignatureDeclarationWithJsDocComments(type); case 148: + return emitTypeReference(type); + case 151: + return emitTypeQuery(type); + case 153: + return emitArrayType(type); + case 154: + return emitTupleType(type); + case 155: + return emitUnionType(type); + case 156: + return emitIntersectionType(type); + case 157: + return emitParenType(type); + case 149: + case 150: + return emitSignatureDeclarationWithJsDocComments(type); + case 152: return emitTypeLiteral(type); - case 65: + case 66: return emitEntityName(type); - case 128: + case 132: return emitEntityName(type); + case 147: + return emitTypePredicate(type); + } + function writeEntityName(entityName) { + if (entityName.kind === 66) { + writeTextOfNode(currentSourceFile, entityName); + } + else { + var left = entityName.kind === 132 ? entityName.left : entityName.expression; + var right = entityName.kind === 132 ? entityName.right : entityName.name; + writeEntityName(left); + write("."); + writeTextOfNode(currentSourceFile, right); + } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 211 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 218 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); - function writeEntityName(entityName) { - if (entityName.kind === 65) { - writeTextOfNode(currentSourceFile, entityName); - } - else { - var left = entityName.kind === 128 ? entityName.left : entityName.expression; - var right = entityName.kind === 128 ? entityName.right : entityName.name; - writeEntityName(left); - write("."); - writeTextOfNode(currentSourceFile, right); - } - } } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 65 || node.expression.kind === 158); + ts.Debug.assert(node.expression.kind === 66 || node.expression.kind === 163); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -20875,6 +22178,11 @@ var ts; write(">"); } } + function emitTypePredicate(type) { + writeTextOfNode(currentSourceFile, type.parameterName); + write(" is "); + emitType(type.type); + } function emitTypeQuery(type) { write("typeof "); emitEntityName(type.exprName); @@ -20891,6 +22199,9 @@ var ts; function emitUnionType(type) { emitSeparatedList(type.types, " | ", emitType); } + function emitIntersectionType(type) { + emitSeparatedList(type.types, " & ", emitType); + } function emitParenType(type) { write("("); emitType(type.type); @@ -20919,14 +22230,14 @@ var ts; } var count = 0; while (true) { - var name_16 = baseName + "_" + (++count); - if (!ts.hasProperty(currentSourceFile.identifiers, name_16)) { - return name_16; + var name_18 = baseName + "_" + (++count); + if (!ts.hasProperty(currentSourceFile.identifiers, name_18)) { + return name_18; } } } function emitExportAssignment(node) { - if (node.expression.kind === 65) { + if (node.expression.kind === 66) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentSourceFile, node.expression); } @@ -20944,7 +22255,7 @@ var ts; } write(";"); writeLine(); - if (node.expression.kind === 65) { + if (node.expression.kind === 66) { var nodes = resolver.collectLinkedAliases(node.expression); writeAsynchronousModuleElements(nodes); } @@ -20962,10 +22273,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 211 || - (node.parent.kind === 230 && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 218 || + (node.parent.kind === 245 && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 230) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 245) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -20974,7 +22285,7 @@ var ts; }); } else { - if (node.kind === 212) { + if (node.kind === 219) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -20992,23 +22303,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 203: + case 210: return writeFunctionDeclaration(node); - case 183: + case 190: return writeVariableStatement(node); - case 205: - return writeInterfaceDeclaration(node); - case 204: - return writeClassDeclaration(node); - case 206: - return writeTypeAliasDeclaration(node); - case 207: - return writeEnumDeclaration(node); - case 208: - return writeModuleDeclaration(node); - case 211: - return writeImportEqualsDeclaration(node); case 212: + return writeInterfaceDeclaration(node); + case 211: + return writeClassDeclaration(node); + case 213: + return writeTypeAliasDeclaration(node); + case 214: + return writeEnumDeclaration(node); + case 215: + return writeModuleDeclaration(node); + case 218: + return writeImportEqualsDeclaration(node); + case 219: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -21019,10 +22330,10 @@ var ts; if (node.flags & 1) { write("export "); } - if (node.flags & 256) { + if (node.flags & 1024) { write("default "); } - else if (node.kind !== 205) { + else if (node.kind !== 212) { write("declare "); } } @@ -21037,6 +22348,9 @@ var ts; if (node.flags & 128) { write("static "); } + if (node.flags & 256) { + write("abstract "); + } } function writeImportEqualsDeclaration(node) { emitJsDocComments(node); @@ -21066,7 +22380,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 214) { + if (namedBindings.kind === 221) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -21092,7 +22406,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 214) { + if (node.importClause.namedBindings.kind === 221) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -21141,14 +22455,14 @@ var ts; function writeModuleDeclaration(node) { emitJsDocComments(node); emitModuleElementDeclarationFlags(node); - if (node.flags & 32768) { + if (node.flags & 131072) { write("namespace "); } else { write("module "); } writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 209) { + while (node.body.kind !== 216) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -21209,7 +22523,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 136 && (node.parent.flags & 32); + return node.parent.kind === 140 && (node.parent.flags & 32); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -21219,15 +22533,15 @@ var ts; writeTextOfNode(currentSourceFile, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 145 || - node.parent.kind === 146 || - (node.parent.parent && node.parent.parent.kind === 148)) { - ts.Debug.assert(node.parent.kind === 136 || - node.parent.kind === 135 || - node.parent.kind === 145 || - node.parent.kind === 146 || - node.parent.kind === 140 || - node.parent.kind === 141); + if (node.parent.kind === 149 || + node.parent.kind === 150 || + (node.parent.parent && node.parent.parent.kind === 152)) { + ts.Debug.assert(node.parent.kind === 140 || + node.parent.kind === 139 || + node.parent.kind === 149 || + node.parent.kind === 150 || + node.parent.kind === 144 || + node.parent.kind === 145); emitType(node.constraint); } else { @@ -21237,31 +22551,31 @@ var ts; function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 204: + case 211: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 205: + case 212: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 141: + case 145: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 140: + case 144: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 136: - case 135: + case 140: + case 139: 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 === 204) { + else if (node.parent.parent.kind === 211) { 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 203: + case 210: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -21291,7 +22605,7 @@ var ts; } function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.parent.parent.kind === 204) { + if (node.parent.parent.kind === 211) { 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; @@ -21319,6 +22633,9 @@ var ts; } emitJsDocComments(node); emitModuleElementDeclarationFlags(node); + if (node.flags & 256) { + write("abstract "); + } write("class "); writeTextOfNode(currentSourceFile, node.name); var prevEnclosingDeclaration = enclosingDeclaration; @@ -21368,16 +22685,16 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 201 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 208 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentSourceFile, node.name); - if ((node.kind === 134 || node.kind === 133) && ts.hasQuestionToken(node)) { + if ((node.kind === 138 || node.kind === 137) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 134 || node.kind === 133) && node.parent.kind === 148) { + if ((node.kind === 138 || node.kind === 137) && node.parent.kind === 152) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32)) { @@ -21386,14 +22703,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 201) { + if (node.kind === 208) { 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 === 134 || node.kind === 133) { + else if (node.kind === 138 || node.kind === 137) { if (node.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -21401,7 +22718,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 === 204) { + else if (node.parent.kind === 211) { 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 : @@ -21427,7 +22744,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 178) { + if (element.kind !== 184) { elements.push(element); } } @@ -21493,7 +22810,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 138 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 142 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -21506,7 +22823,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 138 + return accessor.kind === 142 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -21515,7 +22832,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 139) { + if (accessorWithTypeAnnotation.kind === 143) { 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 : @@ -21561,17 +22878,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 203) { + if (node.kind === 210) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 136) { + else if (node.kind === 140) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 203) { + if (node.kind === 210) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 137) { + else if (node.kind === 141) { write("constructor"); } else { @@ -21588,11 +22905,11 @@ var ts; emitSignatureDeclaration(node); } function emitSignatureDeclaration(node) { - if (node.kind === 141 || node.kind === 146) { + if (node.kind === 145 || node.kind === 150) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 142) { + if (node.kind === 146) { write("["); } else { @@ -21601,20 +22918,20 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 142) { + if (node.kind === 146) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 145 || node.kind === 146; - if (isFunctionTypeOrConstructorType || node.parent.kind === 148) { + var isFunctionTypeOrConstructorType = node.kind === 149 || node.kind === 150; + if (isFunctionTypeOrConstructorType || node.parent.kind === 152) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 137 && !(node.flags & 32)) { + else if (node.kind !== 141 && !(node.flags & 32)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -21625,23 +22942,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 141: + case 145: 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 140: + case 144: 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 142: + case 146: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 136: - case 135: + case 140: + case 139: if (node.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -21649,7 +22966,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 === 204) { + else if (node.parent.kind === 211) { 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 : @@ -21662,7 +22979,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 203: + case 210: 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 : @@ -21694,9 +23011,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 145 || - node.parent.kind === 146 || - node.parent.parent.kind === 148) { + if (node.parent.kind === 149 || + node.parent.kind === 150 || + node.parent.parent.kind === 152) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32)) { @@ -21712,22 +23029,22 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 137: + case 141: 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 141: + case 145: 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 140: + case 144: return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 136: - case 135: + case 140: + case 139: if (node.parent.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -21735,7 +23052,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 === 204) { + else if (node.parent.parent.kind === 211) { 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 : @@ -21747,7 +23064,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 203: + case 210: 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 : @@ -21758,12 +23075,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 153) { + if (bindingPattern.kind === 158) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 154) { + else if (bindingPattern.kind === 159) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -21782,10 +23099,10 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 178) { + if (bindingElement.kind === 184) { write(" "); } - else if (bindingElement.kind === 155) { + else if (bindingElement.kind === 160) { if (bindingElement.propertyName) { writeTextOfNode(currentSourceFile, bindingElement.propertyName); write(": "); @@ -21796,7 +23113,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 65); + ts.Debug.assert(bindingElement.name.kind === 66); if (bindingElement.dotDotDotToken) { write("..."); } @@ -21808,44 +23125,44 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 203: - case 208: - case 211: - case 205: - case 204: - case 206: - case 207: - return emitModuleElement(node, isModuleElementVisible(node)); - case 183: - return emitModuleElement(node, isVariableStatementVisible(node)); - case 212: - return emitModuleElement(node, !node.importClause); + case 210: + case 215: case 218: + case 212: + case 211: + case 213: + case 214: + return emitModuleElement(node, isModuleElementVisible(node)); + case 190: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 219: + return emitModuleElement(node, !node.importClause); + case 225: return emitExportDeclaration(node); - case 137: - case 136: - case 135: - return writeFunctionDeclaration(node); case 141: case 140: - case 142: - return emitSignatureDeclarationWithJsDocComments(node); - case 138: case 139: + return writeFunctionDeclaration(node); + case 145: + case 144: + case 146: + return emitSignatureDeclarationWithJsDocComments(node); + case 142: + case 143: return emitAccessorDeclaration(node); - case 134: - case 133: + case 138: + case 137: return emitPropertyDeclaration(node); - case 229: + case 244: return emitEnumMemberDeclaration(node); - case 217: + case 224: return emitExportAssignment(node); - case 230: + case 245: return emitSourceFile(node); } } function writeReferencePath(referencedFile) { - var declFileName = referencedFile.flags & 2048 + var declFileName = referencedFile.flags & 8192 ? referencedFile.fileName : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") @@ -21890,15 +23207,18 @@ var ts; 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, ".js"); + var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js"); emitFile(jsFilePath, sourceFile); } }); @@ -21908,7 +23228,7 @@ var ts; } else { if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ts.forEach(host.getSourceFiles(), shouldEmitJsx) ? ".jsx" : ".js"); emitFile(jsFilePath, targetSourceFile); } else if (!ts.isDeclarationFile(targetSourceFile) && compilerOptions.out) { @@ -21954,6 +23274,7 @@ var ts; var extendsEmitted = false; var decorateEmitted = false; var paramEmitted = false; + var awaiterEmitted = false; var tempFlags = 0; var tempVariables; var tempParameters; @@ -21999,19 +23320,19 @@ var ts; } function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name)) { + var name_19 = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name_19)) { tempFlags |= flags; - return name; + return name_19; } } while (true) { var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_17 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_17)) { - return name_17; + var name_20 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); + if (isUniqueName(name_20)) { + return name_20; } } } @@ -22047,19 +23368,19 @@ var ts; } function generateNameForNode(node) { switch (node.kind) { - case 65: + case 66: return makeUniqueName(node.text); - case 208: - case 207: + case 215: + case 214: return generateNameForModuleOrEnum(node); - case 212: - case 218: + case 219: + case 225: return generateNameForImportOrExportDeclaration(node); - case 203: - case 204: - case 217: + case 210: + case 211: + case 224: return generateNameForExportDefault(); - case 177: + case 183: return generateNameForClassExpression(); } } @@ -22197,8 +23518,8 @@ var ts; if (scopeName) { var parentIndex = getSourceMapNameIndex(); if (parentIndex !== -1) { - var name_18 = node.name; - if (!name_18 || name_18.kind !== 129) { + var name_21 = node.name; + if (!name_21 || name_21.kind !== 133) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -22215,19 +23536,19 @@ var ts; if (scopeName) { recordScopeNameStart(scopeName); } - else if (node.kind === 203 || - node.kind === 165 || - node.kind === 136 || - node.kind === 135 || - node.kind === 138 || + else if (node.kind === 210 || + node.kind === 170 || + node.kind === 140 || node.kind === 139 || - node.kind === 208 || - node.kind === 204 || - node.kind === 207) { + node.kind === 142 || + node.kind === 143 || + node.kind === 215 || + node.kind === 211 || + node.kind === 214) { if (node.name) { - var name_19 = node.name; - scopeName = name_19.kind === 129 - ? ts.getTextOfNode(name_19) + var name_22 = node.name; + scopeName = name_22.kind === 133 + ? ts.getTextOfNode(name_22) : node.name.text; } recordScopeNameStart(scopeName); @@ -22325,7 +23646,7 @@ var ts; if (ts.nodeIsSynthesized(node)) { return emitNodeWithoutSourceMap(node); } - if (node.kind !== 230) { + if (node.kind !== 245) { recordEmitNodeStartSpan(node); emitNodeWithoutSourceMap(node); recordEmitNodeEndSpan(node); @@ -22349,7 +23670,7 @@ var ts; ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); } function createTempVariable(flags) { - var result = ts.createSynthesizedNode(65); + var result = ts.createSynthesizedNode(66); result.text = makeTempVariableName(flags); return result; } @@ -22570,10 +23891,10 @@ var ts; emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); write("("); emit(tempVariable); - if (node.template.kind === 174) { + if (node.template.kind === 180) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 172 + var needsParens = templateSpan.expression.kind === 178 && templateSpan.expression.operatorToken.kind === 23; emitParenthesizedIf(templateSpan.expression, needsParens); }); @@ -22597,7 +23918,7 @@ var ts; } for (var i = 0, n = node.templateSpans.length; i < n; i++) { var templateSpan = node.templateSpans[i]; - var needsParens = templateSpan.expression.kind !== 164 + var needsParens = templateSpan.expression.kind !== 169 && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; if (i > 0 || headEmitted) { write(" + "); @@ -22630,11 +23951,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 160: - case 161: + case 165: + case 166: return parent.expression === template; - case 162: - case 164: + case 167: + case 169: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1; @@ -22642,20 +23963,20 @@ var ts; } function comparePrecedenceToBinaryPlus(expression) { switch (expression.kind) { - case 172: + case 178: switch (expression.operatorToken.kind) { - case 35: case 36: case 37: + case 38: return 1; - case 33: case 34: + case 35: return 0; default: return -1; } - case 175: - case 173: + case 181: + case 179: return -1; default: return 1; @@ -22666,12 +23987,189 @@ var ts; emit(span.expression); emit(span.literal); } + function jsxEmitReact(node) { + function emitTagName(name) { + if (name.kind === 66 && 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) { + emitLeadingComments(openingNode); + write("React.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 === 236; })) { + write("React.__spread("); + var haveOpenedObjectLiteral = false; + for (var i_2 = 0; i_2 < attrs.length; i_2++) { + if (attrs[i_2].kind === 236) { + if (i_2 === 0) { + write("{}, "); + } + if (haveOpenedObjectLiteral) { + write("}"); + haveOpenedObjectLiteral = false; + } + if (i_2 > 0) { + write(", "); + } + emit(attrs[i_2].expression); + } + else { + ts.Debug.assert(attrs[i_2].kind === 235); + if (haveOpenedObjectLiteral) { + write(", "); + } + else { + haveOpenedObjectLiteral = true; + if (i_2 > 0) { + write(", "); + } + write("{"); + } + emitJsxAttribute(attrs[i_2]); + } + } + 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 === 237 && !(children[i].expression)) { + continue; + } + if (children[i].kind === 233) { + var text = getTextToEmit(children[i]); + if (text !== undefined) { + write(', "'); + write(text); + write('"'); + } + } + else { + write(", "); + emit(children[i]); + } + } + } + write(")"); + emitTrailingComments(openingNode); + } + if (node.kind === 230) { + emitJsxElement(node.openingElement, node.children); + } + else { + ts.Debug.assert(node.kind === 231); + emitJsxElement(node); + } + } + function jsxEmitPreserve(node) { + function emitJsxAttribute(node) { + emit(node.name); + 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 === 236) { + emitJsxSpreadAttribute(attribs[i]); + } + else { + ts.Debug.assert(attribs[i].kind === 235); + emitJsxAttribute(attribs[i]); + } + } + } + function emitJsxOpeningOrSelfClosingElement(node) { + write("<"); + emit(node.tagName); + if (node.attributes.length > 0 || (node.kind === 231)) { + write(" "); + } + emitAttributes(node.attributes); + if (node.kind === 231) { + 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 === 230) { + emitJsxElement(node); + } + else { + ts.Debug.assert(node.kind === 231); + emitJsxOpeningOrSelfClosingElement(node); + } + } function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 155); + ts.Debug.assert(node.kind !== 160); if (node.kind === 8) { emitLiteral(node); } - else if (node.kind === 129) { + else if (node.kind === 133) { if (ts.nodeIsDecorated(node.parent)) { if (!computedPropertyNamesToGeneratedNames) { computedPropertyNamesToGeneratedNames = []; @@ -22702,64 +24200,70 @@ var ts; function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 156: + case 161: + case 178: + case 165: + case 238: + case 133: + case 179: + case 136: case 172: - case 160: - case 223: - case 129: - case 173: - case 132: + case 194: + case 164: + case 224: + case 192: + case 185: + case 196: + case 197: + case 198: + case 193: + case 231: + case 232: + case 166: + case 169: + case 177: + case 176: + case 201: + case 243: + case 182: + case 203: case 167: case 187: - case 159: - case 217: - case 185: - case 179: - case 189: - case 190: - case 191: - case 186: - case 161: - case 164: + case 205: + case 168: + case 173: + case 174: + case 195: + case 202: + case 181: + return true; + case 160: + case 244: + case 135: + case 242: + case 138: + case 208: + return parent.initializer === node; + case 163: + return parent.expression === node; case 171: case 170: - case 194: - case 228: - case 176: - case 196: - case 162: - case 180: - case 198: - case 163: - case 168: - case 169: - case 188: - case 195: - case 175: - return true; - case 155: - case 229: - case 131: - case 227: - case 134: - case 201: - return parent.initializer === node; - case 158: - return parent.expression === node; - case 166: - case 165: return parent.body === node; - case 211: + case 218: return parent.moduleReference === node; - case 128: + case 132: 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 === 230) { + if (container.kind === 245) { if (languageVersion < 2 && compilerOptions.module !== 4) { write("exports."); } @@ -22772,12 +24276,12 @@ var ts; else if (languageVersion < 2) { var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { - if (declaration.kind === 213) { + if (declaration.kind === 220) { write(getGeneratedNameForNode(declaration.parent)); write(languageVersion === 0 ? '["default"]' : ".default"); return; } - else if (declaration.kind === 216) { + else if (declaration.kind === 223) { write(getGeneratedNameForNode(declaration.parent.parent.parent)); write("."); writeTextOfNode(currentSourceFile, declaration.propertyName || declaration.name); @@ -22796,10 +24300,10 @@ var ts; if (languageVersion < 2) { var parent_7 = node.parent; switch (parent_7.kind) { - case 155: - case 204: - case 207: - case 201: + case 160: + case 211: + case 214: + case 208: return parent_7.name === node && resolver.isNestedRedeclaration(parent_7); } } @@ -22833,7 +24337,7 @@ var ts; } else { var flags = resolver.getNodeCheckFlags(node); - if (flags & 16) { + if (flags & 256) { write("_super.prototype"); } else { @@ -22874,7 +24378,7 @@ var ts; emit(node.expression); } function emitYieldExpression(node) { - write(ts.tokenToString(110)); + write(ts.tokenToString(111)); if (node.asteriskToken) { write("*"); } @@ -22883,14 +24387,35 @@ var ts; emit(node.expression); } } + function emitAwaitExpression(node) { + var needsParenthesis = needsParenthesisForAwaitExpressionAsYield(node); + if (needsParenthesis) { + write("("); + } + write(ts.tokenToString(111)); + write(" "); + emit(node.expression); + if (needsParenthesis) { + write(")"); + } + } + function needsParenthesisForAwaitExpressionAsYield(node) { + if (node.parent.kind === 178 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + return true; + } + else if (node.parent.kind === 179 && node.parent.condition === node) { + return true; + } + return false; + } function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { - case 65: - case 156: - case 158: - case 159: - case 160: + case 66: + case 161: + case 163: case 164: + case 165: + case 169: return false; } return true; @@ -22907,17 +24432,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 176) { + if (e.kind === 182) { e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 156) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 161) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 176) { + while (i < length && elements[i].kind !== 182) { i++; } write("["); @@ -22940,7 +24465,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 176; + return node.kind === 182; } function emitArrayLiteral(node) { var elements = node.elements; @@ -22953,7 +24478,7 @@ var ts; write("]"); } else { - emitListWithSpread(elements, true, (node.flags & 512) !== 0, elements.hasTrailingComma, true); + emitListWithSpread(elements, true, (node.flags & 2048) !== 0, elements.hasTrailingComma, true); } } function emitObjectLiteralBody(node, numElements) { @@ -22968,7 +24493,7 @@ var ts; emitLinePreservingList(node, properties, languageVersion >= 1, true); } else { - var multiLine = (node.flags & 512) !== 0; + var multiLine = (node.flags & 2048) !== 0; if (!multiLine) { write(" "); } @@ -22987,7 +24512,7 @@ var ts; write("}"); } function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { - var multiLine = (node.flags & 512) !== 0; + var multiLine = (node.flags & 2048) !== 0; var properties = node.properties; write("("); if (multiLine) { @@ -23001,7 +24526,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 138 || property.kind === 139) { + if (property.kind === 142 || property.kind === 143) { var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { continue; @@ -23052,13 +24577,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 227) { + if (property.kind === 242) { emit(property.initializer); } - else if (property.kind === 228) { + else if (property.kind === 243) { emitExpressionIdentifier(property.name); } - else if (property.kind === 136) { + else if (property.kind === 140) { emitFunctionDeclaration(property); } else { @@ -23090,7 +24615,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 === 129) { + if (properties[i].name.kind === 133) { numInitialNonComputedProperties = i; break; } @@ -23104,35 +24629,35 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(172, startsOnNewLine); + var result = ts.createSynthesizedNode(178, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(158); + var result = ts.createSynthesizedNode(163); result.expression = parenthesizeForAccess(expression); result.dotToken = ts.createSynthesizedNode(20); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(159); + var result = ts.createSynthesizedNode(164); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; } function parenthesizeForAccess(expr) { - while (expr.kind === 163) { + while (expr.kind === 168 || expr.kind === 186) { expr = expr.expression; } if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 161 && + expr.kind !== 166 && expr.kind !== 7) { return expr; } - var node = ts.createSynthesizedNode(164); + var node = ts.createSynthesizedNode(169); node.expression = expr; return node; } @@ -23158,7 +24683,7 @@ var ts; } function isNamespaceExportReference(node) { var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 230; + return container && container.kind !== 245; } function emitShorthandPropertyAssignment(node) { writeTextOfNode(currentSourceFile, node.name); @@ -23175,7 +24700,7 @@ var ts; if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 158 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 163 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; @@ -23203,7 +24728,17 @@ var ts; } emit(node.expression); var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); - write("."); + var shouldEmitSpace; + if (!indentedBeforeDot && node.expression.kind === 7) { + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); + shouldEmitSpace = text.indexOf(ts.tokenToString(20)) < 0; + } + if (shouldEmitSpace) { + write(" ."); + } + else { + write("."); + } var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); emit(node.name); decreaseIndentIf(indentedBeforeDot, indentedAfterDot); @@ -23213,6 +24748,40 @@ var ts; write("."); emit(node.right); } + function emitQualifiedNameAsExpression(node, useFallback) { + if (node.left.kind === 66) { + 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("."); + emitNodeWithoutSourceMap(node.right); + } + function emitEntityNameAsExpression(node, useFallback) { + switch (node.kind) { + case 66: + if (useFallback) { + write("typeof "); + emitExpressionIdentifier(node); + write(" !== 'undefined' && "); + } + emitExpressionIdentifier(node); + break; + case 132: + emitQualifiedNameAsExpression(node, useFallback); + break; + } + } function emitIndexedAccess(node) { if (tryEmitConstantValue(node)) { return; @@ -23223,16 +24792,16 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 176; }); + return ts.forEach(elements, function (e) { return e.kind === 182; }); } function skipParentheses(node) { - while (node.kind === 164 || node.kind === 163) { + while (node.kind === 169 || node.kind === 168 || node.kind === 186) { node = node.expression; } return node; } function emitCallTarget(node) { - if (node.kind === 65 || node.kind === 93 || node.kind === 91) { + if (node.kind === 66 || node.kind === 94 || node.kind === 92) { emit(node); return node; } @@ -23247,18 +24816,18 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 158) { + if (expr.kind === 163) { target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 159) { + else if (expr.kind === 164) { target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); write("]"); } - else if (expr.kind === 91) { + else if (expr.kind === 92) { target = expr; write("_super"); } @@ -23267,7 +24836,7 @@ var ts; } write(".apply("); if (target) { - if (target.kind === 91) { + if (target.kind === 92) { emitThis(target); } else { @@ -23287,13 +24856,13 @@ var ts; return; } var superCall = false; - if (node.expression.kind === 91) { + if (node.expression.kind === 92) { emitSuper(node.expression); superCall = true; } else { emit(node.expression); - superCall = node.expression.kind === 158 && node.expression.expression.kind === 91; + superCall = node.expression.kind === 163 && node.expression.expression.kind === 92; } if (superCall && languageVersion < 2) { write(".call("); @@ -23344,20 +24913,20 @@ var ts; } } function emitParenExpression(node) { - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 166) { - if (node.expression.kind === 163) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 171) { + if (node.expression.kind === 168 || node.expression.kind === 186) { var operand = node.expression.expression; - while (operand.kind === 163) { + while (operand.kind === 168 || operand.kind === 186) { operand = operand.expression; } - if (operand.kind !== 170 && - operand.kind !== 169 && - operand.kind !== 168 && - operand.kind !== 167 && - operand.kind !== 171 && - operand.kind !== 161 && - !(operand.kind === 160 && node.parent.kind === 161) && - !(operand.kind === 165 && node.parent.kind === 160)) { + if (operand.kind !== 176 && + operand.kind !== 174 && + operand.kind !== 173 && + operand.kind !== 172 && + operand.kind !== 177 && + operand.kind !== 166 && + !(operand.kind === 165 && node.parent.kind === 166) && + !(operand.kind === 170 && node.parent.kind === 165)) { emit(operand); return; } @@ -23368,25 +24937,25 @@ var ts; write(")"); } function emitDeleteExpression(node) { - write(ts.tokenToString(74)); + write(ts.tokenToString(75)); write(" "); emit(node.expression); } function emitVoidExpression(node) { - write(ts.tokenToString(99)); + write(ts.tokenToString(100)); write(" "); emit(node.expression); } function emitTypeOfExpression(node) { - write(ts.tokenToString(97)); + write(ts.tokenToString(98)); write(" "); emit(node.expression); } function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { - if (!isCurrentFileSystemExternalModule() || node.kind !== 65 || ts.nodeIsSynthesized(node)) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 66 || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 201 || node.parent.kind === 155); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 208 || node.parent.kind === 160); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); @@ -23400,12 +24969,12 @@ var ts; write("\", "); } write(ts.tokenToString(node.operator)); - if (node.operand.kind === 170) { + if (node.operand.kind === 176) { var operand = node.operand; - if (node.operator === 33 && (operand.operator === 33 || operand.operator === 38)) { + if (node.operator === 34 && (operand.operator === 34 || operand.operator === 39)) { write(" "); } - else if (node.operator === 34 && (operand.operator === 34 || operand.operator === 39)) { + else if (node.operator === 35 && (operand.operator === 35 || operand.operator === 40)) { write(" "); } } @@ -23422,7 +24991,7 @@ var ts; write("\", "); write(ts.tokenToString(node.operator)); emit(node.operand); - if (node.operator === 38) { + if (node.operator === 39) { write(") - 1)"); } else { @@ -23443,10 +25012,10 @@ var ts; } var current = node; while (current) { - if (current.kind === 230) { + if (current.kind === 245) { return !isExported || ((ts.getCombinedNodeFlags(node) & 1) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 209) { + else if (ts.isFunctionLike(current) || current.kind === 216) { return false; } else { @@ -23455,13 +25024,13 @@ var ts; } } function emitBinaryExpression(node) { - if (languageVersion < 2 && node.operatorToken.kind === 53 && - (node.left.kind === 157 || node.left.kind === 156)) { - emitDestructuring(node, node.parent.kind === 185); + if (languageVersion < 2 && node.operatorToken.kind === 54 && + (node.left.kind === 162 || node.left.kind === 161)) { + emitDestructuring(node, node.parent.kind === 192); } else { - var exportChanged = node.operatorToken.kind >= 53 && - node.operatorToken.kind <= 64 && + var exportChanged = node.operatorToken.kind >= 54 && + node.operatorToken.kind <= 65 && isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); if (exportChanged) { write(exportFunctionForFile + "(\""); @@ -23504,7 +25073,7 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 182) { + if (node && node.kind === 189) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } @@ -23519,12 +25088,12 @@ var ts; emitToken(14, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 209) { - ts.Debug.assert(node.parent.kind === 208); + if (node.kind === 216) { + ts.Debug.assert(node.parent.kind === 215); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 209) { + if (node.kind === 216) { emitTempDeclarations(true); } decreaseIndent(); @@ -23533,7 +25102,7 @@ var ts; scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 182) { + if (node.kind === 189) { write(" "); emit(node); } @@ -23545,11 +25114,11 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 166); + emitParenthesizedIf(node.expression, node.expression.kind === 171); write(";"); } function emitIfStatement(node) { - var endPos = emitToken(84, node.pos); + var endPos = emitToken(85, node.pos); write(" "); endPos = emitToken(16, endPos); emit(node.expression); @@ -23557,8 +25126,8 @@ var ts; emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - emitToken(76, node.thenStatement.end); - if (node.elseStatement.kind === 186) { + emitToken(77, node.thenStatement.end); + if (node.elseStatement.kind === 193) { write(" "); emit(node.elseStatement); } @@ -23570,7 +25139,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 182) { + if (node.statement.kind === 189) { write(" "); } else { @@ -23590,13 +25159,13 @@ var ts; if (shouldHoistVariable(decl, true)) { return false; } - var tokenKind = 98; + var tokenKind = 99; if (decl && languageVersion >= 2) { if (ts.isLet(decl)) { - tokenKind = 104; + tokenKind = 105; } else if (ts.isConst(decl)) { - tokenKind = 70; + tokenKind = 71; } } if (startPos !== undefined) { @@ -23605,13 +25174,13 @@ var ts; } else { switch (tokenKind) { - case 98: + case 99: write("var "); break; - case 104: + case 105: write("let "); break; - case 70: + case 71: write("const "); break; } @@ -23636,10 +25205,10 @@ var ts; return started; } function emitForStatement(node) { - var endPos = emitToken(82, node.pos); + var endPos = emitToken(83, node.pos); write(" "); endPos = emitToken(16, endPos); - if (node.initializer && node.initializer.kind === 202) { + if (node.initializer && node.initializer.kind === 209) { var variableDeclarationList = node.initializer; var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); if (startIsEmitted) { @@ -23660,13 +25229,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 && node.kind === 191) { + if (languageVersion < 2 && node.kind === 198) { return emitDownLevelForOfStatement(node); } - var endPos = emitToken(82, node.pos); + var endPos = emitToken(83, node.pos); write(" "); endPos = emitToken(16, endPos); - if (node.initializer.kind === 202) { + if (node.initializer.kind === 209) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); @@ -23676,7 +25245,7 @@ var ts; else { emit(node.initializer); } - if (node.kind === 190) { + if (node.kind === 197) { write(" in "); } else { @@ -23707,10 +25276,10 @@ var ts; // 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(82, node.pos); + var endPos = emitToken(83, node.pos); write(" "); endPos = emitToken(16, endPos); - var rhsIsIdentifier = node.expression.kind === 65; + var rhsIsIdentifier = node.expression.kind === 66; var counter = createTempVariable(268435456); var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0); emitStart(node.expression); @@ -23744,7 +25313,7 @@ var ts; increaseIndent(); var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 202) { + if (node.initializer.kind === 209) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -23765,8 +25334,8 @@ var ts; } } else { - var assignmentExpression = createBinaryExpression(node.initializer, 53, rhsIterationValue, false); - if (node.initializer.kind === 156 || node.initializer.kind === 157) { + var assignmentExpression = createBinaryExpression(node.initializer, 54, rhsIterationValue, false); + if (node.initializer.kind === 161 || node.initializer.kind === 162) { emitDestructuring(assignmentExpression, true, undefined); } else { @@ -23775,7 +25344,7 @@ var ts; } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 182) { + if (node.statement.kind === 189) { emitLines(node.statement.statements); } else { @@ -23787,12 +25356,12 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 193 ? 66 : 71, node.pos); + emitToken(node.kind === 200 ? 67 : 72, node.pos); emitOptional(" ", node.label); write(";"); } function emitReturnStatement(node) { - emitToken(90, node.pos); + emitToken(91, node.pos); emitOptional(" ", node.expression); write(";"); } @@ -23803,7 +25372,7 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var endPos = emitToken(92, node.pos); + var endPos = emitToken(93, node.pos); write(" "); emitToken(16, endPos); emit(node.expression); @@ -23832,7 +25401,7 @@ var ts; ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 223) { + if (node.kind === 238) { write("case "); emit(node.expression); write(":"); @@ -23867,7 +25436,7 @@ var ts; } function emitCatchClause(node) { writeLine(); - var endPos = emitToken(68, node.pos); + var endPos = emitToken(69, node.pos); write(" "); emitToken(16, endPos); emit(node.variableDeclaration); @@ -23876,7 +25445,7 @@ var ts; emitBlock(node.block); } function emitDebuggerStatement(node) { - emitToken(72, node.pos); + emitToken(73, node.pos); write(";"); } function emitLabelledStatement(node) { @@ -23887,7 +25456,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 208); + } while (node && node.kind !== 215); return node; } function emitContainingModuleName(node) { @@ -23912,7 +25481,7 @@ var ts; function createVoidZero() { var zero = ts.createSynthesizedNode(7); zero.text = "0"; - var result = ts.createSynthesizedNode(169); + var result = ts.createSynthesizedNode(174); result.expression = zero; return result; } @@ -23922,7 +25491,7 @@ var ts; emitStart(node); if (compilerOptions.module === 4 && node.parent === currentSourceFile) { write(exportFunctionForFile + "(\""); - if (node.flags & 256) { + if (node.flags & 1024) { write("default"); } else { @@ -23933,7 +25502,7 @@ var ts; write(")"); } else { - if (node.flags & 256) { + if (node.flags & 1024) { if (languageVersion === 0) { write("exports[\"default\"]"); } @@ -23981,15 +25550,15 @@ var ts; function emitDestructuring(root, isAssignmentExpressionStatement, value) { var emitCount = 0; var canDefineTempVariablesInPlace = false; - if (root.kind === 201) { + if (root.kind === 208) { var isExported = ts.getCombinedNodeFlags(root) & 1; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 131) { + else if (root.kind === 135) { canDefineTempVariablesInPlace = true; } - if (root.kind === 172) { + if (root.kind === 178) { emitAssignmentExpression(root); } else { @@ -24000,7 +25569,7 @@ var ts; if (emitCount++) { write(", "); } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 201 || name.parent.kind === 155); + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 208 || name.parent.kind === 160); var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); if (exportChanged) { write(exportFunctionForFile + "(\""); @@ -24020,7 +25589,7 @@ var ts; } } function ensureIdentifier(expr) { - if (expr.kind !== 65) { + if (expr.kind !== 66) { var identifier = createTempVariable(0); if (!canDefineTempVariablesInPlace) { recordTempDeclaration(identifier); @@ -24032,18 +25601,18 @@ var ts; } function createDefaultValueCheck(value, defaultValue) { value = ensureIdentifier(value); - var equals = ts.createSynthesizedNode(172); + var equals = ts.createSynthesizedNode(178); equals.left = value; - equals.operatorToken = ts.createSynthesizedNode(30); + equals.operatorToken = ts.createSynthesizedNode(31); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(173); + var cond = ts.createSynthesizedNode(179); cond.condition = condition; - cond.questionToken = ts.createSynthesizedNode(50); + cond.questionToken = ts.createSynthesizedNode(51); cond.whenTrue = whenTrue; - cond.colonToken = ts.createSynthesizedNode(51); + cond.colonToken = ts.createSynthesizedNode(52); cond.whenFalse = whenFalse; return cond; } @@ -24055,14 +25624,14 @@ var ts; function createPropertyAccessForDestructuringProperty(object, propName) { var syntheticName = ts.createSynthesizedNode(propName.kind); syntheticName.text = propName.text; - if (syntheticName.kind !== 65) { + if (syntheticName.kind !== 66) { return createElementAccessExpression(object, syntheticName); } return createPropertyAccessExpression(object, syntheticName); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(160); - var sliceIdentifier = ts.createSynthesizedNode(65); + var call = ts.createSynthesizedNode(165); + var sliceIdentifier = ts.createSynthesizedNode(66); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); call.arguments = ts.createSynthesizedNodeArray(); @@ -24076,7 +25645,7 @@ var ts; } for (var _a = 0; _a < properties.length; _a++) { var p = properties[_a]; - if (p.kind === 227 || p.kind === 228) { + if (p.kind === 242 || p.kind === 243) { var propName = p.name; emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); } @@ -24089,8 +25658,8 @@ var ts; } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 178) { - if (e.kind !== 176) { + if (e.kind !== 184) { + if (e.kind !== 182) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); } else if (i === elements.length - 1) { @@ -24100,14 +25669,14 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 172 && target.operatorToken.kind === 53) { + if (target.kind === 178 && target.operatorToken.kind === 54) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 157) { + if (target.kind === 162) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 156) { + else if (target.kind === 161) { emitArrayLiteralAssignment(target, value); } else { @@ -24121,14 +25690,14 @@ var ts; emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 164) { + if (root.parent.kind !== 169) { write("("); } value = ensureIdentifier(value); emitDestructuringAssignment(target, value); write(", "); emit(value); - if (root.parent.kind !== 164) { + if (root.parent.kind !== 169) { write(")"); } } @@ -24148,11 +25717,11 @@ var ts; } for (var i = 0; i < elements.length; i++) { var element = elements[i]; - if (pattern.kind === 153) { + if (pattern.kind === 158) { var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } - else if (element.kind !== 178) { + else if (element.kind !== 184) { if (!element.dotDotDotToken) { emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); } @@ -24180,11 +25749,11 @@ var ts; else { var initializer = node.initializer; if (!initializer && languageVersion < 2) { - var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 256) && - (getCombinedFlagsForIdentifier(node.name) & 4096); + var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 16384) && + (getCombinedFlagsForIdentifier(node.name) & 16384); if (isUninitializedLet && - node.parent.parent.kind !== 190 && - node.parent.parent.kind !== 191) { + node.parent.parent.kind !== 197 && + node.parent.parent.kind !== 198) { initializer = createVoidZero(); } } @@ -24202,11 +25771,11 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 178) { + if (node.kind === 184) { return; } var name = node.name; - if (name.kind === 65) { + if (name.kind === 66) { emitExportMemberAssignments(name); } else if (ts.isBindingPattern(name)) { @@ -24214,7 +25783,7 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 201 && node.parent.kind !== 155)) { + if (!node.parent || (node.parent.kind !== 208 && node.parent.kind !== 160)) { return 0; } return ts.getCombinedNodeFlags(node.parent); @@ -24222,7 +25791,7 @@ var ts; function isES6ExportedDeclaration(node) { return !!(node.flags & 1) && languageVersion >= 2 && - node.parent.kind === 230; + node.parent.kind === 245; } function emitVariableStatement(node) { var startIsEmitted = false; @@ -24267,12 +25836,12 @@ var ts; function emitParameter(node) { if (languageVersion < 2) { if (ts.isBindingPattern(node.name)) { - var name_20 = createTempVariable(0); + var name_23 = createTempVariable(0); if (!tempParameters) { tempParameters = []; } - tempParameters.push(name_20); - emit(name_20); + tempParameters.push(name_23); + emit(name_23); } else { emit(node.name); @@ -24289,30 +25858,41 @@ var ts; function emitDefaultValueAssignments(node) { if (languageVersion < 2) { var tempIndex = 0; - ts.forEach(node.parameters, function (p) { - if (p.dotDotDotToken) { + ts.forEach(node.parameters, function (parameter) { + if (parameter.dotDotDotToken) { return; } - if (ts.isBindingPattern(p.name)) { - writeLine(); - write("var "); - emitDestructuring(p, false, tempParameters[tempIndex]); - write(";"); - tempIndex++; + 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 (p.initializer) { + else if (initializer) { writeLine(); - emitStart(p); + emitStart(parameter); write("if ("); - emitNodeWithoutSourceMap(p.name); + emitNodeWithoutSourceMap(paramName); write(" === void 0)"); - emitEnd(p); + emitEnd(parameter); write(" { "); - emitStart(p); - emitNodeWithoutSourceMap(p.name); + emitStart(parameter); + emitNodeWithoutSourceMap(paramName); write(" = "); - emitNodeWithoutSourceMap(p.initializer); - emitEnd(p); + emitNodeWithoutSourceMap(initializer); + emitEnd(parameter); write("; }"); } }); @@ -24360,12 +25940,12 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 138 ? "get " : "set "); + write(node.kind === 142 ? "get " : "set "); emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 166 && languageVersion >= 2; + return node.kind === 171 && languageVersion >= 2; } function emitDeclarationName(node) { if (node.name) { @@ -24376,10 +25956,10 @@ var ts; } } function shouldEmitFunctionName(node) { - if (node.kind === 165) { + if (node.kind === 170) { return !!node.name; } - if (node.kind === 203) { + if (node.kind === 210) { return !!node.name || languageVersion < 2; } } @@ -24387,13 +25967,13 @@ var ts; if (ts.nodeIsMissing(node.body)) { return emitOnlyPinnedOrTripleSlashComments(node); } - if (node.kind !== 136 && node.kind !== 135) { + if (node.kind !== 140 && node.kind !== 139) { emitLeadingComments(node); } if (!shouldEmitAsArrowFunction(node)) { if (isES6ExportedDeclaration(node)) { write("export "); - if (node.flags & 256) { + if (node.flags & 1024) { write("default "); } } @@ -24407,10 +25987,10 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 && node.kind === 203 && node.parent === currentSourceFile && node.name) { + if (languageVersion < 2 && node.kind === 210 && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - if (node.kind !== 136 && node.kind !== 135) { + if (node.kind !== 140 && node.kind !== 139) { emitTrailingComments(node); } } @@ -24440,6 +26020,59 @@ var ts; } emitSignatureParameters(node); } + function emitAsyncFunctionBodyForES6(node) { + var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); + var isArrowFunction = node.kind === 171; + 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 === 189) { + emitBlockFunctionBody(node, node.body); + } + else { + emitExpressionFunctionBody(node, node.body); + } + } + } function emitSignatureAndBody(node) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; @@ -24454,14 +26087,12 @@ var ts; else { emitSignatureParameters(node); } - if (!node.body) { - write(" { }"); - } - else if (node.body.kind === 182) { - emitBlockFunctionBody(node, node.body); + var isAsync = ts.isAsyncFunctionLike(node); + if (isAsync && languageVersion === 2) { + emitAsyncFunctionBodyForES6(node); } else { - emitExpressionFunctionBody(node, node.body); + emitFunctionBody(node); } if (!isES6ExportedDeclaration(node)) { emitExportMemberAssignment(node); @@ -24476,16 +26107,16 @@ var ts; emitRestParameter(node); } function emitExpressionFunctionBody(node, body) { - if (languageVersion < 2) { + if (languageVersion < 2 || node.flags & 512) { emitDownLevelExpressionFunctionBody(node, body); return; } write(" "); var current = body; - while (current.kind === 163) { + while (current.kind === 168) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 157); + emitParenthesizedIf(body, current.kind === 162); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -24557,11 +26188,11 @@ var ts; function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 185) { + if (statement && statement.kind === 192) { var expr = statement.expression; - if (expr && expr.kind === 160) { + if (expr && expr.kind === 165) { var func = expr.expression; - if (func && func.kind === 91) { + if (func && func.kind === 92) { return statement; } } @@ -24590,7 +26221,7 @@ var ts; emitNodeWithoutSourceMap(memberName); write("]"); } - else if (memberName.kind === 129) { + else if (memberName.kind === 133) { emitComputedPropertyName(memberName); } else { @@ -24602,7 +26233,7 @@ var ts; var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 134 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { + if (member.kind === 138 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { properties.push(member); } } @@ -24642,11 +26273,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 181) { + if (member.kind === 188) { writeLine(); write(";"); } - else if (member.kind === 136 || node.kind === 135) { + else if (member.kind === 140 || node.kind === 139) { if (!member.body) { return emitOnlyPinnedOrTripleSlashComments(member); } @@ -24665,7 +26296,7 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 138 || member.kind === 139) { + else if (member.kind === 142 || member.kind === 143) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -24715,22 +26346,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 136 || node.kind === 135) && !member.body) { + if ((member.kind === 140 || node.kind === 139) && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - else if (member.kind === 136 || - member.kind === 138 || - member.kind === 139) { + else if (member.kind === 140 || + member.kind === 142 || + member.kind === 143) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 128) { write("static "); } - if (member.kind === 138) { + if (member.kind === 142) { write("get "); } - else if (member.kind === 139) { + else if (member.kind === 143) { write("set "); } if (member.asteriskToken) { @@ -24741,7 +26372,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 181) { + else if (member.kind === 188) { writeLine(); write(";"); } @@ -24762,10 +26393,10 @@ var ts; function emitConstructorWorker(node, baseTypeElement) { var hasInstancePropertyWithInitializer = false; ts.forEach(node.members, function (member) { - if (member.kind === 137 && !member.body) { + if (member.kind === 141 && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - if (member.kind === 134 && member.initializer && (member.flags & 128) === 0) { + if (member.kind === 138 && member.initializer && (member.flags & 128) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -24865,9 +26496,9 @@ var ts; } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 204) { + if (node.kind === 211) { if (thisNodeIsDecorated) { - if (isES6ExportedDeclaration(node) && !(node.flags & 256)) { + if (isES6ExportedDeclaration(node) && !(node.flags & 1024)) { write("export "); } write("let "); @@ -24876,13 +26507,13 @@ var ts; } else if (isES6ExportedDeclaration(node)) { write("export "); - if (node.flags & 256) { + if (node.flags & 1024) { write("default "); } } } var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 177; + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 183; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0); @@ -24892,7 +26523,7 @@ var ts; write(" = "); } write("class"); - if ((node.name || !(node.flags & 256)) && !thisNodeIsDecorated) { + if ((node.name || !(node.flags & 1024)) && !thisNodeIsDecorated) { write(" "); emitDeclarationName(node); } @@ -24941,7 +26572,7 @@ var ts; emitEnd(node); write(";"); } - else if (isES6ExportedDeclaration(node) && (node.flags & 256) && thisNodeIsDecorated) { + else if (isES6ExportedDeclaration(node) && (node.flags & 1024) && thisNodeIsDecorated) { writeLine(); write("export default "); emitDeclarationName(node); @@ -24949,7 +26580,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 204) { + if (node.kind === 211) { if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); } @@ -25007,11 +26638,11 @@ var ts; emit(baseTypeNode.expression); } write(")"); - if (node.kind === 204) { + if (node.kind === 211) { write(";"); } emitEnd(node); - if (node.kind === 204) { + if (node.kind === 211) { emitExportMemberAssignment(node); } if (languageVersion < 2 && node.parent === currentSourceFile && node.name) { @@ -25085,13 +26716,13 @@ var ts; } else { decorators = member.decorators; - if (member.kind === 136) { + if (member.kind === 140) { functionLikeMember = member; } } writeLine(); emitStart(member); - if (member.kind !== 134) { + if (member.kind !== 138) { write("Object.defineProperty("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -25121,7 +26752,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); - if (member.kind !== 134) { + if (member.kind !== 138) { write(", Object.getOwnPropertyDescriptor("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -25160,101 +26791,228 @@ var ts; } function shouldEmitTypeMetadata(node) { switch (node.kind) { - case 136: + case 140: + case 142: + case 143: case 138: - case 139: - case 134: return true; } return false; } function shouldEmitReturnTypeMetadata(node) { switch (node.kind) { - case 136: + case 140: return true; } return false; } function shouldEmitParamTypesMetadata(node) { switch (node.kind) { - case 204: - case 136: - case 139: + case 211: + case 140: + case 143: return true; } return false; } + function emitSerializedTypeOfNode(node) { + switch (node.kind) { + case 211: + write("Function"); + return; + case 138: + emitSerializedTypeNode(node.type); + return; + case 135: + emitSerializedTypeNode(node.type); + return; + case 142: + emitSerializedTypeNode(node.type); + return; + case 143: + emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); + return; + } + if (ts.isFunctionLike(node)) { + write("Function"); + return; + } + write("void 0"); + } + function emitSerializedTypeNode(node) { + switch (node.kind) { + case 100: + write("void 0"); + return; + case 157: + emitSerializedTypeNode(node.type); + return; + case 149: + case 150: + write("Function"); + return; + case 153: + case 154: + write("Array"); + return; + case 147: + case 117: + write("Boolean"); + return; + case 127: + case 8: + write("String"); + return; + case 125: + write("Number"); + return; + case 128: + write("Symbol"); + return; + case 148: + emitSerializedTypeReferenceNode(node); + return; + case 151: + case 152: + case 155: + case 156: + case 114: + break; + default: + ts.Debug.fail("Cannot serialize unexpected type node."); + break; + } + write("Object"); + } + function emitSerializedTypeReferenceNode(node) { + var typeName = node.typeName; + var result = resolver.getTypeReferenceSerializationKind(node); + 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 === 211) { + 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 === 153) { + parameterType = parameterType.elementType; + } + else if (parameterType.kind === 148 && 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)) { + emitSerializedTypeNode(node.type); + return; + } + write("void 0"); + } function emitSerializedTypeMetadata(node, writeComma) { var argumentsWritten = 0; if (compilerOptions.emitDecoratorMetadata) { if (shouldEmitTypeMetadata(node)) { - var serializedType = resolver.serializeTypeOfNode(node); - if (serializedType) { - if (writeComma) { - write(", "); - } - writeLine(); - write("__metadata('design:type', "); - emitSerializedType(node, serializedType); - write(")"); - argumentsWritten++; + if (writeComma) { + write(", "); } + writeLine(); + write("__metadata('design:type', "); + emitSerializedTypeOfNode(node); + write(")"); + argumentsWritten++; } if (shouldEmitParamTypesMetadata(node)) { - var serializedTypes = resolver.serializeParameterTypesOfNode(node); - if (serializedTypes) { - if (writeComma || argumentsWritten) { - write(", "); - } - writeLine(); - write("__metadata('design:paramtypes', ["); - for (var i = 0; i < serializedTypes.length; ++i) { - if (i > 0) { - write(", "); - } - emitSerializedType(node, serializedTypes[i]); - } - write("])"); - argumentsWritten++; + if (writeComma || argumentsWritten) { + write(", "); } + writeLine(); + write("__metadata('design:paramtypes', ["); + emitSerializedParameterTypesOfNode(node); + write("])"); + argumentsWritten++; } if (shouldEmitReturnTypeMetadata(node)) { - var serializedType = resolver.serializeReturnTypeOfNode(node); - if (serializedType) { - if (writeComma || argumentsWritten) { - write(", "); - } - writeLine(); - write("__metadata('design:returntype', "); - emitSerializedType(node, serializedType); - write(")"); - argumentsWritten++; + if (writeComma || argumentsWritten) { + write(", "); } + writeLine(); + write("__metadata('design:returntype', "); + emitSerializedReturnTypeOfNode(node); + write(")"); + argumentsWritten++; } } return argumentsWritten; } - function serializeTypeNameSegment(location, path, index) { - switch (index) { - case 0: - return "typeof " + path[index] + " !== 'undefined' && " + path[index]; - case 1: - return serializeTypeNameSegment(location, path, index - 1) + "." + path[index]; - default: - var temp = createAndRecordTempVariable(0).text; - return "(" + temp + " = " + serializeTypeNameSegment(location, path, index - 1) + ") && " + temp + "." + path[index]; - } - } - function emitSerializedType(location, name) { - if (typeof name === "string") { - write(name); - return; - } - else { - ts.Debug.assert(name.length > 0, "Invalid serialized type name"); - write("(" + serializeTypeNameSegment(location, name, name.length - 1) + ") || Object"); - } - } function emitInterfaceDeclaration(node) { emitOnlyPinnedOrTripleSlashComments(node); } @@ -25349,7 +27107,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 208) { + if (moduleDeclaration.body.kind === 215) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -25358,7 +27116,7 @@ var ts; return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); } function isModuleMergedWithES6Class(node) { - return languageVersion === 2 && !!(resolver.getNodeCheckFlags(node) & 2048); + return languageVersion === 2 && !!(resolver.getNodeCheckFlags(node) & 32768); } function emitModuleDeclaration(node) { var shouldEmit = shouldEmitModuleDeclaration(node); @@ -25384,7 +27142,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 209) { + if (node.body.kind === 216) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; tempFlags = 0; @@ -25416,7 +27174,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.name.kind === 65 && node.parent === currentSourceFile) { + if (!isES6ExportedDeclaration(node) && node.name.kind === 66 && node.parent === currentSourceFile) { if (compilerOptions.module === 4 && (node.flags & 1)) { writeLine(); write(exportFunctionForFile + "(\""); @@ -25441,16 +27199,16 @@ var ts; } } function getNamespaceDeclarationNode(node) { - if (node.kind === 211) { + if (node.kind === 218) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 214) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 221) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 212 && node.importClause && !!node.importClause.name; + return node.kind === 219 && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -25477,7 +27235,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 214) { + if (node.importClause.namedBindings.kind === 221) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -25503,7 +27261,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 211 && (node.flags & 1) !== 0; + var isExportedImport = node.kind === 218 && (node.flags & 1) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (compilerOptions.module !== 2) { emitLeadingComments(node); @@ -25515,7 +27273,7 @@ var ts; write(" = "); } else { - var isNakedImport = 212 && !node.importClause; + var isNakedImport = 219 && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -25671,8 +27429,8 @@ var ts; write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 203 && - expression.kind !== 204) { + if (expression.kind !== 210 && + expression.kind !== 211) { write(";"); } emitEnd(node); @@ -25708,18 +27466,18 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 212: + case 219: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, true)) { externalImports.push(node); } break; - case 211: - if (node.moduleReference.kind === 222 && resolver.isReferencedAliasDeclaration(node)) { + case 218: + if (node.moduleReference.kind === 229 && resolver.isReferencedAliasDeclaration(node)) { externalImports.push(node); } break; - case 218: + case 225: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -25732,12 +27490,12 @@ var ts; else { for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { var specifier = _d[_c]; - var name_21 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_21] || (exportSpecifiers[name_21] = [])).push(specifier); + var name_24 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_24] || (exportSpecifiers[name_24] = [])).push(specifier); } } break; - case 217: + case 224: if (node.isExportEquals && !exportEquals) { exportEquals = node; } @@ -25762,10 +27520,10 @@ var ts; if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); } - if (node.kind === 212 && node.importClause) { + if (node.kind === 219 && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 218 && node.moduleSpecifier) { + if (node.kind === 225 && node.moduleSpecifier) { return getGeneratedNameForNode(node); } } @@ -25784,8 +27542,8 @@ var ts; var started = false; for (var _a = 0; _a < externalImports.length; _a++) { var importNode = externalImports[_a]; - var skipNode = importNode.kind === 218 || - (importNode.kind === 212 && !importNode.importClause); + var skipNode = importNode.kind === 225 || + (importNode.kind === 219 && !importNode.importClause); if (skipNode) { continue; } @@ -25810,7 +27568,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0; _a < externalImports.length; _a++) { var externalImport = externalImports[_a]; - if (externalImport.kind === 218 && externalImport.exportClause) { + if (externalImport.kind === 225 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -25839,7 +27597,7 @@ var ts; } for (var _d = 0; _d < externalImports.length; _d++) { var externalImport = externalImports[_d]; - if (externalImport.kind !== 218) { + if (externalImport.kind !== 225) { continue; } var exportDecl = externalImport; @@ -25878,7 +27636,7 @@ var ts; return exportStarFunction; } function writeExportedName(node) { - if (node.kind !== 65 && node.flags & 256) { + if (node.kind !== 66 && node.flags & 1024) { return; } if (started) { @@ -25889,7 +27647,7 @@ var ts; } writeLine(); write("'"); - if (node.kind === 65) { + if (node.kind === 66) { emitNodeWithoutSourceMap(node); } else { @@ -25909,11 +27667,11 @@ var ts; var seen = {}; for (var i = 0; i < hoistedVars.length; ++i) { var local = hoistedVars[i]; - var name_22 = local.kind === 65 + var name_25 = local.kind === 66 ? local : local.name; - if (name_22) { - var text = ts.unescapeIdentifier(name_22.text); + if (name_25) { + var text = ts.unescapeIdentifier(name_25.text); if (ts.hasProperty(seen, text)) { continue; } @@ -25924,13 +27682,13 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 204 || local.kind === 208 || local.kind === 207) { + if (local.kind === 211 || local.kind === 215 || local.kind === 214) { emitDeclarationName(local); } else { emit(local); } - var flags = ts.getCombinedNodeFlags(local.kind === 65 ? local.parent : local); + var flags = ts.getCombinedNodeFlags(local.kind === 66 ? local.parent : local); if (flags & 1) { if (!exportedDeclarations) { exportedDeclarations = []; @@ -25958,21 +27716,21 @@ var ts; if (node.flags & 2) { return; } - if (node.kind === 203) { + if (node.kind === 210) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 204) { + if (node.kind === 211) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 207) { + if (node.kind === 214) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -25981,7 +27739,7 @@ var ts; } return; } - if (node.kind === 208) { + if (node.kind === 215) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -25990,17 +27748,17 @@ var ts; } return; } - if (node.kind === 201 || node.kind === 155) { + if (node.kind === 208 || node.kind === 160) { if (shouldHoistVariable(node, false)) { - var name_23 = node.name; - if (name_23.kind === 65) { + var name_26 = node.name; + if (name_26.kind === 66) { if (!hoistedVars) { hoistedVars = []; } - hoistedVars.push(name_23); + hoistedVars.push(name_26); } else { - ts.forEachChild(name_23, visit); + ts.forEachChild(name_26, visit); } } return; @@ -26018,8 +27776,8 @@ var ts; if (checkIfSourceFileLevelDecl && !shouldHoistDeclarationInSystemJsModule(node)) { return false; } - return (ts.getCombinedNodeFlags(node) & 12288) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 230; + return (ts.getCombinedNodeFlags(node) & 49152) === 0 || + ts.getEnclosingBlockScopeContainer(node).kind === 245; } function isCurrentFileSystemExternalModule() { return compilerOptions.module === 4 && ts.isExternalModule(currentSourceFile); @@ -26054,27 +27812,27 @@ var ts; var parameterName = "_" + importVariableName; write("function (" + parameterName + ") {"); switch (importNode.kind) { - case 212: + case 219: if (!importNode.importClause) { break; } - case 211: + case 218: ts.Debug.assert(importVariableName !== ""); increaseIndent(); writeLine(); write(importVariableName + " = " + parameterName + ";"); writeLine(); - var defaultName = importNode.kind === 212 + var defaultName = importNode.kind === 219 ? importNode.importClause.name : importNode.name; if (defaultName) { emitExportMemberAssignments(defaultName); writeLine(); } - if (importNode.kind === 212 && + if (importNode.kind === 219 && importNode.importClause.namedBindings) { var namedBindings = importNode.importClause.namedBindings; - if (namedBindings.kind === 214) { + if (namedBindings.kind === 221) { emitExportMemberAssignments(namedBindings.name); writeLine(); } @@ -26088,7 +27846,7 @@ var ts; } decreaseIndent(); break; - case 218: + case 225: ts.Debug.assert(importVariableName !== ""); increaseIndent(); if (importNode.exportClause) { @@ -26122,10 +27880,10 @@ var ts; for (var i = startIndex; i < node.statements.length; ++i) { var statement = node.statements[i]; switch (statement.kind) { + case 225: + case 219: case 218: - case 212: - case 211: - case 203: + case 210: continue; } writeLine(); @@ -26139,6 +27897,7 @@ var ts; collectExternalModuleInfo(node); ts.Debug.assert(!exportFunctionForFile); exportFunctionForFile = makeUniqueName("exports"); + writeLine(); write("System.register("); if (node.moduleName) { write("\"" + node.moduleName + "\", "); @@ -26273,6 +28032,87 @@ var ts; emitEnd(exportEquals); } } + function emitJsxElement(node) { + switch (compilerOptions.jsx) { + case 2: + jsxEmitReact(node); + break; + case 1: + default: + jsxEmitPreserve(node); + break; + } + } + function trimReactWhitespace(node) { + var result = undefined; + var text = ts.getTextOfNode(node); + 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; + } + return result; + } + function getTextToEmit(node) { + switch (compilerOptions.jsx) { + case 2: + var text = trimReactWhitespace(node); + if (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(trimReactWhitespace(node)); + write('"'); + break; + case 1: + default: + write(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])) { @@ -26306,17 +28146,21 @@ var ts; writeLines(extendsHelper); extendsEmitted = true; } - if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 512) { + if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 16) { writeLines(decorateHelper); if (compilerOptions.emitDecoratorMetadata) { writeLines(metadataHelper); } decorateEmitted = true; } - if (!paramEmitted && resolver.getNodeCheckFlags(node) & 1024) { + if (!paramEmitted && resolver.getNodeCheckFlags(node) & 32) { writeLines(paramHelper); paramEmitted = true; } + if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & 64) { + writeLines(awaiterHelper); + awaiterEmitted = true; + } } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { if (languageVersion >= 2) { @@ -26364,23 +28208,23 @@ var ts; } function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { - case 205: - case 203: case 212: - case 211: - case 206: - case 217: + case 210: + case 219: + case 218: + case 213: + case 224: return false; - case 183: + case 190: return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 208: + case 215: return shouldEmitModuleDeclaration(node); - case 207: + case 214: return shouldEmitEnumDeclaration(node); } - if (node.kind !== 182 && + if (node.kind !== 189 && node.parent && - node.parent.kind === 166 && + node.parent.kind === 171 && node.parent.body === node && compilerOptions.target <= 1) { return false; @@ -26389,25 +28233,25 @@ var ts; } function emitJavaScriptWorker(node) { switch (node.kind) { - case 65: + case 66: return emitIdentifier(node); - case 131: - return emitParameter(node); - case 136: case 135: - return emitMethod(node); - case 138: + return emitParameter(node); + case 140: case 139: + return emitMethod(node); + case 142: + case 143: return emitAccessor(node); - case 93: + case 94: return emitThis(node); - case 91: + case 92: return emitSuper(node); - case 89: + case 90: return write("null"); - case 95: + case 96: return write("true"); - case 80: + case 81: return write("false"); case 7: case 8: @@ -26417,131 +28261,142 @@ var ts; case 12: case 13: return emitLiteral(node); - case 174: - return emitTemplateExpression(node); case 180: - return emitTemplateSpan(node); - case 128: - return emitQualifiedName(node); - case 153: - return emitObjectBindingPattern(node); - case 154: - return emitArrayBindingPattern(node); - case 155: - return emitBindingElement(node); - case 156: - return emitArrayLiteral(node); - case 157: - return emitObjectLiteral(node); - case 227: - return emitPropertyAssignment(node); - case 228: - return emitShorthandPropertyAssignment(node); - case 129: - return emitComputedPropertyName(node); - case 158: - return emitPropertyAccess(node); - case 159: - return emitIndexedAccess(node); - case 160: - return emitCallExpression(node); - case 161: - return emitNewExpression(node); - case 162: - return emitTaggedTemplateExpression(node); - case 163: - return emit(node.expression); - case 164: - return emitParenExpression(node); - case 203: - case 165: - case 166: - return emitFunctionDeclaration(node); - case 167: - return emitDeleteExpression(node); - case 168: - return emitTypeOfExpression(node); - case 169: - return emitVoidExpression(node); - case 170: - return emitPrefixUnaryExpression(node); - case 171: - return emitPostfixUnaryExpression(node); - case 172: - return emitBinaryExpression(node); - case 173: - return emitConditionalExpression(node); - case 176: - return emitSpreadElementExpression(node); - case 175: - return emitYieldExpression(node); - case 178: - return; - case 182: - case 209: - return emitBlock(node); - case 183: - return emitVariableStatement(node); - case 184: - return write(";"); - case 185: - return emitExpressionStatement(node); - case 186: - return emitIfStatement(node); + return emitTemplateExpression(node); case 187: - return emitDoStatement(node); - case 188: - return emitWhileStatement(node); - case 189: - return emitForStatement(node); - case 191: - case 190: - return emitForInOrForOfStatement(node); - case 192: - case 193: - return emitBreakOrContinueStatement(node); - case 194: - return emitReturnStatement(node); - case 195: - return emitWithStatement(node); - case 196: - return emitSwitchStatement(node); - case 223: - case 224: - return emitCaseOrDefaultClause(node); - case 197: - return emitLabelledStatement(node); - case 198: - return emitThrowStatement(node); - case 199: - return emitTryStatement(node); - case 226: - return emitCatchClause(node); - case 200: - return emitDebuggerStatement(node); - case 201: - return emitVariableDeclaration(node); - case 177: - return emitClassExpression(node); - case 204: - return emitClassDeclaration(node); - case 205: - return emitInterfaceDeclaration(node); - case 207: - return emitEnumDeclaration(node); - case 229: - return emitEnumMember(node); - case 208: - return emitModuleDeclaration(node); - case 212: - return emitImportDeclaration(node); - case 211: - return emitImportEqualsDeclaration(node); - case 218: - return emitExportDeclaration(node); - case 217: - return emitExportAssignment(node); + return emitTemplateSpan(node); case 230: + case 231: + return emitJsxElement(node); + case 233: + return emitJsxText(node); + case 237: + return emitJsxExpression(node); + case 132: + return emitQualifiedName(node); + case 158: + return emitObjectBindingPattern(node); + case 159: + return emitArrayBindingPattern(node); + case 160: + return emitBindingElement(node); + case 161: + return emitArrayLiteral(node); + case 162: + return emitObjectLiteral(node); + case 242: + return emitPropertyAssignment(node); + case 243: + return emitShorthandPropertyAssignment(node); + case 133: + return emitComputedPropertyName(node); + case 163: + return emitPropertyAccess(node); + case 164: + return emitIndexedAccess(node); + case 165: + return emitCallExpression(node); + case 166: + return emitNewExpression(node); + case 167: + return emitTaggedTemplateExpression(node); + case 168: + return emit(node.expression); + case 186: + return emit(node.expression); + case 169: + return emitParenExpression(node); + case 210: + case 170: + case 171: + return emitFunctionDeclaration(node); + case 172: + return emitDeleteExpression(node); + case 173: + return emitTypeOfExpression(node); + case 174: + return emitVoidExpression(node); + case 175: + return emitAwaitExpression(node); + case 176: + return emitPrefixUnaryExpression(node); + case 177: + return emitPostfixUnaryExpression(node); + case 178: + return emitBinaryExpression(node); + case 179: + return emitConditionalExpression(node); + case 182: + return emitSpreadElementExpression(node); + case 181: + return emitYieldExpression(node); + case 184: + return; + case 189: + case 216: + return emitBlock(node); + case 190: + return emitVariableStatement(node); + case 191: + return write(";"); + case 192: + return emitExpressionStatement(node); + case 193: + return emitIfStatement(node); + case 194: + return emitDoStatement(node); + case 195: + return emitWhileStatement(node); + case 196: + return emitForStatement(node); + case 198: + case 197: + return emitForInOrForOfStatement(node); + case 199: + case 200: + return emitBreakOrContinueStatement(node); + case 201: + return emitReturnStatement(node); + case 202: + return emitWithStatement(node); + case 203: + return emitSwitchStatement(node); + case 238: + case 239: + return emitCaseOrDefaultClause(node); + case 204: + return emitLabelledStatement(node); + case 205: + return emitThrowStatement(node); + case 206: + return emitTryStatement(node); + case 241: + return emitCatchClause(node); + case 207: + return emitDebuggerStatement(node); + case 208: + return emitVariableDeclaration(node); + case 183: + return emitClassExpression(node); + case 211: + return emitClassDeclaration(node); + case 212: + return emitInterfaceDeclaration(node); + case 214: + return emitEnumDeclaration(node); + case 244: + return emitEnumMember(node); + case 215: + return emitModuleDeclaration(node); + case 219: + return emitImportDeclaration(node); + case 218: + return emitImportEqualsDeclaration(node); + case 225: + return emitExportDeclaration(node); + case 224: + return emitExportAssignment(node); + case 245: return emitSourceFileNode(node); } } @@ -26569,7 +28424,7 @@ var ts; } function getLeadingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 230 || node.pos !== node.parent.pos) { + if (node.parent.kind === 245 || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { return getLeadingCommentsWithoutDetachedComments(); } @@ -26581,7 +28436,7 @@ var ts; } function getTrailingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 230 || node.end !== node.parent.end) { + if (node.parent.kind === 245 || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } @@ -26758,10 +28613,10 @@ var ts; }; } ts.createCompilerHost = createCompilerHost; - function getPreEmitDiagnostics(program, sourceFile) { - var diagnostics = program.getOptionsDiagnostics().concat(program.getSyntacticDiagnostics(sourceFile), program.getGlobalDiagnostics(), program.getSemanticDiagnostics(sourceFile)); + function getPreEmitDiagnostics(program, sourceFile, cancellationToken) { + var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (program.getCompilerOptions().declaration) { - diagnostics.concat(program.getDeclarationDiagnostics(sourceFile)); + diagnostics.concat(program.getDeclarationDiagnostics(sourceFile, cancellationToken)); } return ts.sortAndDeduplicateDiagnostics(diagnostics); } @@ -26857,8 +28712,12 @@ var ts; function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false)); } - function emit(sourceFile, writeFileCallback) { - if (options.noEmitOnError && getPreEmitDiagnostics(this).length > 0) { + function emit(sourceFile, writeFileCallback, cancellationToken) { + var _this = this; + return runWithCancellationToken(function () { return emitWorker(_this, sourceFile, writeFileCallback, cancellationToken); }); + } + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken) { + if (options.noEmitOnError && getPreEmitDiagnostics(program, undefined, cancellationToken).length > 0) { return { diagnostics: [], sourceMaps: undefined, emitSkipped: true }; } var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(options.out ? undefined : sourceFile); @@ -26870,42 +28729,61 @@ var ts; function getSourceFile(fileName) { return filesByName.get(fileName); } - function getDiagnosticsHelper(sourceFile, getDiagnostics) { + function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) { if (sourceFile) { - return getDiagnostics(sourceFile); + return getDiagnostics(sourceFile, cancellationToken); } var allDiagnostics = []; ts.forEach(program.getSourceFiles(), function (sourceFile) { - ts.addRange(allDiagnostics, getDiagnostics(sourceFile)); + if (cancellationToken) { + cancellationToken.throwIfCancellationRequested(); + } + ts.addRange(allDiagnostics, getDiagnostics(sourceFile, cancellationToken)); }); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } - function getSyntacticDiagnostics(sourceFile) { - return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile); + function getSyntacticDiagnostics(sourceFile, cancellationToken) { + return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile, cancellationToken); } - function getSemanticDiagnostics(sourceFile) { - return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile); + function getSemanticDiagnostics(sourceFile, cancellationToken) { + return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile, cancellationToken); } - function getDeclarationDiagnostics(sourceFile) { - return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile); + function getDeclarationDiagnostics(sourceFile, cancellationToken) { + return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken); } - function getSyntacticDiagnosticsForFile(sourceFile) { + function getSyntacticDiagnosticsForFile(sourceFile, cancellationToken) { return sourceFile.parseDiagnostics; } - function getSemanticDiagnosticsForFile(sourceFile) { - var typeChecker = getDiagnosticsProducingTypeChecker(); - ts.Debug.assert(!!sourceFile.bindDiagnostics); - var bindDiagnostics = sourceFile.bindDiagnostics; - var checkDiagnostics = typeChecker.getDiagnostics(sourceFile); - var programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName); - return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics); - } - function getDeclarationDiagnosticsForFile(sourceFile) { - if (!ts.isDeclarationFile(sourceFile)) { - var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile); - var writeFile = function () { }; - return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); + function runWithCancellationToken(func) { + try { + return func(); } + catch (e) { + if (e instanceof ts.OperationCanceledException) { + noDiagnosticsTypeChecker = undefined; + diagnosticsProducingTypeChecker = undefined; + } + throw e; + } + } + function getSemanticDiagnosticsForFile(sourceFile, cancellationToken) { + return runWithCancellationToken(function () { + var typeChecker = getDiagnosticsProducingTypeChecker(); + ts.Debug.assert(!!sourceFile.bindDiagnostics); + var bindDiagnostics = sourceFile.bindDiagnostics; + var checkDiagnostics = typeChecker.getDiagnostics(sourceFile, cancellationToken); + var programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName); + return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics); + }); + } + function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) { + return runWithCancellationToken(function () { + if (!ts.isDeclarationFile(sourceFile)) { + var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); + var writeFile_1 = function () { }; + return ts.getDeclarationDiagnostics(getEmitHost(writeFile_1), resolver, sourceFile); + } + }); } function getOptionsDiagnostics() { var allDiagnostics = []; @@ -26926,7 +28804,6 @@ var ts; function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var start; var length; - var extensions; var diagnosticArgument; if (refEnd !== undefined && refPos !== undefined) { start = refPos; @@ -27027,7 +28904,7 @@ var ts; } function processImportedModules(file, basePath) { ts.forEach(file.statements, function (node) { - if (node.kind === 212 || node.kind === 211 || node.kind === 218) { + if (node.kind === 219 || node.kind === 218 || node.kind === 225) { var moduleNameExpr = ts.getExternalModuleName(node); if (moduleNameExpr && moduleNameExpr.kind === 8) { var moduleNameText = moduleNameExpr.text; @@ -27048,7 +28925,7 @@ var ts; } } } - else if (node.kind === 208 && node.name.kind === 8 && (node.flags & 2 || ts.isDeclarationFile(file))) { + else if (node.kind === 215 && node.name.kind === 8 && (node.flags & 2 || ts.isDeclarationFile(file))) { ts.forEachChild(node.body, function (node) { if (ts.isExternalModuleImportEqualsDeclaration(node) && ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 8) { @@ -27198,6 +29075,10 @@ var ts; !options.experimentalDecorators) { diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified)); } + if (options.experimentalAsyncFunctions && + options.target !== 2) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower)); + } } } ts.createProgram = createProgram; @@ -27241,6 +29122,16 @@ var ts; name: "inlineSources", type: "boolean" }, + { + name: "jsx", + type: { + "preserve": 1, + "react": 2 + }, + paramType: ts.Diagnostics.KIND, + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, + error: ts.Diagnostics.Argument_for_jsx_must_be_preserve_or_react + }, { name: "listFiles", type: "boolean" @@ -27396,6 +29287,11 @@ 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", @@ -27454,10 +29350,10 @@ var ts; options[opt.name] = args[i++] || ""; break; default: - var map = opt.type; + var map_2 = opt.type; var key = (args[i++] || "").toLowerCase(); - if (ts.hasProperty(map, key)) { - options[opt.name] = map[key]; + if (ts.hasProperty(map_2, key)) { + options[opt.name] = map_2[key]; } else { errors.push(ts.createCompilerDiagnostic(opt.error)); @@ -27510,8 +29406,9 @@ var ts; } ts.parseCommandLine = parseCommandLine; function readConfigFile(fileName) { + var text = ''; try { - var text = ts.sys.readFile(fileName); + text = ts.sys.readFile(fileName); } catch (e) { return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; @@ -27585,11 +29482,22 @@ var ts; } else { var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; - var sysFiles = host.readDirectory(basePath, ".ts", exclude); + var sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)); for (var i = 0; i < sysFiles.length; i++) { - var name = sysFiles[i]; - if (!ts.fileExtensionIs(name, ".d.ts") || !ts.contains(sysFiles, name.substr(0, name.length - 5) + ".ts")) { - fileNames.push(name); + var name_27 = sysFiles[i]; + if (ts.fileExtensionIs(name_27, ".d.ts")) { + var baseName = name_27.substr(0, name_27.length - ".d.ts".length); + if (!ts.contains(sysFiles, baseName + ".tsx") && !ts.contains(sysFiles, baseName + ".ts")) { + fileNames.push(name_27); + } + } + else if (ts.fileExtensionIs(name_27, ".ts")) { + if (!ts.contains(sysFiles, name_27 + "x")) { + fileNames.push(name_27); + } + } + else { + fileNames.push(name_27); } } } @@ -27628,8 +29536,9 @@ var ts; if (!ts.sys.fileExists(filePath)) { return false; } + var fileContents = ''; try { - var fileContents = ts.sys.readFile(filePath); + fileContents = ts.sys.readFile(filePath); } catch (e) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unable_to_open_file_0, filePath)); @@ -27748,7 +29657,7 @@ var ts; printHelp(); return ts.sys.exit(ts.ExitStatus.Success); } - if (commandLine.options.watch) { + if (commandLine.options.watch && commandLine.options.hasOwnProperty("watch")) { if (!ts.sys.watchFile) { reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--watch")); return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); @@ -27792,9 +29701,9 @@ var ts; } function getSourceFile(fileName, languageVersion, onError) { if (cachedProgram) { - var sourceFile = cachedProgram.getSourceFile(fileName); - if (sourceFile && sourceFile.fileWatcher) { - return sourceFile; + var sourceFile_1 = cachedProgram.getSourceFile(fileName); + if (sourceFile_1 && sourceFile_1.fileWatcher) { + return sourceFile_1; } } var sourceFile = hostGetSourceFile(fileName, languageVersion, onError); @@ -27877,11 +29786,11 @@ var ts; var diagnostics = program.getSyntacticDiagnostics(); reportDiagnostics(diagnostics); if (diagnostics.length === 0) { - var diagnostics = program.getGlobalDiagnostics(); - reportDiagnostics(diagnostics); - if (diagnostics.length === 0) { - var diagnostics = program.getSemanticDiagnostics(); - reportDiagnostics(diagnostics); + var diagnostics_1 = program.getGlobalDiagnostics(); + reportDiagnostics(diagnostics_1); + if (diagnostics_1.length === 0) { + var diagnostics_2 = program.getSemanticDiagnostics(); + reportDiagnostics(diagnostics_2); } } if (compilerOptions.noEmit) { @@ -27920,7 +29829,7 @@ var ts; output += getDiagnosticText(ts.Diagnostics.Options_Colon) + ts.sys.newLine; var optsList = ts.filter(ts.optionDeclarations.slice(), function (v) { return !v.experimental; }); optsList.sort(function (a, b) { return ts.compareValues(a.name.toLowerCase(), b.name.toLowerCase()); }); - var marginLength = 0; + marginLength = 0; var usageColumn = []; var descriptionColumn = []; for (var i = 0; i < optsList.length; i++) { @@ -27928,17 +29837,17 @@ var ts; if (!option.description) { continue; } - var usageText = " "; + var usageText_1 = " "; if (option.shortName) { - usageText += "-" + option.shortName; - usageText += getParamType(option); - usageText += ", "; + usageText_1 += "-" + option.shortName; + usageText_1 += getParamType(option); + usageText_1 += ", "; } - usageText += "--" + option.name; - usageText += getParamType(option); - usageColumn.push(usageText); + usageText_1 += "--" + option.name; + usageText_1 += getParamType(option); + usageColumn.push(usageText_1); descriptionColumn.push(getDiagnosticText(option.description)); - marginLength = Math.max(usageText.length, marginLength); + marginLength = Math.max(usageText_1.length, marginLength); } var usageText = " @<" + getDiagnosticText(ts.Diagnostics.file) + ">"; usageColumn.push(usageText); diff --git a/bin/tsserver.js b/bin/tsserver.js index b9b8ecc2ad1..abc95f7a760 100644 --- a/bin/tsserver.js +++ b/bin/tsserver.js @@ -15,12 +15,31 @@ and limitations under the License. var ts; (function (ts) { + var OperationCanceledException = (function () { + function OperationCanceledException() { + } + return OperationCanceledException; + })(); + ts.OperationCanceledException = OperationCanceledException; (function (ExitStatus) { ExitStatus[ExitStatus["Success"] = 0] = "Success"; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsSkipped"] = 1] = "DiagnosticsPresent_OutputsSkipped"; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; })(ts.ExitStatus || (ts.ExitStatus = {})); var ExitStatus = ts.ExitStatus; + (function (TypeReferenceSerializationKind) { + TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidType"] = 2] = "VoidType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 4] = "StringLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 5] = "BooleanType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 6] = "ArrayLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 7] = "ESSymbolType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 8] = "TypeWithCallSignature"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 9] = "ObjectType"; + })(ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); + var TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind; (function (DiagnosticCategory) { DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; @@ -547,7 +566,7 @@ 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/ + // 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; @@ -630,8 +649,8 @@ var ts; return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension; } ts.fileExtensionIs = fileExtensionIs; - ts.supportedExtensions = [".ts", ".d.ts"]; - var extensionsToRemove = [".d.ts", ".ts", ".js"]; + ts.supportedExtensions = [".tsx", ".ts", ".d.ts"]; + var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { for (var _i = 0; _i < extensionsToRemove.length; _i++) { var ext = extensionsToRemove[_i]; @@ -674,8 +693,8 @@ var ts; } Node.prototype = { kind: kind, - pos: 0, - end: 0, + pos: -1, + end: -1, flags: 0, parent: undefined }; @@ -890,16 +909,16 @@ var ts; var directories = []; for (var _i = 0; _i < files.length; _i++) { var current = files[_i]; - var name = ts.combinePaths(path, current); - if (!ts.contains(exclude, getCanonicalPath(name))) { - var stat = _fs.statSync(name); + var name_3 = ts.combinePaths(path, current); + if (!ts.contains(exclude, getCanonicalPath(name_3))) { + var stat = _fs.statSync(name_3); if (stat.isFile()) { - if (!extension || ts.fileExtensionIs(name, extension)) { - result.push(name); + if (!extension || ts.fileExtensionIs(name_3, extension)) { + result.push(name_3); } } else if (stat.isDirectory()) { - directories.push(name); + directories.push(name_3); } } } @@ -995,22 +1014,21 @@ var ts; An_index_signature_must_have_a_type_annotation: { code: 1021, category: ts.DiagnosticCategory.Error, key: "An index signature must have a type annotation." }, An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: ts.DiagnosticCategory.Error, key: "An index signature parameter must have a type annotation." }, An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: ts.DiagnosticCategory.Error, key: "An index signature parameter type must be 'string' or 'number'." }, - A_class_or_interface_declaration_can_only_have_one_extends_clause: { code: 1024, category: ts.DiagnosticCategory.Error, key: "A class or interface declaration can only have one 'extends' clause." }, - An_extends_clause_must_precede_an_implements_clause: { code: 1025, category: ts.DiagnosticCategory.Error, key: "An 'extends' clause must precede an 'implements' clause." }, - A_class_can_only_extend_a_single_class: { code: 1026, category: ts.DiagnosticCategory.Error, key: "A class can only extend a single class." }, - A_class_declaration_can_only_have_one_implements_clause: { code: 1027, category: ts.DiagnosticCategory.Error, key: "A class declaration can only have one 'implements' clause." }, Accessibility_modifier_already_seen: { code: 1028, category: ts.DiagnosticCategory.Error, key: "Accessibility modifier already seen." }, _0_modifier_must_precede_1_modifier: { code: 1029, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier must precede '{1}' modifier." }, _0_modifier_already_seen: { code: 1030, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier already seen." }, _0_modifier_cannot_appear_on_a_class_element: { code: 1031, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a class element." }, - An_interface_declaration_cannot_have_an_implements_clause: { code: 1032, category: ts.DiagnosticCategory.Error, key: "An interface declaration cannot have an 'implements' clause." }, super_must_be_followed_by_an_argument_list_or_member_access: { code: 1034, category: ts.DiagnosticCategory.Error, key: "'super' must be followed by an argument list or member access." }, Only_ambient_modules_can_use_quoted_names: { code: 1035, category: ts.DiagnosticCategory.Error, key: "Only ambient modules can use quoted names." }, Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: ts.DiagnosticCategory.Error, key: "Statements are not allowed in ambient contexts." }, A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used in an already ambient context." }, Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: ts.DiagnosticCategory.Error, key: "Initializers are not allowed in ambient contexts." }, + _0_modifier_cannot_be_used_in_an_ambient_context: { code: 1040, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used in an ambient context." }, + _0_modifier_cannot_be_used_with_a_class_declaration: { code: 1041, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with a class declaration." }, + _0_modifier_cannot_be_used_here: { code: 1042, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used here." }, + _0_modifier_cannot_appear_on_a_data_property: { code: 1043, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a data property." }, _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a module element." }, - A_declare_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an interface declaration." }, + A_0_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: ts.DiagnosticCategory.Error, key: "A '{0}' modifier cannot be used with an interface declaration." }, A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, A_rest_parameter_cannot_be_optional: { code: 1047, category: ts.DiagnosticCategory.Error, key: "A rest parameter cannot be optional." }, A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: ts.DiagnosticCategory.Error, key: "A rest parameter cannot have an initializer." }, @@ -1019,12 +1037,18 @@ var ts; A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor parameter cannot have an initializer." }, A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor cannot have rest parameter." }, A_get_accessor_cannot_have_parameters: { code: 1054, category: ts.DiagnosticCategory.Error, key: "A 'get' accessor cannot have parameters." }, + Type_0_is_not_a_valid_async_function_return_type: { code: 1055, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not a valid async function return type." }, Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: ts.DiagnosticCategory.Error, key: "Accessors are only available when targeting ECMAScript 5 and higher." }, + An_async_function_or_method_must_have_a_valid_awaitable_return_type: { code: 1057, category: ts.DiagnosticCategory.Error, key: "An async function or method must have a valid awaitable return type." }, + Operand_for_await_does_not_have_a_valid_callable_then_member: { code: 1058, category: ts.DiagnosticCategory.Error, key: "Operand for 'await' does not have a valid callable 'then' member." }, + Return_expression_in_async_function_does_not_have_a_valid_callable_then_member: { code: 1059, category: ts.DiagnosticCategory.Error, key: "Return expression in async function does not have a valid callable 'then' member." }, + Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member: { code: 1060, category: ts.DiagnosticCategory.Error, key: "Expression body for async arrow function does not have a valid callable 'then' member." }, 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." }, 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_declare_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an import declaration." }, + 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." }, Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal literals are not available when targeting ECMAScript 5 and higher." }, An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: ts.DiagnosticCategory.Error, key: "An accessor cannot be declared in an ambient context." }, @@ -1069,7 +1093,6 @@ var ts; case_or_default_expected: { code: 1130, category: ts.DiagnosticCategory.Error, key: "'case' or 'default' expected." }, Property_or_signature_expected: { code: 1131, category: ts.DiagnosticCategory.Error, key: "Property or signature expected." }, Enum_member_expected: { code: 1132, category: ts.DiagnosticCategory.Error, key: "Enum member expected." }, - Type_reference_expected: { code: 1133, category: ts.DiagnosticCategory.Error, key: "Type reference expected." }, Variable_declaration_expected: { code: 1134, category: ts.DiagnosticCategory.Error, key: "Variable declaration expected." }, Argument_expression_expected: { code: 1135, category: ts.DiagnosticCategory.Error, key: "Argument expression expected." }, Property_assignment_expected: { code: 1136, category: ts.DiagnosticCategory.Error, key: "Property assignment expected." }, @@ -1086,9 +1109,6 @@ var ts; Cannot_compile_modules_unless_the_module_flag_is_provided: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules unless the '--module' flag is provided." }, File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: ts.DiagnosticCategory.Error, key: "File name '{0}' differs from already included file name '{1}' only in casing" }, new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: ts.DiagnosticCategory.Error, key: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, - var_let_or_const_expected: { code: 1152, category: ts.DiagnosticCategory.Error, key: "'var', 'let' or 'const' expected." }, - let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1153, category: ts.DiagnosticCategory.Error, key: "'let' declarations are only available when targeting ECMAScript 6 and higher." }, - const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1154, category: ts.DiagnosticCategory.Error, key: "'const' declarations are only available when targeting ECMAScript 6 and higher." }, const_declarations_must_be_initialized: { code: 1155, category: ts.DiagnosticCategory.Error, key: "'const' declarations must be initialized" }, const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: ts.DiagnosticCategory.Error, key: "'const' declarations can only be declared inside a block." }, let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: ts.DiagnosticCategory.Error, key: "'let' declarations can only be declared inside a block." }, @@ -1099,7 +1119,6 @@ var ts; Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: ts.DiagnosticCategory.Error, key: "Computed property names are not allowed in enums." }, A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { code: 1165, category: ts.DiagnosticCategory.Error, key: "A computed property name in an ambient context must directly refer to a built-in symbol." }, A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { code: 1166, category: ts.DiagnosticCategory.Error, key: "A computed property name in a class property declaration must directly refer to a built-in symbol." }, - Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1167, category: ts.DiagnosticCategory.Error, key: "Computed property names are only available when targeting ECMAScript 6 and higher." }, A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol: { code: 1168, category: ts.DiagnosticCategory.Error, key: "A computed property name in a method overload must directly refer to a built-in symbol." }, A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol: { code: 1169, category: ts.DiagnosticCategory.Error, key: "A computed property name in an interface must directly refer to a built-in symbol." }, A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol: { code: 1170, category: ts.DiagnosticCategory.Error, key: "A computed property name in a type literal must directly refer to a built-in symbol." }, @@ -1115,7 +1134,6 @@ 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." }, - Destructuring_declarations_are_not_allowed_in_ambient_contexts: { code: 1183, category: ts.DiagnosticCategory.Error, key: "Destructuring declarations are not allowed in ambient contexts." }, An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1184, 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." }, @@ -1166,12 +1184,20 @@ 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." }, Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { code: 1239, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of parameter decorator when called as an expression." }, Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { code: 1240, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of property decorator when called as an expression." }, Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { code: 1241, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of method decorator when called as an expression." }, + abstract_modifier_can_only_appear_on_a_class_or_method_declaration: { code: 1242, category: ts.DiagnosticCategory.Error, key: "'abstract' modifier can only appear on a class or method declaration." }, + _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." }, 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." }, @@ -1180,7 +1206,6 @@ var ts; Module_0_has_no_exported_member_1: { code: 2305, category: ts.DiagnosticCategory.Error, key: "Module '{0}' has no exported member '{1}'." }, File_0_is_not_a_module: { code: 2306, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not a module." }, Cannot_find_module_0: { code: 2307, category: ts.DiagnosticCategory.Error, key: "Cannot find module '{0}'." }, - A_module_cannot_have_more_than_one_export_assignment: { code: 2308, category: ts.DiagnosticCategory.Error, key: "A module cannot have more than one export assignment." }, An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { code: 2309, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in a module with other exported elements." }, Type_0_recursively_references_itself_as_a_base_type: { code: 2310, category: ts.DiagnosticCategory.Error, key: "Type '{0}' recursively references itself as a base type." }, A_class_may_only_extend_another_class: { code: 2311, category: ts.DiagnosticCategory.Error, key: "A class may only extend another class." }, @@ -1208,10 +1233,10 @@ var ts; this_cannot_be_referenced_in_a_static_property_initializer: { code: 2334, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a static property initializer." }, super_can_only_be_referenced_in_a_derived_class: { code: 2335, category: ts.DiagnosticCategory.Error, key: "'super' can only be referenced in a derived class." }, super_cannot_be_referenced_in_constructor_arguments: { code: 2336, category: ts.DiagnosticCategory.Error, key: "'super' cannot be referenced in constructor arguments." }, - Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: ts.DiagnosticCategory.Error, key: "Super calls are not permitted outside constructors or in nested functions inside constructors" }, - super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: ts.DiagnosticCategory.Error, key: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class" }, + Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: ts.DiagnosticCategory.Error, key: "Super calls are not permitted outside constructors or in nested functions inside constructors." }, + super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: ts.DiagnosticCategory.Error, key: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class." }, 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" }, + 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'." }, Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: ts.DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." }, @@ -1370,6 +1395,29 @@ var ts; No_base_constructor_has_the_specified_number_of_type_arguments: { code: 2508, category: ts.DiagnosticCategory.Error, key: "No base constructor has the specified number of type arguments." }, Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: ts.DiagnosticCategory.Error, key: "Base constructor return type '{0}' is not a class or interface type." }, Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: ts.DiagnosticCategory.Error, key: "Base constructors must all have the same return type." }, + Cannot_create_an_instance_of_the_abstract_class_0: { code: 2511, category: ts.DiagnosticCategory.Error, key: "Cannot create an instance of the abstract class '{0}'." }, + Overload_signatures_must_all_be_abstract_or_not_abstract: { code: 2512, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be abstract or not abstract." }, + Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: { code: 2513, category: ts.DiagnosticCategory.Error, key: "Abstract method '{0}' in class '{1}' cannot be accessed via super expression." }, + Classes_containing_abstract_methods_must_be_marked_abstract: { code: 2514, category: ts.DiagnosticCategory.Error, key: "Classes containing abstract methods must be marked abstract." }, + 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." }, + Constructor_objects_of_abstract_type_cannot_be_assigned_to_constructor_objects_of_non_abstract_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Constructor objects of abstract type cannot be assigned to constructor objects of non-abstract 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." }, + 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." }, + Property_0_in_type_1_is_not_assignable_to_type_2: { code: 2603, category: ts.DiagnosticCategory.Error, key: "Property '{0}' in type '{1}' is not assignable to type '{2}'" }, + JSX_element_type_0_does_not_have_any_construct_or_call_signatures: { code: 2604, category: ts.DiagnosticCategory.Error, key: "JSX element type '{0}' does not have any construct or call signatures." }, + JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements: { code: 2605, category: ts.DiagnosticCategory.Error, key: "JSX element type '{0}' is not a constructor function for JSX elements." }, + Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of JSX spread attribute is not assignable to target property." }, + JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" }, + The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" }, + Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" }, 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}'." }, @@ -1506,15 +1554,18 @@ var ts; File_0_has_unsupported_extension_The_only_supported_extensions_are_1: { code: 6054, category: ts.DiagnosticCategory.Error, key: "File '{0}' has unsupported extension. The only supported extensions are {1}." }, Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: ts.DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: ts.DiagnosticCategory.Message, key: "Do not emit declarations for code that has an '@internal' annotation." }, - Preserve_new_lines_when_emitting_code: { code: 6057, category: ts.DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." }, Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: ts.DiagnosticCategory.Message, key: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." }, File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." }, Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: ts.DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE" }, Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, + Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify JSX code generation: 'preserve' or 'react'" }, + Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: ts.DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." }, 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." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -1531,6 +1582,7 @@ var ts; _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: { code: 7023, category: ts.DiagnosticCategory.Error, key: "'{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." }, Function_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: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function 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." }, Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: ts.DiagnosticCategory.Error, key: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." }, + JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: ts.DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists" }, You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: ts.DiagnosticCategory.Error, key: "'import ... =' can only be used in a .ts file." }, @@ -1547,7 +1599,14 @@ var ts; property_declarations_can_only_be_used_in_a_ts_file: { code: 8014, category: ts.DiagnosticCategory.Error, key: "'property declarations' can only be used in a .ts file." }, enum_declarations_can_only_be_used_in_a_ts_file: { code: 8015, category: ts.DiagnosticCategory.Error, key: "'enum declarations' can only be used in a .ts file." }, type_assertion_expressions_can_only_be_used_in_a_ts_file: { code: 8016, category: ts.DiagnosticCategory.Error, key: "'type assertion expressions' can only be used in a .ts file." }, - decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: ts.DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." } + decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: ts.DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." }, + Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: ts.DiagnosticCategory.Error, key: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." }, + class_expressions_are_not_currently_supported: { code: 9003, category: ts.DiagnosticCategory.Error, key: "'class' expressions are not currently supported." }, + JSX_attributes_must_only_be_assigned_a_non_empty_expression: { code: 17000, category: ts.DiagnosticCategory.Error, key: "JSX attributes must only be assigned a non-empty 'expression'." }, + JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { code: 17001, category: ts.DiagnosticCategory.Error, key: "JSX elements cannot have multiple attributes with the same name." }, + 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." } }; })(ts || (ts = {})); /// @@ -1555,68 +1614,71 @@ var ts; var ts; (function (ts) { var textToToken = { - "any": 112, - "as": 111, - "boolean": 113, - "break": 66, - "case": 67, - "catch": 68, - "class": 69, - "continue": 71, - "const": 70, - "constructor": 114, - "debugger": 72, - "declare": 115, - "default": 73, - "delete": 74, - "do": 75, - "else": 76, - "enum": 77, - "export": 78, - "extends": 79, - "false": 80, - "finally": 81, - "for": 82, - "from": 126, - "function": 83, - "get": 116, - "if": 84, - "implements": 102, - "import": 85, - "in": 86, - "instanceof": 87, - "interface": 103, - "is": 117, - "let": 104, - "module": 118, - "namespace": 119, - "new": 88, - "null": 89, - "number": 121, - "package": 105, - "private": 106, - "protected": 107, - "public": 108, - "require": 120, - "return": 90, - "set": 122, - "static": 109, - "string": 123, - "super": 91, - "switch": 92, - "symbol": 124, - "this": 93, - "throw": 94, - "true": 95, - "try": 96, - "type": 125, - "typeof": 97, - "var": 98, - "void": 99, - "while": 100, - "with": 101, - "yield": 110, - "of": 127, + "abstract": 112, + "any": 114, + "as": 113, + "boolean": 117, + "break": 67, + "case": 68, + "catch": 69, + "class": 70, + "continue": 72, + "const": 71, + "constructor": 118, + "debugger": 73, + "declare": 119, + "default": 74, + "delete": 75, + "do": 76, + "else": 77, + "enum": 78, + "export": 79, + "extends": 80, + "false": 81, + "finally": 82, + "for": 83, + "from": 130, + "function": 84, + "get": 120, + "if": 85, + "implements": 103, + "import": 86, + "in": 87, + "instanceof": 88, + "interface": 104, + "is": 121, + "let": 105, + "module": 122, + "namespace": 123, + "new": 89, + "null": 90, + "number": 125, + "package": 106, + "private": 107, + "protected": 108, + "public": 109, + "require": 124, + "return": 91, + "set": 126, + "static": 110, + "string": 127, + "super": 92, + "switch": 93, + "symbol": 128, + "this": 94, + "throw": 95, + "true": 96, + "try": 97, + "type": 129, + "typeof": 98, + "var": 99, + "void": 100, + "while": 101, + "with": 102, + "yield": 111, + "async": 115, + "await": 116, + "of": 131, "{": 14, "}": 15, "(": 16, @@ -1628,46 +1690,47 @@ var ts; ";": 22, ",": 23, "<": 24, - ">": 25, - "<=": 26, - ">=": 27, - "==": 28, - "!=": 29, - "===": 30, - "!==": 31, - "=>": 32, - "+": 33, - "-": 34, - "*": 35, - "/": 36, - "%": 37, - "++": 38, - "--": 39, - "<<": 40, - ">>": 41, - ">>>": 42, - "&": 43, - "|": 44, - "^": 45, - "!": 46, - "~": 47, - "&&": 48, - "||": 49, - "?": 50, - ":": 51, - "=": 53, - "+=": 54, - "-=": 55, - "*=": 56, - "/=": 57, - "%=": 58, - "<<=": 59, - ">>=": 60, - ">>>=": 61, - "&=": 62, - "|=": 63, - "^=": 64, - "@": 52 + ">": 26, + "<=": 27, + ">=": 28, + "==": 29, + "!=": 30, + "===": 31, + "!==": 32, + "=>": 33, + "+": 34, + "-": 35, + "*": 36, + "/": 37, + "%": 38, + "++": 39, + "--": 40, + "<<": 41, + ">": 42, + ">>>": 43, + "&": 44, + "|": 45, + "^": 46, + "!": 47, + "~": 48, + "&&": 49, + "||": 50, + "?": 51, + ":": 52, + "=": 54, + "+=": 55, + "-=": 56, + "*=": 57, + "/=": 58, + "%=": 59, + "<<=": 60, + ">>=": 61, + ">>>=": 62, + "&=": 63, + "|=": 64, + "^=": 65, + "@": 53 }; 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,]; @@ -1708,9 +1771,9 @@ var ts; } function makeReverseMap(source) { var result = []; - for (var name_3 in source) { - if (source.hasOwnProperty(name_3)) { - result[source[name_3]] = name_3; + for (var name_4 in source) { + if (source.hasOwnProperty(name_4)) { + result[source[name_4]] = name_4; } } return result; @@ -1804,8 +1867,8 @@ var ts; // \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. + // 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 || @@ -2033,7 +2096,8 @@ var ts; ch > 127 && isUnicodeIdentifierPart(ch, languageVersion); } ts.isIdentifierPart = isIdentifierPart; - function createScanner(languageVersion, skipTrivia, text, onError, start, length) { + function createScanner(languageVersion, skipTrivia, languageVariant, text, onError, start, length) { + if (languageVariant === void 0) { languageVariant = 0; } var pos; var end; var startPos; @@ -2053,15 +2117,19 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 65 || token > 101; }, - isReservedWord: function () { return token >= 66 && token <= 101; }, + isIdentifier: function () { return token === 66 || token > 102; }, + isReservedWord: function () { return token >= 67 && token <= 102; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, reScanTemplateToken: reScanTemplateToken, + scanJsxIdentifier: scanJsxIdentifier, + reScanJsxToken: reScanJsxToken, + scanJsxToken: scanJsxToken, scan: scan, setText: setText, setScriptTarget: setScriptTarget, + setLanguageVariant: setLanguageVariant, setOnError: setOnError, setTextPos: setTextPos, tryScan: tryScan, @@ -2364,7 +2432,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 65; + return token = 66; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); @@ -2430,11 +2498,11 @@ var ts; case 33: if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 31; + return pos += 3, token = 32; } - return pos += 2, token = 29; + return pos += 2, token = 30; } - return pos++, token = 46; + return pos++, token = 47; case 34: case 39: tokenValue = scanString(); @@ -2443,44 +2511,44 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 58; + return pos += 2, token = 59; } - return pos++, token = 37; + return pos++, token = 38; case 38: if (text.charCodeAt(pos + 1) === 38) { - return pos += 2, token = 48; + return pos += 2, token = 49; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 62; + return pos += 2, token = 63; } - return pos++, token = 43; + return pos++, token = 44; case 40: return pos++, token = 16; case 41: return pos++, token = 17; case 42: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 56; + return pos += 2, token = 57; } - return pos++, token = 35; + return pos++, token = 36; case 43: if (text.charCodeAt(pos + 1) === 43) { - return pos += 2, token = 38; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 54; - } - return pos++, token = 33; - case 44: - return pos++, token = 23; - case 45: - if (text.charCodeAt(pos + 1) === 45) { return pos += 2, token = 39; } if (text.charCodeAt(pos + 1) === 61) { return pos += 2, token = 55; } return pos++, token = 34; + case 44: + return pos++, token = 23; + case 45: + if (text.charCodeAt(pos + 1) === 45) { + return pos += 2, token = 40; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 56; + } + return pos++, token = 35; case 46: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanNumber(); @@ -2533,9 +2601,9 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 57; + return pos += 2, token = 58; } - return pos++, token = 36; + return pos++, token = 37; case 48: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) { pos += 2; @@ -2583,7 +2651,7 @@ var ts; tokenValue = "" + scanNumber(); return token = 7; case 58: - return pos++, token = 51; + return pos++, token = 52; case 59: return pos++, token = 22; case 60: @@ -2598,12 +2666,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 60) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 59; + return pos += 3, token = 60; } - return pos += 2, token = 40; + return pos += 2, token = 41; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 26; + return pos += 2, token = 27; + } + if (text.charCodeAt(pos + 1) === 47 && languageVariant === 1) { + return pos += 2, token = 25; } return pos++, token = 24; case 61: @@ -2618,14 +2689,14 @@ var ts; } if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 30; + return pos += 3, token = 31; } - return pos += 2, token = 28; + return pos += 2, token = 29; } if (text.charCodeAt(pos + 1) === 62) { - return pos += 2, token = 32; + return pos += 2, token = 33; } - return pos++, token = 53; + return pos++, token = 54; case 62: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -2636,34 +2707,34 @@ var ts; return token = 6; } } - return pos++, token = 25; + return pos++, token = 26; case 63: - return pos++, token = 50; + return pos++, token = 51; case 91: return pos++, token = 18; case 93: return pos++, token = 19; case 94: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 64; + return pos += 2, token = 65; } - return pos++, token = 45; + return pos++, token = 46; case 123: return pos++, token = 14; case 124: if (text.charCodeAt(pos + 1) === 124) { - return pos += 2, token = 49; + return pos += 2, token = 50; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 63; + return pos += 2, token = 64; } - return pos++, token = 44; + return pos++, token = 45; case 125: return pos++, token = 15; case 126: - return pos++, token = 47; + return pos++, token = 48; case 64: - return pos++, token = 52; + return pos++, token = 53; case 92: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { @@ -2699,27 +2770,27 @@ var ts; } } function reScanGreaterToken() { - if (token === 25) { + if (token === 26) { if (text.charCodeAt(pos) === 62) { if (text.charCodeAt(pos + 1) === 62) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 61; + return pos += 3, token = 62; } - return pos += 2, token = 42; + return pos += 2, token = 43; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 60; + return pos += 2, token = 61; } - return pos++, token = 41; + return pos++, token = 42; } if (text.charCodeAt(pos) === 61) { - return pos++, token = 27; + return pos++, token = 28; } } return token; } function reScanSlashToken() { - if (token === 36 || token === 57) { + if (token === 37 || token === 58) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -2767,6 +2838,53 @@ var ts; pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } + function reScanJsxToken() { + pos = tokenPos = startPos; + return token = scanJsxToken(); + } + function scanJsxToken() { + startPos = tokenPos = pos; + if (pos >= end) { + return token = 1; + } + var char = text.charCodeAt(pos); + if (char === 60) { + if (text.charCodeAt(pos + 1) === 47) { + pos += 2; + return token = 25; + } + pos++; + return token = 24; + } + if (char === 123) { + pos++; + return token = 14; + } + while (pos < end) { + pos++; + char = text.charCodeAt(pos); + if ((char === 123) || (char === 60)) { + break; + } + } + return token = 233; + } + function scanJsxIdentifier() { + if (token === 66) { + var firstCharPosition = pos; + while (pos < end) { + var ch = text.charCodeAt(pos); + if (ch === 45 || ((firstCharPosition === pos) ? isIdentifierStart(ch) : isIdentifierPart(ch))) { + pos++; + } + else { + break; + } + } + tokenValue += text.substr(firstCharPosition, pos - firstCharPosition); + } + return token; + } function speculationHelper(callback, isLookahead) { var savePos = pos; var saveStartPos = startPos; @@ -2802,6 +2920,9 @@ var ts; function setScriptTarget(scriptTarget) { languageVersion = scriptTarget; } + function setLanguageVariant(variant) { + languageVariant = variant; + } function setTextPos(textPos) { ts.Debug.assert(textPos >= 0); pos = textPos; @@ -2855,6 +2976,16 @@ var ts; name: "inlineSources", type: "boolean" }, + { + name: "jsx", + type: { + "preserve": 1, + "react": 2 + }, + paramType: ts.Diagnostics.KIND, + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, + error: ts.Diagnostics.Argument_for_jsx_must_be_preserve_or_react + }, { name: "listFiles", type: "boolean" @@ -3010,6 +3141,11 @@ 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", @@ -3068,10 +3204,10 @@ var ts; options[opt.name] = args[i++] || ""; break; default: - var map = opt.type; + var map_1 = opt.type; var key = (args[i++] || "").toLowerCase(); - if (ts.hasProperty(map, key)) { - options[opt.name] = map[key]; + if (ts.hasProperty(map_1, key)) { + options[opt.name] = map_1[key]; } else { errors.push(ts.createCompilerDiagnostic(opt.error)); @@ -3124,8 +3260,9 @@ var ts; } ts.parseCommandLine = parseCommandLine; function readConfigFile(fileName) { + var text = ''; try { - var text = ts.sys.readFile(fileName); + text = ts.sys.readFile(fileName); } catch (e) { return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; @@ -3199,11 +3336,22 @@ var ts; } else { var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; - var sysFiles = host.readDirectory(basePath, ".ts", exclude); + var sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)); for (var i = 0; i < sysFiles.length; i++) { - var name = sysFiles[i]; - if (!ts.fileExtensionIs(name, ".d.ts") || !ts.contains(sysFiles, name.substr(0, name.length - 5) + ".ts")) { - fileNames.push(name); + var name_5 = sysFiles[i]; + if (ts.fileExtensionIs(name_5, ".d.ts")) { + var baseName = name_5.substr(0, name_5.length - ".d.ts".length); + if (!ts.contains(sysFiles, baseName + ".tsx") && !ts.contains(sysFiles, baseName + ".ts")) { + fileNames.push(name_5); + } + } + else if (ts.fileExtensionIs(name_5, ".ts")) { + if (!ts.contains(sysFiles, name_5 + "x")) { + fileNames.push(name_5); + } + } + else { + fileNames.push(name_5); } } } @@ -3217,10 +3365,12 @@ var ts; (function (ts) { function getDeclarationOfKind(symbol, kind) { var declarations = symbol.declarations; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; - if (declaration.kind === kind) { - return declaration; + if (declarations) { + for (var _i = 0; _i < declarations.length; _i++) { + var declaration = declarations[_i]; + if (declaration.kind === kind) { + return declaration; + } } } return undefined; @@ -3261,21 +3411,21 @@ var ts; ts.getFullWidth = getFullWidth; function containsParseError(node) { aggregateChildData(node); - return (node.parserContextFlags & 128) !== 0; + return (node.parserContextFlags & 64) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.parserContextFlags & 256)) { - var thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & 32) !== 0) || + if (!(node.parserContextFlags & 128)) { + var thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & 16) !== 0) || ts.forEachChild(node, containsParseError); if (thisNodeOrAnySubNodesHasError) { - node.parserContextFlags |= 128; + node.parserContextFlags |= 64; } - node.parserContextFlags |= 256; + node.parserContextFlags |= 128; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 230) { + while (node && node.kind !== 245) { node = node.parent; } return node; @@ -3300,7 +3450,7 @@ var ts; if (!node) { return true; } - return node.pos === node.end && node.kind !== 1; + return node.pos === node.end && node.pos >= 0 && node.kind !== 1; } ts.nodeIsMissing = nodeIsMissing; function nodeIsPresent(node) { @@ -3321,12 +3471,13 @@ var ts; return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end); } ts.getNonDecoratorTokenPosOfNode = getNonDecoratorTokenPosOfNode; - function getSourceTextOfNodeFromSourceFile(sourceFile, node) { + function getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia) { + if (includeTrivia === void 0) { includeTrivia = false; } if (nodeIsMissing(node)) { return ""; } var text = sourceFile.text; - return text.substring(ts.skipTrivia(text, node.pos), node.end); + return text.substring(includeTrivia ? node.pos : ts.skipTrivia(text, node.pos), node.end); } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function getTextOfNodeFromSourceText(sourceText, node) { @@ -3336,8 +3487,9 @@ var ts; return sourceText.substring(ts.skipTrivia(sourceText, node.pos), node.end); } ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText; - function getTextOfNode(node) { - return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node); + function getTextOfNode(node, includeTrivia) { + if (includeTrivia === void 0) { includeTrivia = false; } + return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); } ts.getTextOfNode = getTextOfNode; function escapeIdentifier(identifier) { @@ -3353,7 +3505,7 @@ var ts; } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { - return (getCombinedNodeFlags(declaration) & 12288) !== 0 || + return (getCombinedNodeFlags(declaration) & 49152) !== 0 || isCatchClauseVariableDeclaration(declaration); } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; @@ -3364,15 +3516,15 @@ var ts; return current; } switch (current.kind) { - case 230: - case 210: - case 226: - case 208: - case 189: - case 190: - case 191: + case 245: + case 217: + case 241: + case 215: + case 196: + case 197: + case 198: return current; - case 182: + case 189: if (!isFunctionLike(current.parent)) { return current; } @@ -3383,9 +3535,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 201 && + declaration.kind === 208 && declaration.parent && - declaration.parent.kind === 226; + declaration.parent.kind === 241; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; function declarationNameToString(name) { @@ -3412,7 +3564,7 @@ var ts; } ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; function getSpanOfTokenAtPosition(sourceFile, pos) { - var scanner = ts.createScanner(sourceFile.languageVersion, true, sourceFile.text, undefined, pos); + var scanner = ts.createScanner(sourceFile.languageVersion, true, sourceFile.languageVariant, sourceFile.text, undefined, pos); scanner.scan(); var start = scanner.getTokenPos(); return ts.createTextSpanFromBounds(start, scanner.getTextPos()); @@ -3421,22 +3573,22 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 230: + case 245: 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 201: - case 155: - case 204: - case 177: - case 205: case 208: - case 207: - case 229: - case 203: - case 165: + case 160: + case 211: + case 183: + case 212: + case 215: + case 214: + case 244: + case 210: + case 170: errorNode = node.name; break; } @@ -3454,15 +3606,15 @@ var ts; } ts.isExternalModule = isExternalModule; function isDeclarationFile(file) { - return (file.flags & 2048) !== 0; + return (file.flags & 8192) !== 0; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 207 && isConst(node); + return node.kind === 214 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 155 || isBindingPattern(node))) { + while (node && (node.kind === 160 || isBindingPattern(node))) { node = node.parent; } return node; @@ -3470,33 +3622,33 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 201) { + if (node.kind === 208) { node = node.parent; } - if (node && node.kind === 202) { + if (node && node.kind === 209) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 183) { + if (node && node.kind === 190) { flags |= node.flags; } return flags; } ts.getCombinedNodeFlags = getCombinedNodeFlags; function isConst(node) { - return !!(getCombinedNodeFlags(node) & 8192); + return !!(getCombinedNodeFlags(node) & 32768); } ts.isConst = isConst; function isLet(node) { - return !!(getCombinedNodeFlags(node) & 4096); + return !!(getCombinedNodeFlags(node) & 16384); } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 185 && node.expression.kind === 8; + return node.kind === 192 && node.expression.kind === 8; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { - if (node.kind === 131 || node.kind === 130) { + if (node.kind === 135 || node.kind === 134) { return ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)); } else { @@ -3515,68 +3667,68 @@ var ts; ts.getJsDocComments = getJsDocComments; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (144 <= node.kind && node.kind <= 152) { + if (148 <= node.kind && node.kind <= 157) { return true; } switch (node.kind) { - case 112: - case 121: - case 123: - case 113: - case 124: - return true; - case 99: - return node.parent.kind !== 169; - case 8: - return node.parent.kind === 131; - case 179: - return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 65: - if (node.parent.kind === 128 && node.parent.right === node) { - node = node.parent; - } - else if (node.parent.kind === 158 && node.parent.name === node) { - node = node.parent; - } + case 114: + case 125: + case 127: + case 117: case 128: - case 158: - ts.Debug.assert(node.kind === 65 || node.kind === 128 || node.kind === 158, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + return true; + case 100: + return node.parent.kind !== 174; + case 8: + return node.parent.kind === 135; + case 185: + return !isExpressionWithTypeArgumentsInClassExtendsClause(node); + case 66: + if (node.parent.kind === 132 && node.parent.right === node) { + node = node.parent; + } + else if (node.parent.kind === 163 && node.parent.name === node) { + node = node.parent; + } + case 132: + case 163: + ts.Debug.assert(node.kind === 66 || node.kind === 132 || node.kind === 163, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); var parent_1 = node.parent; - if (parent_1.kind === 147) { + if (parent_1.kind === 151) { return false; } - if (144 <= parent_1.kind && parent_1.kind <= 152) { + if (148 <= parent_1.kind && parent_1.kind <= 157) { return true; } switch (parent_1.kind) { - case 179: + case 185: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 130: - return node === parent_1.constraint; case 134: - case 133: - case 131: - case 201: + return node === parent_1.constraint; + case 138: + case 137: + case 135: + case 208: + return node === parent_1.type; + case 210: + case 170: + case 171: + case 141: + case 140: + case 139: + case 142: + case 143: + return node === parent_1.type; + case 144: + case 145: + case 146: + return node === parent_1.type; + case 168: return node === parent_1.type; - case 203: case 165: case 166: - case 137: - case 136: - case 135: - case 138: - case 139: - return node === parent_1.type; - case 140: - case 141: - case 142: - return node === parent_1.type; - case 163: - return node === parent_1.type; - case 160: - case 161: return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 162: + case 167: return false; } } @@ -3587,23 +3739,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 194: + case 201: return visitor(node); - case 210: - case 182: - case 186: - case 187: - case 188: + case 217: case 189: - case 190: - case 191: + case 193: + case 194: case 195: case 196: - case 223: - case 224: case 197: - case 199: - case 226: + case 198: + case 202: + case 203: + case 238: + case 239: + case 204: + case 206: + case 241: return ts.forEachChild(node, traverse); } } @@ -3613,24 +3765,24 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 175: + case 181: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 207: - case 205: - case 208: - case 206: - case 204: - case 177: + case 214: + case 212: + case 215: + case 213: + case 211: + case 183: return; default: if (isFunctionLike(node)) { - var name_4 = node.name; - if (name_4 && name_4.kind === 129) { - traverse(name_4.expression); + var name_6 = node.name; + if (name_6 && name_6.kind === 133) { + traverse(name_6.expression); return; } } @@ -3644,14 +3796,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 155: - case 229: - case 131: - case 227: - case 134: - case 133: - case 228: - case 201: + case 160: + case 244: + case 135: + case 242: + case 138: + case 137: + case 243: + case 208: return true; } } @@ -3659,29 +3811,29 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 138 || node.kind === 139); + return node && (node.kind === 142 || node.kind === 143); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 204 || node.kind === 177); + return node && (node.kind === 211 || node.kind === 183); } ts.isClassLike = isClassLike; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 137: - case 165: - case 203: - case 166: - case 136: - case 135: - case 138: - case 139: - case 140: case 141: + case 170: + case 210: + case 171: + case 140: + case 139: case 142: + case 143: + case 144: case 145: case 146: + case 149: + case 150: return true; } } @@ -3689,11 +3841,11 @@ var ts; } ts.isFunctionLike = isFunctionLike; function isFunctionBlock(node) { - return node && node.kind === 182 && isFunctionLike(node.parent); + return node && node.kind === 189 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 136 && node.parent.kind === 157; + return node && node.kind === 140 && node.parent.kind === 162; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -3721,36 +3873,36 @@ var ts; return undefined; } switch (node.kind) { - case 129: + case 133: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 132: - if (node.parent.kind === 131 && isClassElement(node.parent.parent)) { + case 136: + if (node.parent.kind === 135 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 166: + case 171: if (!includeArrowFunctions) { continue; } - case 203: - case 165: - case 208: - case 134: - case 133: - case 136: - case 135: - case 137: + case 210: + case 170: + case 215: case 138: + case 137: + case 140: case 139: - case 207: - case 230: + case 141: + case 142: + case 143: + case 214: + case 245: return node; } } @@ -3762,40 +3914,55 @@ var ts; if (!node) return node; switch (node.kind) { - case 129: + case 133: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 132: - if (node.parent.kind === 131 && isClassElement(node.parent.parent)) { + case 136: + if (node.parent.kind === 135 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 203: - case 165: - case 166: + case 210: + case 170: + case 171: if (!includeFunctions) { continue; } - case 134: - case 133: - case 136: - case 135: - case 137: case 138: + case 137: + case 140: case 139: + case 141: + case 142: + case 143: return node; } } } ts.getSuperContainer = getSuperContainer; + function getEntityNameFromTypeNode(node) { + if (node) { + switch (node.kind) { + case 148: + return node.typeName; + case 185: + return node.expression; + case 66: + case 132: + return node; + } + } + return undefined; + } + ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { - if (node.kind === 162) { + if (node.kind === 167) { return node.tag; } return node.expression; @@ -3803,40 +3970,40 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 204: + case 211: return true; - case 134: - return node.parent.kind === 204; - case 131: - return node.parent.body && node.parent.parent.kind === 204; case 138: - case 139: - case 136: - return node.body && node.parent.kind === 204; + return node.parent.kind === 211; + case 135: + return node.parent.body && node.parent.parent.kind === 211; + case 142: + case 143: + case 140: + return node.body && node.parent.kind === 211; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 204: - if (node.decorators) { - return true; - } - return false; - case 134: - case 131: + case 211: if (node.decorators) { return true; } return false; case 138: + case 135: + if (node.decorators) { + return true; + } + return false; + case 142: if (node.body && node.decorators) { return true; } return false; - case 136: - case 139: + case 140: + case 143: if (node.body && node.decorators) { return true; } @@ -3847,10 +4014,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 204: + case 211: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 136: - case 139: + case 140: + case 143: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -3862,88 +4029,92 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function isExpression(node) { switch (node.kind) { - case 93: - case 91: - case 89: - case 95: - case 80: + case 94: + case 92: + case 90: + case 96: + case 81: case 9: - case 156: - case 157: - case 158: - case 159: - case 160: case 161: case 162: case 163: case 164: case 165: - case 177: case 166: - case 169: case 167: + case 186: case 168: + case 169: case 170: + case 183: case 171: + case 174: case 172: case 173: case 176: - case 174: - case 10: + case 177: case 178: - case 175: + case 179: + case 182: + case 180: + case 10: + case 184: + case 230: + case 231: + case 181: return true; - case 128: - while (node.parent.kind === 128) { + case 132: + while (node.parent.kind === 132) { node = node.parent; } - return node.parent.kind === 147; - case 65: - if (node.parent.kind === 147) { + return node.parent.kind === 151; + case 66: + if (node.parent.kind === 151) { return true; } case 7: case 8: var parent_2 = node.parent; switch (parent_2.kind) { - case 201: - case 131: - case 134: - case 133: - case 229: - case 227: - case 155: + case 208: + case 135: + case 138: + case 137: + case 244: + case 242: + case 160: return parent_2.initializer === node; - case 185: - case 186: - case 187: - case 188: + case 192: + case 193: case 194: case 195: - case 196: - case 223: - case 198: - case 196: + case 201: + case 202: + case 203: + case 238: + case 205: + case 203: return parent_2.expression === node; - case 189: + case 196: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 202) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 209) || forStatement.condition === node || forStatement.incrementor === node; - case 190: - case 191: + case 197: + case 198: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 202) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 209) || forInStatement.expression === node; - case 163: + case 168: + case 186: return node === parent_2.expression; - case 180: + case 187: return node === parent_2.expression; - case 129: + case 133: return node === parent_2.expression; - case 132: + case 136: return true; - case 179: + case 185: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -3961,7 +4132,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 211 && node.moduleReference.kind === 222; + return node.kind === 218 && node.moduleReference.kind === 229; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -3970,20 +4141,20 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 211 && node.moduleReference.kind !== 222; + return node.kind === 218 && node.moduleReference.kind !== 229; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function getExternalModuleName(node) { - if (node.kind === 212) { + if (node.kind === 219) { return node.moduleSpecifier; } - if (node.kind === 211) { + if (node.kind === 218) { var reference = node.moduleReference; - if (reference.kind === 222) { + if (reference.kind === 229) { return reference.expression; } } - if (node.kind === 218) { + if (node.kind === 225) { return node.moduleSpecifier; } } @@ -3991,15 +4162,15 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 131: - return node.questionToken !== undefined; - case 136: case 135: return node.questionToken !== undefined; - case 228: - case 227: - case 134: - case 133: + case 140: + case 139: + return node.questionToken !== undefined; + case 243: + case 242: + case 138: + case 137: return node.questionToken !== undefined; } } @@ -4007,9 +4178,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 243 && + return node.kind === 258 && node.parameters.length > 0 && - node.parameters[0].type.kind === 245; + node.parameters[0].type.kind === 260; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -4023,27 +4194,27 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 251); + return getJSDocTag(node, 266); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 250); + return getJSDocTag(node, 265); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 252); + return getJSDocTag(node, 267); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 65) { + if (parameter.name && parameter.name.kind === 66) { var parameterName = parameter.name.text; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 249) { + if (t.kind === 264) { var parameterTag = t; - var name_5 = parameterTag.preParameterName || parameterTag.postParameterName; - if (name_5.text === parameterName) { + var name_7 = parameterTag.preParameterName || parameterTag.postParameterName; + if (name_7.text === parameterName) { return t; } } @@ -4058,13 +4229,13 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { if (node) { - if (node.parserContextFlags & 64) { - if (node.type && node.type.kind === 244) { + if (node.parserContextFlags & 32) { + if (node.type && node.type.kind === 259) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 244; + return paramTag.typeExpression.type.kind === 259; } } return node.dotDotDotToken !== undefined; @@ -4085,12 +4256,12 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 154 || node.kind === 153); + return !!node && (node.kind === 159 || node.kind === 158); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { while (node) { - if (node.flags & (2 | 2048)) { + if (node.flags & (2 | 8192)) { return true; } node = node.parent; @@ -4100,34 +4271,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 166: - case 155: - case 204: - case 177: - case 137: - case 207: - case 229: - case 220: - case 203: - case 165: - case 138: - case 213: + case 171: + case 160: case 211: - case 216: - case 205: - case 136: - case 135: - case 208: + case 183: + case 141: case 214: - case 131: + case 244: case 227: - case 134: - case 133: + case 210: + case 170: + case 142: + case 220: + case 218: + case 223: + case 212: + case 140: case 139: - case 228: - case 206: - case 130: - case 201: + case 215: + case 221: + case 135: + case 242: + case 138: + case 137: + case 143: + case 243: + case 213: + case 134: + case 208: return true; } return false; @@ -4135,25 +4306,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 193: - case 192: case 200: - case 187: - case 185: - case 184: - case 190: - case 191: - case 189: - case 186: - case 197: - case 194: - case 196: - case 94: case 199: - case 183: - case 188: + case 207: + case 194: + case 192: + case 191: + case 197: + case 198: + case 196: + case 193: + case 204: + case 201: + case 203: + case 95: + case 206: + case 190: case 195: - case 217: + case 202: + case 224: return true; default: return false; @@ -4162,13 +4333,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 137: - case 134: - case 136: + case 141: case 138: - case 139: - case 135: + case 140: case 142: + case 143: + case 139: + case 146: return true; default: return false; @@ -4176,11 +4347,11 @@ var ts; } ts.isClassElement = isClassElement; function isDeclarationName(name) { - if (name.kind !== 65 && name.kind !== 8 && name.kind !== 7) { + if (name.kind !== 66 && name.kind !== 8 && name.kind !== 7) { return false; } var parent = name.parent; - if (parent.kind === 216 || parent.kind === 220) { + if (parent.kind === 223 || parent.kind === 227) { if (parent.propertyName) { return true; } @@ -4194,54 +4365,54 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 134: - case 133: - case 136: - case 135: case 138: + case 137: + case 140: case 139: - case 229: - case 227: - case 158: + case 142: + case 143: + case 244: + case 242: + case 163: return parent.name === node; - case 128: + case 132: if (parent.right === node) { - while (parent.kind === 128) { + while (parent.kind === 132) { parent = parent.parent; } - return parent.kind === 147; + return parent.kind === 151; } return false; - case 155: - case 216: + case 160: + case 223: return parent.propertyName === node; - case 220: + case 227: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 211 || - node.kind === 213 && !!node.name || - node.kind === 214 || - node.kind === 216 || - node.kind === 220 || - node.kind === 217 && node.expression.kind === 65; + return node.kind === 218 || + node.kind === 220 && !!node.name || + node.kind === 221 || + node.kind === 223 || + node.kind === 227 || + node.kind === 224 && node.expression.kind === 66; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 79); + var heritageClause = getHeritageClause(node.heritageClauses, 80); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 102); + var heritageClause = getHeritageClause(node.heritageClauses, 103); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 79); + var heritageClause = getHeritageClause(node.heritageClauses, 80); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -4310,28 +4481,32 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 66 <= token && token <= 127; + return 67 <= token && token <= 131; } ts.isKeyword = isKeyword; function isTrivia(token) { return 2 <= token && token <= 6; } ts.isTrivia = isTrivia; + function isAsyncFunctionLike(node) { + return isFunctionLike(node) && (node.flags & 512) !== 0 && !isAccessor(node); + } + ts.isAsyncFunctionLike = isAsyncFunctionLike; function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 129 && + declaration.name.kind === 133 && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; function isWellKnownSymbolSyntactically(node) { - return node.kind === 158 && isESSymbolIdentifier(node.expression); + return node.kind === 163 && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 65 || name.kind === 8 || name.kind === 7) { + if (name.kind === 66 || name.kind === 8 || name.kind === 7) { return name.text; } - if (name.kind === 129) { + if (name.kind === 133) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -4346,19 +4521,21 @@ var ts; } ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; function isESSymbolIdentifier(node) { - return node.kind === 65 && node.text === "Symbol"; + return node.kind === 66 && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isModifier(token) { switch (token) { - case 108: - case 106: - case 107: - case 109: - case 78: + case 112: case 115: - case 70: - case 73: + case 71: + case 119: + case 74: + case 79: + case 109: + case 107: + case 108: + case 110: return true; } return false; @@ -4366,18 +4543,18 @@ var ts; ts.isModifier = isModifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 131; + return root.kind === 135; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 155) { + while (node.kind === 160) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 208 || n.kind === 230; + return isFunctionLike(n) || n.kind === 215 || n.kind === 245; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -4386,8 +4563,6 @@ var ts; ts.nodeIsSynthesized = nodeIsSynthesized; function createSynthesizedNode(kind, startsOnNewLine) { var node = ts.createNode(kind); - node.pos = -1; - node.end = -1; node.startsOnNewLine = startsOnNewLine; return node; } @@ -4487,6 +4662,11 @@ var ts; } } ts.escapeString = escapeString; + function isIntrinsicJsxName(name) { + var ch = name.substr(0, 1); + return ch.toLowerCase() === ch; + } + ts.isIntrinsicJsxName = isIntrinsicJsxName; function get16BitUnicodeEscapeSequence(charCode) { var hexCharCode = charCode.toString(16).toUpperCase(); var paddedHexCode = ("0000" + hexCharCode).slice(-4); @@ -4601,12 +4781,16 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 137 && nodeIsPresent(member.body)) { + if (member.kind === 141 && nodeIsPresent(member.body)) { return member; } }); } ts.getFirstConstructorWithBody = getFirstConstructorWithBody; + function getSetAccessorTypeAnnotationNode(accessor) { + return accessor && accessor.parameters.length > 0 && accessor.parameters[0].type; + } + ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; function shouldEmitToOwnFile(sourceFile, compilerOptions) { if (!isDeclarationFile(sourceFile)) { if ((isExternalModule(sourceFile) || !compilerOptions.out)) { @@ -4624,10 +4808,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 138) { + if (accessor.kind === 142) { getAccessor = accessor; } - else if (accessor.kind === 139) { + else if (accessor.kind === 143) { setAccessor = accessor; } else { @@ -4636,7 +4820,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 138 || member.kind === 139) + if ((member.kind === 142 || member.kind === 143) && (member.flags & 128) === (accessor.flags & 128)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -4647,10 +4831,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 138 && !getAccessor) { + if (member.kind === 142 && !getAccessor) { getAccessor = member; } - if (member.kind === 139 && !setAccessor) { + if (member.kind === 143 && !setAccessor) { setAccessor = member; } } @@ -4756,14 +4940,16 @@ var ts; ts.writeCommentRange = writeCommentRange; function modifierToFlag(token) { switch (token) { - case 109: return 128; - case 108: return 16; - case 107: return 64; - case 106: return 32; - case 78: return 1; - case 115: return 2; - case 70: return 8192; - case 73: return 256; + case 110: return 128; + case 109: return 16; + case 108: return 64; + case 107: return 32; + case 112: return 256; + case 79: return 1; + case 119: return 2; + case 71: return 32768; + case 74: return 1024; + case 115: return 512; } return 0; } @@ -4771,27 +4957,29 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 158: - case 159: - case 161: - case 160: - case 162: - case 156: + case 163: case 164: - case 157: - case 177: + case 166: case 165: - case 65: + case 230: + case 231: + case 167: + case 161: + case 169: + case 162: + case 183: + case 170: + case 66: case 9: case 7: case 8: case 10: - case 174: - case 80: - case 89: - case 93: - case 95: - case 91: + case 180: + case 81: + case 90: + case 94: + case 96: + case 92: return true; } } @@ -4799,12 +4987,12 @@ var ts; } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isAssignmentOperator(token) { - return token >= 53 && token <= 64; + return token >= 54 && token <= 65; } ts.isAssignmentOperator = isAssignmentOperator; function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 179 && - node.parent.token === 79 && + return node.kind === 185 && + node.parent.token === 80 && isClassLike(node.parent.parent); } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; @@ -4813,10 +5001,10 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 65) { + if (node.kind === 66) { return true; } - else if (node.kind === 158) { + else if (node.kind === 163) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { @@ -4824,22 +5012,25 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 128 && node.parent.right === node) || - (node.parent.kind === 158 && node.parent.name === node); + return (node.parent.kind === 132 && node.parent.right === node) || + (node.parent.kind === 163 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function getLocalSymbolForExportDefault(symbol) { - return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 256) ? symbol.valueDeclaration.localSymbol : undefined; + return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; function isJavaScript(fileName) { return ts.fileExtensionIs(fileName, ".js"); } ts.isJavaScript = isJavaScript; + function isTsx(fileName) { + return ts.fileExtensionIs(fileName, ".tsx"); + } + ts.isTsx = isTsx; function getExpandedCharCodes(input) { var output = []; var length = input.length; - var leadSurrogate = undefined; for (var i = 0; i < length; i++) { var charCode = input.charCodeAt(i); if (charCode < 0x80) { @@ -5028,9 +5219,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 130) { + if (d && d.kind === 134) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 205) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 212) { return current; } } @@ -5042,7 +5233,7 @@ var ts; /// var ts; (function (ts) { - var nodeConstructors = new Array(254); + var nodeConstructors = new Array(269); ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -5080,20 +5271,20 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 128: + case 132: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 130: + case 134: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 131: - case 134: - case 133: - case 227: - case 228: - case 201: - case 155: + case 135: + case 138: + case 137: + case 242: + case 243: + case 208: + case 160: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -5102,24 +5293,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); + case 149: + case 150: + case 144: case 145: case 146: - case 140: - case 141: - case 142: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 136: - case 135: - case 137: - case 138: + case 140: case 139: - case 165: - case 203: - case 166: + case 141: + case 142: + case 143: + case 170: + case 210: + case 171: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -5130,267 +5321,290 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 144: + case 148: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 143: + case 147: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 147: - return visitNode(cbNode, node.exprName); - case 148: - return visitNodes(cbNodes, node.members); - case 149: - return visitNode(cbNode, node.elementType); - case 150: - return visitNodes(cbNodes, node.elementTypes); case 151: - return visitNodes(cbNodes, node.types); + return visitNode(cbNode, node.exprName); case 152: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.members); case 153: + return visitNode(cbNode, node.elementType); case 154: - return visitNodes(cbNodes, node.elements); + return visitNodes(cbNodes, node.elementTypes); + case 155: case 156: - return visitNodes(cbNodes, node.elements); + return visitNodes(cbNodes, node.types); case 157: - return visitNodes(cbNodes, node.properties); + return visitNode(cbNode, node.type); case 158: + case 159: + return visitNodes(cbNodes, node.elements); + case 161: + return visitNodes(cbNodes, node.elements); + case 162: + return visitNodes(cbNodes, node.properties); + case 163: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 159: + case 164: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 160: - case 161: + case 165: + case 166: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 162: + case 167: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 163: + case 168: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 164: - return visitNode(cbNode, node.expression); - case 167: - return visitNode(cbNode, node.expression); - case 168: - return visitNode(cbNode, node.expression); case 169: return visitNode(cbNode, node.expression); - case 170: + case 172: + return visitNode(cbNode, node.expression); + case 173: + return visitNode(cbNode, node.expression); + case 174: + return visitNode(cbNode, node.expression); + case 176: return visitNode(cbNode, node.operand); - case 175: + case 181: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 171: + case 175: + return visitNode(cbNode, node.expression); + case 177: return visitNode(cbNode, node.operand); - case 172: + case 178: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 173: + case 186: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.type); + case 179: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 176: - return visitNode(cbNode, node.expression); case 182: - case 209: + return visitNode(cbNode, node.expression); + case 189: + case 216: return visitNodes(cbNodes, node.statements); - case 230: + case 245: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 183: + case 190: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 202: + case 209: return visitNodes(cbNodes, node.declarations); - case 185: + case 192: return visitNode(cbNode, node.expression); - case 186: + case 193: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 187: + case 194: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 188: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 189: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.condition) || - visitNode(cbNode, node.incrementor) || - visitNode(cbNode, node.statement); - case 190: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 191: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); - case 192: - case 193: - return visitNode(cbNode, node.label); - case 194: - return visitNode(cbNode, node.expression); case 195: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 196: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.caseBlock); - case 210: - return visitNodes(cbNodes, node.clauses); - case 223: - return visitNode(cbNode, node.expression) || - visitNodes(cbNodes, node.statements); - case 224: - return visitNodes(cbNodes, node.statements); + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.condition) || + visitNode(cbNode, node.incrementor) || + visitNode(cbNode, node.statement); case 197: - return visitNode(cbNode, node.label) || + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 198: - return visitNode(cbNode, node.expression); + return visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); case 199: + case 200: + return visitNode(cbNode, node.label); + case 201: + return visitNode(cbNode, node.expression); + case 202: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 203: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.caseBlock); + case 217: + return visitNodes(cbNodes, node.clauses); + case 238: + return visitNode(cbNode, node.expression) || + visitNodes(cbNodes, node.statements); + case 239: + return visitNodes(cbNodes, node.statements); + case 204: + return visitNode(cbNode, node.label) || + visitNode(cbNode, node.statement); + case 205: + return visitNode(cbNode, node.expression); + case 206: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 226: + case 241: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 132: + case 136: return visitNode(cbNode, node.expression); - case 204: - case 177: + case 211: + case 183: 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 205: + case 212: 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 206: + case 213: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 207: + case 214: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 229: + case 244: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 208: + case 215: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 211: + case 218: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 212: + case 219: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 213: + case 220: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 214: + case 221: return visitNode(cbNode, node.name); - case 215: - case 219: + case 222: + case 226: return visitNodes(cbNodes, node.elements); - case 218: + case 225: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 216: - case 220: + case 223: + case 227: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 217: + case 224: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 174: - return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); case 180: + return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); + case 187: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 129: + case 133: return visitNode(cbNode, node.expression); - case 225: + case 240: return visitNodes(cbNodes, node.types); - case 179: + case 185: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 222: + case 229: return visitNode(cbNode, node.expression); - case 221: + case 228: return visitNodes(cbNodes, node.decorators); + case 230: + return visitNode(cbNode, node.openingElement) || + visitNodes(cbNodes, node.children) || + visitNode(cbNode, node.closingElement); case 231: - return visitNode(cbNode, node.type); + case 232: + return visitNode(cbNode, node.tagName) || + visitNodes(cbNodes, node.attributes); case 235: - return visitNodes(cbNodes, node.types); - case 236: - return visitNodes(cbNodes, node.types); - case 234: - return visitNode(cbNode, node.elementType); - case 238: - return visitNode(cbNode, node.type); - case 237: - return visitNode(cbNode, node.type); - case 239: - return visitNodes(cbNodes, node.members); - case 241: return visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.typeArguments); - case 242: - return visitNode(cbNode, node.type); - case 243: - return visitNodes(cbNodes, node.parameters) || - visitNode(cbNode, node.type); - case 244: - return visitNode(cbNode, node.type); - case 245: - return visitNode(cbNode, node.type); + visitNode(cbNode, node.initializer); + case 236: + return visitNode(cbNode, node.expression); + case 237: + return visitNode(cbNode, node.expression); + case 234: + return visitNode(cbNode, node.tagName); case 246: return visitNode(cbNode, node.type); - case 240: + case 250: + return visitNodes(cbNodes, node.types); + case 251: + return visitNodes(cbNodes, node.types); + case 249: + return visitNode(cbNode, node.elementType); + case 253: + return visitNode(cbNode, node.type); + case 252: + return visitNode(cbNode, node.type); + case 254: + return visitNodes(cbNodes, node.members); + case 256: + return visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.typeArguments); + case 257: + return visitNode(cbNode, node.type); + case 258: + return visitNodes(cbNodes, node.parameters) || + visitNode(cbNode, node.type); + case 259: + return visitNode(cbNode, node.type); + case 260: + return visitNode(cbNode, node.type); + case 261: + return visitNode(cbNode, node.type); + case 255: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 247: + case 262: return visitNodes(cbNodes, node.tags); - case 249: + case 264: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 250: + case 265: return visitNode(cbNode, node.typeExpression); - case 251: + case 266: return visitNode(cbNode, node.typeExpression); - case 252: + case 267: return visitNodes(cbNodes, node.typeParameters); } } @@ -5418,7 +5632,7 @@ var ts; var Parser; (function (Parser) { var scanner = ts.createScanner(2, true); - var disallowInAndDecoratorContext = 2 | 16; + var disallowInAndDecoratorContext = 1 | 4; var sourceFile; var parseDiagnostics; var syntaxCursor; @@ -5445,11 +5659,12 @@ var ts; identifiers = {}; identifierCount = 0; nodeCount = 0; - contextFlags = ts.isJavaScript(fileName) ? 64 : 0; + contextFlags = ts.isJavaScript(fileName) ? 32 : 0; parseErrorBeforeNextFinishedNode = false; scanner.setText(sourceText); scanner.setOnError(scanError); scanner.setScriptTarget(languageVersion); + scanner.setLanguageVariant(ts.isTsx(fileName) ? 1 : 0); } function clearState() { scanner.setText(""); @@ -5485,9 +5700,9 @@ var ts; return; function visit(node) { switch (node.kind) { - case 183: - case 203: - case 131: + case 190: + case 210: + case 135: addJSDocComment(node); } forEachChild(node, visit); @@ -5525,14 +5740,15 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(230, 0); + var sourceFile = createNode(245, 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; sourceFile.languageVersion = languageVersion; sourceFile.fileName = ts.normalizePath(fileName); - sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 2048 : 0; + sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 8192 : 0; + sourceFile.languageVariant = ts.isTsx(sourceFile.fileName) ? 1 : 0; return sourceFile; } function setContextFlag(val, flag) { @@ -5544,83 +5760,78 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 2); + setContextFlag(val, 1); } function setYieldContext(val) { - setContextFlag(val, 4); - } - function setGeneratorParameterContext(val) { - setContextFlag(val, 8); + setContextFlag(val, 2); } function setDecoratorContext(val) { - setContextFlag(val, 16); + setContextFlag(val, 4); } - function doOutsideOfContext(flags, func) { - var currentContextFlags = contextFlags & flags; - if (currentContextFlags) { - setContextFlag(false, currentContextFlags); + function setAwaitContext(val) { + setContextFlag(val, 8); + } + function doOutsideOfContext(context, func) { + var contextFlagsToClear = context & contextFlags; + if (contextFlagsToClear) { + setContextFlag(false, contextFlagsToClear); var result = func(); - setContextFlag(true, currentContextFlags); + setContextFlag(true, contextFlagsToClear); + return result; + } + return func(); + } + function doInsideOfContext(context, func) { + var contextFlagsToSet = context & ~contextFlags; + if (contextFlagsToSet) { + setContextFlag(true, contextFlagsToSet); + var result = func(); + setContextFlag(false, contextFlagsToSet); return result; } return func(); } function allowInAnd(func) { - if (contextFlags & 2) { - setDisallowInContext(false); - var result = func(); - setDisallowInContext(true); - return result; - } - return func(); + return doOutsideOfContext(1, func); } function disallowInAnd(func) { - if (contextFlags & 2) { - return func(); - } - setDisallowInContext(true); - var result = func(); - setDisallowInContext(false); - return result; + return doInsideOfContext(1, func); } function doInYieldContext(func) { - if (contextFlags & 4) { - return func(); - } - setYieldContext(true); - var result = func(); - setYieldContext(false); - return result; + return doInsideOfContext(2, func); } function doOutsideOfYieldContext(func) { - if (contextFlags & 4) { - setYieldContext(false); - var result = func(); - setYieldContext(true); - return result; - } - return func(); + return doOutsideOfContext(2, func); } function doInDecoratorContext(func) { - if (contextFlags & 16) { - return func(); - } - setDecoratorContext(true); - var result = func(); - setDecoratorContext(false); - return result; + return doInsideOfContext(4, func); + } + function doInAwaitContext(func) { + return doInsideOfContext(8, func); + } + function doOutsideOfAwaitContext(func) { + return doOutsideOfContext(8, func); + } + function doInYieldAndAwaitContext(func) { + return doInsideOfContext(2 | 8, func); + } + function doOutsideOfYieldAndAwaitContext(func) { + return doOutsideOfContext(2 | 8, func); + } + function inContext(flags) { + return (contextFlags & flags) !== 0; } function inYieldContext() { - return (contextFlags & 4) !== 0; - } - function inGeneratorParameterContext() { - return (contextFlags & 8) !== 0; + return inContext(2); } function inDisallowInContext() { - return (contextFlags & 2) !== 0; + return inContext(1); } function inDecoratorContext() { - return (contextFlags & 16) !== 0; + return inContext(4); + } + function inAwaitContext() { + return inContext(8); } function parseErrorAtCurrentToken(message, arg0) { var start = scanner.getTokenPos(); @@ -5659,6 +5870,9 @@ var ts; function reScanTemplateToken() { return token = scanner.reScanTemplateToken(); } + function scanJsxIdentifier() { + return token = scanner.scanJsxIdentifier(); + } function speculationHelper(callback, isLookAhead) { var saveToken = token; var saveParseDiagnosticsLength = parseDiagnostics.length; @@ -5682,13 +5896,16 @@ var ts; return speculationHelper(callback, false); } function isIdentifier() { - if (token === 65) { + if (token === 66) { return true; } - if (token === 110 && inYieldContext()) { + if (token === 111 && inYieldContext()) { return false; } - return token > 101; + if (token === 116 && inAwaitContext()) { + return false; + } + return token > 102; } function parseExpected(kind, diagnosticMessage) { if (token === kind) { @@ -5759,7 +5976,7 @@ var ts; } if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.parserContextFlags |= 32; + node.parserContextFlags |= 16; } return node; } @@ -5781,15 +5998,15 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(65); - if (token !== 65) { + var node = createNode(66); + if (token !== 66) { node.originalKeywordKind = token; } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(65, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(66, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -5821,16 +6038,9 @@ var ts; return token === 8 || token === 7 || isIdentifierOrKeyword(); } function parseComputedPropertyName() { - var node = createNode(129); + var node = createNode(133); parseExpected(18); - var yieldContext = inYieldContext(); - if (inGeneratorParameterContext()) { - setYieldContext(false); - } node.expression = allowInAnd(parseExpression); - if (inGeneratorParameterContext()) { - setYieldContext(yieldContext); - } parseExpected(19); return finishNode(node); } @@ -5838,17 +6048,17 @@ var ts; return token === t && tryParse(nextTokenCanFollowModifier); } function nextTokenCanFollowModifier() { - if (token === 70) { - return nextToken() === 77; + if (token === 71) { + return nextToken() === 78; } - if (token === 78) { + if (token === 79) { nextToken(); - if (token === 73) { + if (token === 74) { return lookAhead(nextTokenIsClassOrFunction); } - return token !== 35 && token !== 14 && canFollowModifier(); + return token !== 36 && token !== 14 && canFollowModifier(); } - if (token === 73) { + if (token === 74) { return nextTokenIsClassOrFunction(); } nextToken(); @@ -5860,12 +6070,12 @@ var ts; function canFollowModifier() { return token === 18 || token === 14 - || token === 35 + || token === 36 || isLiteralPropertyName(); } function nextTokenIsClassOrFunction() { nextToken(); - return token === 69 || token === 83; + return token === 70 || token === 84; } function isListElement(parsingContext, inErrorRecovery) { var node = currentNode(parsingContext); @@ -5878,7 +6088,7 @@ var ts; case 3: return !(token === 22 && inErrorRecovery) && isStartOfStatement(); case 2: - return token === 67 || token === 73; + return token === 68 || token === 74; case 4: return isStartOfTypeMember(); case 5: @@ -5886,7 +6096,7 @@ var ts; case 6: return token === 18 || isLiteralPropertyName(); case 12: - return token === 18 || token === 35 || isLiteralPropertyName(); + return token === 18 || token === 36 || isLiteralPropertyName(); case 9: return isLiteralPropertyName(); case 7: @@ -5903,25 +6113,29 @@ var ts; return isIdentifierOrPattern(); case 10: return token === 23 || token === 21 || isIdentifierOrPattern(); - case 15: + case 17: return isIdentifier(); case 11: - case 13: + case 15: return token === 23 || token === 21 || isStartOfExpression(); - case 14: - return isStartOfParameter(); case 16: - case 17: - return token === 23 || isStartOfType(); + return isStartOfParameter(); case 18: - return isHeritageClause(); case 19: - return isIdentifierOrKeyword(); + return token === 23 || isStartOfType(); case 20: + return isHeritageClause(); case 21: - case 23: - return JSDocParser.isJSDocType(); + return isIdentifierOrKeyword(); + case 13: + return isIdentifierOrKeyword() || token === 14; + case 14: + return true; case 22: + case 23: + case 25: + return JSDocParser.isJSDocType(); + case 24: return isSimplePropertyName(); } ts.Debug.fail("Non-exhaustive case in 'isListElement'."); @@ -5930,7 +6144,7 @@ var ts; ts.Debug.assert(token === 14); if (nextToken() === 15) { var next = nextToken(); - return next === 23 || next === 14 || next === 79 || next === 102; + return next === 23 || next === 14 || next === 80 || next === 103; } return true; } @@ -5938,9 +6152,13 @@ var ts; nextToken(); return isIdentifier(); } + function nextTokenIsIdentifierOrKeyword() { + nextToken(); + return isIdentifierOrKeyword(); + } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token === 102 || - token === 79) { + if (token === 103 || + token === 80) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -5961,35 +6179,39 @@ var ts; case 6: case 12: case 9: - case 19: + case 21: return token === 15; case 3: - return token === 15 || token === 67 || token === 73; + return token === 15 || token === 68 || token === 74; case 7: - return token === 14 || token === 79 || token === 102; + return token === 14 || token === 80 || token === 103; case 8: return isVariableDeclaratorListTerminator(); - case 15: - return token === 25 || token === 16 || token === 14 || token === 79 || token === 102; + case 17: + return token === 26 || token === 16 || token === 14 || token === 80 || token === 103; case 11: return token === 17 || token === 22; - case 13: - case 17: + case 15: + case 19: case 10: return token === 19; - case 14: - return token === 17 || token === 19; case 16: - return token === 25 || token === 16; + return token === 17 || token === 19; case 18: - return token === 14 || token === 15; + return token === 26 || token === 16; case 20: - return token === 17 || token === 51 || token === 15; - case 21: - return token === 25 || token === 15; - case 23: - return token === 19 || token === 15; + return token === 14 || token === 15; + case 13: + return token === 26 || token === 37; + case 14: + return token === 24 && lookAhead(nextTokenIsSlash); case 22: + return token === 17 || token === 52 || token === 15; + case 23: + return token === 26 || token === 15; + case 25: + return token === 19 || token === 15; + case 24: return token === 15; } } @@ -6000,13 +6222,13 @@ var ts; if (isInOrOfKeyword(token)) { return true; } - if (token === 32) { + if (token === 33) { return true; } return false; } function isInSomeParsingContext() { - for (var kind = 0; kind < 24; kind++) { + for (var kind = 0; kind < 26; kind++) { if (parsingContext & (1 << kind)) { if (isListElement(kind, true) || isListTerminator(kind)) { return true; @@ -6058,7 +6280,7 @@ var ts; if (ts.containsParseError(node)) { return undefined; } - var nodeContextFlags = node.parserContextFlags & 62; + var nodeContextFlags = node.parserContextFlags & 31; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -6088,32 +6310,34 @@ var ts; return isReusableTypeMember(node); case 8: return isReusableVariableDeclaration(node); - case 14: - return isReusableParameter(node); - case 18: - case 15: - case 17: case 16: + return isReusableParameter(node); + case 20: + case 17: + case 19: + case 18: case 11: case 12: case 7: + case 13: + case 14: } return false; } function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 137: + case 141: + case 146: case 142: + case 143: case 138: - case 139: - case 134: - case 181: + case 188: return true; - case 136: + case 140: var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 65 && - methodDeclaration.name.originalKeywordKind === 114; + var nameIsConstructor = methodDeclaration.name.kind === 66 && + methodDeclaration.name.originalKeywordKind === 118; return !nameIsConstructor; } } @@ -6122,8 +6346,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 223: - case 224: + case 238: + case 239: return true; } } @@ -6132,65 +6356,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 203: - case 183: - case 182: - case 186: - case 185: - case 198: - case 194: - case 196: + case 210: + case 190: + case 189: case 193: case 192: - case 190: - case 191: - case 189: - case 188: - case 195: - case 184: + case 205: + case 201: + case 203: + case 200: case 199: case 197: - case 187: - case 200: - case 212: - case 211: - case 218: - case 217: - case 208: - case 204: - case 205: - case 207: + case 198: + case 196: + case 195: + case 202: + case 191: case 206: + case 204: + case 194: + case 207: + case 219: + case 218: + case 225: + case 224: + case 215: + case 211: + case 212: + case 214: + case 213: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 229; + return node.kind === 244; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 141: - case 135: - case 142: - case 133: - case 140: + case 145: + case 139: + case 146: + case 137: + case 144: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 201) { + if (node.kind !== 208) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 131) { + if (node.kind !== 135) { return false; } var parameter = node; @@ -6219,17 +6443,19 @@ var ts; case 10: return ts.Diagnostics.Array_element_destructuring_pattern_expected; case 11: return ts.Diagnostics.Argument_expression_expected; case 12: return ts.Diagnostics.Property_assignment_expected; - case 13: return ts.Diagnostics.Expression_or_comma_expected; - case 14: return ts.Diagnostics.Parameter_declaration_expected; - case 15: return ts.Diagnostics.Type_parameter_declaration_expected; - case 16: return ts.Diagnostics.Type_argument_expected; - case 17: return ts.Diagnostics.Type_expected; - case 18: return ts.Diagnostics.Unexpected_token_expected; - case 19: return ts.Diagnostics.Identifier_expected; - case 20: return ts.Diagnostics.Parameter_declaration_expected; - case 21: return ts.Diagnostics.Type_argument_expected; - case 23: return ts.Diagnostics.Type_expected; - case 22: return ts.Diagnostics.Property_assignment_expected; + case 15: return ts.Diagnostics.Expression_or_comma_expected; + case 16: return ts.Diagnostics.Parameter_declaration_expected; + case 17: return ts.Diagnostics.Type_parameter_declaration_expected; + case 18: return ts.Diagnostics.Type_argument_expected; + case 19: return ts.Diagnostics.Type_expected; + case 20: return ts.Diagnostics.Unexpected_token_expected; + case 21: return ts.Diagnostics.Identifier_expected; + case 13: return ts.Diagnostics.Identifier_expected; + case 14: return ts.Diagnostics.Identifier_expected; + case 22: return ts.Diagnostics.Parameter_declaration_expected; + case 23: return ts.Diagnostics.Type_argument_expected; + case 25: return ts.Diagnostics.Type_expected; + case 24: return ts.Diagnostics.Property_assignment_expected; } } ; @@ -6288,7 +6514,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(20)) { - var node = createNode(128, entity.pos); + var node = createNode(132, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -6299,13 +6525,13 @@ var ts; if (scanner.hasPrecedingLineBreak() && isIdentifierOrKeyword()) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { - return createMissingNode(65, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(66, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(174); + var template = createNode(180); template.head = parseLiteralNode(); ts.Debug.assert(template.head.kind === 11, "Template head has wrong token kind"); var templateSpans = []; @@ -6318,7 +6544,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(180); + var span = createNode(187); span.expression = allowInAnd(parseExpression); var literal; if (token === 15) { @@ -6347,36 +6573,36 @@ var ts; if (node.kind === 7 && sourceText.charCodeAt(tokenPos) === 48 && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { - node.flags |= 16384; + node.flags |= 65536; } return node; } function parseTypeReferenceOrTypePredicate() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - if (typeName.kind === 65 && token === 117 && !scanner.hasPrecedingLineBreak()) { + if (typeName.kind === 66 && token === 121 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var node_1 = createNode(143, typeName.pos); + var node_1 = createNode(147, typeName.pos); node_1.parameterName = typeName; node_1.type = parseType(); return finishNode(node_1); } - var node = createNode(144, typeName.pos); + var node = createNode(148, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token === 24) { - node.typeArguments = parseBracketedList(16, parseType, 24, 25); + node.typeArguments = parseBracketedList(18, parseType, 24, 26); } return finishNode(node); } function parseTypeQuery() { - var node = createNode(147); - parseExpected(97); + var node = createNode(151); + parseExpected(98); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(130); + var node = createNode(134); node.name = parseIdentifier(); - if (parseOptional(79)) { + if (parseOptional(80)) { if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } @@ -6388,11 +6614,11 @@ var ts; } function parseTypeParameters() { if (token === 24) { - return parseBracketedList(15, parseTypeParameter, 24, 25); + return parseBracketedList(17, parseTypeParameter, 24, 26); } } function parseParameterType() { - if (parseOptional(51)) { + if (parseOptional(52)) { return token === 8 ? parseLiteralNode(true) : parseType(); @@ -6400,7 +6626,7 @@ var ts; return undefined; } function isStartOfParameter() { - return token === 21 || isIdentifierOrPattern() || ts.isModifier(token) || token === 52; + return token === 21 || isIdentifierOrPattern() || ts.isModifier(token) || token === 53; } function setModifiers(node, modifiers) { if (modifiers) { @@ -6409,26 +6635,29 @@ var ts; } } function parseParameter() { - var node = createNode(131); + var node = createNode(135); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(21); - node.name = inGeneratorParameterContext() ? doInYieldContext(parseIdentifierOrPattern) : parseIdentifierOrPattern(); + node.name = parseIdentifierOrPattern(); if (ts.getFullWidth(node.name) === 0 && node.flags === 0 && ts.isModifier(token)) { nextToken(); } - node.questionToken = parseOptionalToken(50); + node.questionToken = parseOptionalToken(51); node.type = parseParameterType(); - node.initializer = inGeneratorParameterContext() ? doOutsideOfYieldContext(parseParameterInitializer) : parseParameterInitializer(); + node.initializer = parseBindingElementInitializer(true); return finishNode(node); } + function parseBindingElementInitializer(inParameter) { + return inParameter ? parseParameterInitializer() : parseNonParameterInitializer(); + } function parseParameterInitializer() { return parseInitializer(true); } - function fillSignature(returnToken, yieldAndGeneratorParameterContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 32; + function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { + var returnTokenRequired = returnToken === 33; signature.typeParameters = parseTypeParameters(); - signature.parameters = parseParameterList(yieldAndGeneratorParameterContext, requireCompleteParameterList); + signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { parseExpected(returnToken); signature.type = parseType(); @@ -6437,15 +6666,15 @@ var ts; signature.type = parseType(); } } - function parseParameterList(yieldAndGeneratorParameterContext, requireCompleteParameterList) { + function parseParameterList(yieldContext, awaitContext, requireCompleteParameterList) { if (parseExpected(16)) { var savedYieldContext = inYieldContext(); - var savedGeneratorParameterContext = inGeneratorParameterContext(); - setYieldContext(yieldAndGeneratorParameterContext); - setGeneratorParameterContext(yieldAndGeneratorParameterContext); - var result = parseDelimitedList(14, parseParameter); + var savedAwaitContext = inAwaitContext(); + setYieldContext(yieldContext); + setAwaitContext(awaitContext); + var result = parseDelimitedList(16, parseParameter); setYieldContext(savedYieldContext); - setGeneratorParameterContext(savedGeneratorParameterContext); + setAwaitContext(savedAwaitContext); if (!parseExpected(17) && requireCompleteParameterList) { return undefined; } @@ -6461,10 +6690,10 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 141) { - parseExpected(88); + if (kind === 145) { + parseExpected(89); } - fillSignature(51, false, false, node); + fillSignature(52, false, false, false, node); parseTypeMemberSemicolon(); return finishNode(node); } @@ -6491,20 +6720,20 @@ var ts; else { nextToken(); } - if (token === 51 || token === 23) { + if (token === 52 || token === 23) { return true; } - if (token !== 50) { + if (token !== 51) { return false; } nextToken(); - return token === 51 || token === 23 || token === 19; + return token === 52 || token === 23 || token === 19; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(142, fullStart); + var node = createNode(146, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.parameters = parseBracketedList(14, parseParameter, 18, 19); + node.parameters = parseBracketedList(16, parseParameter, 18, 19); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); @@ -6512,17 +6741,17 @@ var ts; function parsePropertyOrMethodSignature() { var fullStart = scanner.getStartPos(); var name = parsePropertyName(); - var questionToken = parseOptionalToken(50); + var questionToken = parseOptionalToken(51); if (token === 16 || token === 24) { - var method = createNode(135, fullStart); + var method = createNode(139, fullStart); method.name = name; method.questionToken = questionToken; - fillSignature(51, false, false, method); + fillSignature(52, false, false, false, method); parseTypeMemberSemicolon(); return finishNode(method); } else { - var property = createNode(133, fullStart); + var property = createNode(137, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -6556,22 +6785,22 @@ var ts; nextToken(); return token === 16 || token === 24 || - token === 50 || token === 51 || + token === 52 || canParseSemicolon(); } function parseTypeMember() { switch (token) { case 16: case 24: - return parseSignatureMember(140); + return parseSignatureMember(144); case 18: return isIndexSignature() ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) : parsePropertyOrMethodSignature(); - case 88: + case 89: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(141); + return parseSignatureMember(145); } case 8: case 7: @@ -6601,7 +6830,7 @@ var ts; return token === 16 || token === 24; } function parseTypeLiteral() { - var node = createNode(148); + var node = createNode(152); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -6617,12 +6846,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(150); - node.elementTypes = parseBracketedList(17, parseType, 18, 19); + var node = createNode(154); + node.elementTypes = parseBracketedList(19, parseType, 18, 19); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(152); + var node = createNode(157); parseExpected(16); node.type = parseType(); parseExpected(17); @@ -6630,10 +6859,10 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 146) { - parseExpected(88); + if (kind === 150) { + parseExpected(89); } - fillSignature(32, false, false, node); + fillSignature(33, false, false, false, node); return finishNode(node); } function parseKeywordAndNoDot() { @@ -6642,16 +6871,16 @@ var ts; } function parseNonArrayType() { switch (token) { - case 112: - case 123: - case 121: - case 113: - case 124: + case 114: + case 127: + case 125: + case 117: + case 128: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReferenceOrTypePredicate(); - case 99: + case 100: return parseTokenNode(); - case 97: + case 98: return parseTypeQuery(); case 14: return parseTypeLiteral(); @@ -6665,17 +6894,17 @@ var ts; } function isStartOfType() { switch (token) { - case 112: - case 123: - case 121: - case 113: - case 124: - case 99: - case 97: + case 114: + case 127: + case 125: + case 117: + case 128: + case 100: + case 98: case 14: case 18: case 24: - case 88: + case 89: return true; case 16: return lookAhead(isStartOfParenthesizedOrFunctionType); @@ -6691,27 +6920,33 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(18)) { parseExpected(19); - var node = createNode(149, type.pos); + var node = createNode(153, type.pos); node.elementType = type; type = finishNode(node); } return type; } - function parseUnionTypeOrHigher() { - var type = parseArrayTypeOrHigher(); - if (token === 44) { + function parseUnionOrIntersectionType(kind, parseConstituentType, operator) { + var type = parseConstituentType(); + if (token === operator) { var types = [type]; types.pos = type.pos; - while (parseOptional(44)) { - types.push(parseArrayTypeOrHigher()); + while (parseOptional(operator)) { + types.push(parseConstituentType()); } types.end = getNodeEnd(); - var node = createNode(151, type.pos); + var node = createNode(kind, type.pos); node.types = types; type = finishNode(node); } return type; } + function parseIntersectionTypeOrHigher() { + return parseUnionOrIntersectionType(156, parseArrayTypeOrHigher, 44); + } + function parseUnionTypeOrHigher() { + return parseUnionOrIntersectionType(155, parseIntersectionTypeOrHigher, 45); + } function isStartOfFunctionType() { if (token === 24) { return true; @@ -6725,14 +6960,14 @@ var ts; } if (isIdentifier() || ts.isModifier(token)) { nextToken(); - if (token === 51 || token === 23 || - token === 50 || token === 53 || + if (token === 52 || token === 23 || + token === 51 || token === 54 || isIdentifier() || ts.isModifier(token)) { return true; } if (token === 17) { nextToken(); - if (token === 32) { + if (token === 33) { return true; } } @@ -6740,34 +6975,27 @@ var ts; return false; } function parseType() { - var savedYieldContext = inYieldContext(); - var savedGeneratorParameterContext = inGeneratorParameterContext(); - setYieldContext(false); - setGeneratorParameterContext(false); - var result = parseTypeWorker(); - setYieldContext(savedYieldContext); - setGeneratorParameterContext(savedGeneratorParameterContext); - return result; + return doOutsideOfContext(10, parseTypeWorker); } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(145); + return parseFunctionOrConstructorType(149); } - if (token === 88) { - return parseFunctionOrConstructorType(146); + if (token === 89) { + return parseFunctionOrConstructorType(150); } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(51) ? parseType() : undefined; + return parseOptional(52) ? parseType() : undefined; } function isStartOfLeftHandSideExpression() { switch (token) { - case 93: - case 91: - case 89: - case 95: - case 80: + case 94: + case 92: + case 90: + case 96: + case 81: case 7: case 8: case 10: @@ -6775,12 +7003,12 @@ var ts; case 16: case 18: case 14: - case 83: - case 69: - case 88: - case 36: - case 57: - case 65: + case 84: + case 70: + case 89: + case 37: + case 58: + case 66: return true; default: return isIdentifier(); @@ -6791,17 +7019,18 @@ var ts; return true; } switch (token) { - case 33: case 34: + case 35: + case 48: case 47: - case 46: - case 74: - case 97: - case 99: - case 38: + case 75: + case 98: + case 100: case 39: + case 40: case 24: - case 110: + case 116: + case 111: return true; default: if (isBinaryOperator()) { @@ -6812,11 +7041,14 @@ var ts; } function isStartOfExpressionStatement() { return token !== 14 && - token !== 83 && - token !== 69 && - token !== 52 && + token !== 84 && + token !== 70 && + token !== 53 && isStartOfExpression(); } + function allowInAndParseExpression() { + return allowInAnd(parseExpression); + } function parseExpression() { // Expression[in]: // AssignmentExpression[in] @@ -6836,12 +7068,12 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token !== 53) { + if (token !== 54) { if (scanner.hasPrecedingLineBreak() || (inParameter && token === 14) || !isStartOfExpression()) { return undefined; } } - parseExpected(53); + parseExpected(54); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -6862,7 +7094,7 @@ var ts; return arrowExpression; } var expr = parseBinaryExpressionOrHigher(0); - if (expr.kind === 65 && token === 32) { + if (expr.kind === 66 && token === 33) { return parseSimpleArrowFunctionExpression(expr); } if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { @@ -6871,7 +7103,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token === 110) { + if (token === 111) { if (inYieldContext()) { return true; } @@ -6884,11 +7116,11 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(175); + var node = createNode(181); nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token === 35 || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(35); + (token === 36 || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(36); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -6897,16 +7129,16 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier) { - ts.Debug.assert(token === 32, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(166, identifier.pos); - var parameter = createNode(131, identifier.pos); + ts.Debug.assert(token === 33, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + var node = createNode(171, identifier.pos); + var parameter = createNode(135, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; node.parameters.pos = parameter.pos; node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(32, false, ts.Diagnostics._0_expected, "=>"); - node.body = parseArrowFunctionExpressionBody(); + node.equalsGreaterThanToken = parseExpectedToken(33, false, ts.Diagnostics._0_expected, "=>"); + node.body = parseArrowFunctionExpressionBody(false); return finishNode(node); } function tryParseParenthesizedArrowFunctionExpression() { @@ -6920,31 +7152,41 @@ var ts; if (!arrowFunction) { return undefined; } + var isAsync = !!(arrowFunction.flags & 512); var lastToken = token; - arrowFunction.equalsGreaterThanToken = parseExpectedToken(32, false, ts.Diagnostics._0_expected, "=>"); - arrowFunction.body = (lastToken === 32 || lastToken === 14) - ? parseArrowFunctionExpressionBody() + arrowFunction.equalsGreaterThanToken = parseExpectedToken(33, false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 33 || lastToken === 14) + ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); } function isParenthesizedArrowFunctionExpression() { - if (token === 16 || token === 24) { + if (token === 16 || token === 24 || token === 115) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token === 32) { + if (token === 33) { return 1; } return 0; } function isParenthesizedArrowFunctionExpressionWorker() { + if (token === 115) { + nextToken(); + if (scanner.hasPrecedingLineBreak()) { + return 0; + } + if (token !== 16 && token !== 24) { + return 0; + } + } var first = token; var second = nextToken(); if (first === 16) { if (second === 17) { var third = nextToken(); switch (third) { - case 32: - case 51: + case 33: + case 52: case 14: return 1; default: @@ -6960,7 +7202,7 @@ var ts; if (!isIdentifier()) { return 0; } - if (nextToken() === 51) { + if (nextToken() === 52) { return 1; } return 2; @@ -6970,6 +7212,29 @@ var ts; if (!isIdentifier()) { return 0; } + if (sourceFile.languageVariant === 1) { + var isArrowFunctionInJsx = lookAhead(function () { + var third = nextToken(); + if (third === 80) { + var fourth = nextToken(); + switch (fourth) { + case 54: + case 26: + return false; + default: + return true; + } + } + else if (third === 23) { + return true; + } + return false; + }); + if (isArrowFunctionInJsx) { + return 1; + } + return 0; + } return 2; } } @@ -6977,39 +7242,43 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(166); - fillSignature(51, false, !allowAmbiguity, node); + var node = createNode(171); + setModifiers(node, parseModifiersForArrowFunction()); + var isAsync = !!(node.flags & 512); + fillSignature(52, false, isAsync, !allowAmbiguity, node); if (!node.parameters) { return undefined; } - if (!allowAmbiguity && token !== 32 && token !== 14) { + if (!allowAmbiguity && token !== 33 && token !== 14) { return undefined; } return node; } - function parseArrowFunctionExpressionBody() { + function parseArrowFunctionExpressionBody(isAsync) { if (token === 14) { - return parseFunctionBlock(false, false); + return parseFunctionBlock(false, isAsync, false); } if (token !== 22 && - token !== 83 && - token !== 69 && + token !== 84 && + token !== 70 && isStartOfStatement() && !isStartOfExpressionStatement()) { - return parseFunctionBlock(false, true); + return parseFunctionBlock(false, isAsync, true); } - return parseAssignmentExpressionOrHigher(); + return isAsync + ? doInAwaitContext(parseAssignmentExpressionOrHigher) + : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); } function parseConditionalExpressionRest(leftOperand) { - var questionToken = parseOptionalToken(50); + var questionToken = parseOptionalToken(51); if (!questionToken) { return leftOperand; } - var node = createNode(173, leftOperand.pos); + var node = createNode(179, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(51, false, ts.Diagnostics._0_expected, ts.tokenToString(51)); + node.colonToken = parseExpectedToken(52, false, ts.Diagnostics._0_expected, ts.tokenToString(52)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -7018,7 +7287,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 86 || t === 127; + return t === 87 || t === 131; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -7027,106 +7296,147 @@ var ts; if (newPrecedence <= precedence) { break; } - if (token === 86 && inDisallowInContext()) { + if (token === 87 && inDisallowInContext()) { break; } - leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence)); + if (token === 113) { + if (scanner.hasPrecedingLineBreak()) { + break; + } + else { + nextToken(); + leftOperand = makeAsExpression(leftOperand, parseType()); + } + } + else { + leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence)); + } } return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token === 86) { + if (inDisallowInContext() && token === 87) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token) { - case 49: + case 50: return 1; - case 48: + case 49: return 2; - case 44: - return 3; case 45: + return 3; + case 46: return 4; - case 43: + case 44: return 5; - case 28: case 29: case 30: case 31: + case 32: return 6; case 24: - case 25: case 26: case 27: + case 28: + case 88: case 87: - case 86: + case 113: return 7; - case 40: case 41: case 42: + case 43: return 8; - case 33: case 34: - return 9; case 35: + return 9; case 36: case 37: + case 38: return 10; } return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(172, left.pos); + var node = createNode(178, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } + function makeAsExpression(left, right) { + var node = createNode(186, left.pos); + node.expression = left; + node.type = right; + return finishNode(node); + } function parsePrefixUnaryExpression() { - var node = createNode(170); + var node = createNode(176); node.operator = token; nextToken(); node.operand = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(167); + var node = createNode(172); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(168); + var node = createNode(173); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(169); + var node = createNode(174); + nextToken(); + node.expression = parseUnaryExpressionOrHigher(); + return finishNode(node); + } + function isAwaitExpression() { + if (token === 116) { + if (inAwaitContext()) { + return true; + } + return lookAhead(nextTokenIsIdentifierOnSameLine); + } + return false; + } + function parseAwaitExpression() { + var node = createNode(175); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseUnaryExpressionOrHigher() { + if (isAwaitExpression()) { + return parseAwaitExpression(); + } switch (token) { - case 33: case 34: + case 35: + case 48: case 47: - case 46: - case 38: case 39: + case 40: return parsePrefixUnaryExpression(); - case 74: + case 75: return parseDeleteExpression(); - case 97: + case 98: return parseTypeOfExpression(); - case 99: + case 100: return parseVoidExpression(); case 24: - return parseTypeAssertion(); + if (sourceFile.languageVariant !== 1) { + return parseTypeAssertion(); + } + if (lookAhead(nextTokenIsIdentifierOrKeyword)) { + return parseJsxElementOrSelfClosingElement(); + } default: return parsePostfixExpressionOrHigher(); } @@ -7134,8 +7444,8 @@ var ts; function parsePostfixExpressionOrHigher() { var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token === 38 || token === 39) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(171, expression.pos); + if ((token === 39 || token === 40) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(177, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -7144,7 +7454,7 @@ var ts; return expression; } function parseLeftHandSideExpressionOrHigher() { - var expression = token === 91 + var expression = token === 92 ? parseSuperExpression() : parseMemberExpressionOrHigher(); return parseCallExpressionRest(expression); @@ -7158,17 +7468,140 @@ var ts; if (token === 16 || token === 20) { return expression; } - var node = createNode(158, expression.pos); + var node = createNode(163, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(20, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } + function parseJsxElementOrSelfClosingElement() { + var opening = parseJsxOpeningOrSelfClosingElement(); + if (opening.kind === 232) { + var node = createNode(230, opening.pos); + node.openingElement = opening; + node.children = parseJsxChildren(node.openingElement.tagName); + node.closingElement = parseJsxClosingElement(); + return finishNode(node); + } + else { + ts.Debug.assert(opening.kind === 231); + return opening; + } + } + function parseJsxText() { + var node = createNode(233, scanner.getStartPos()); + token = scanner.scanJsxToken(); + return finishNode(node); + } + function parseJsxChild() { + switch (token) { + case 233: + return parseJsxText(); + case 14: + return parseJsxExpression(); + case 24: + return parseJsxElementOrSelfClosingElement(); + } + ts.Debug.fail('Unknown JSX child kind ' + token); + } + function parseJsxChildren(openingTagName) { + var result = []; + result.pos = scanner.getStartPos(); + var saveParsingContext = parsingContext; + parsingContext |= 1 << 14; + while (true) { + token = scanner.reScanJsxToken(); + if (token === 25) { + break; + } + else if (token === 1) { + parseErrorAtCurrentToken(ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNodeFromSourceText(sourceText, openingTagName)); + break; + } + result.push(parseJsxChild()); + } + result.end = scanner.getTokenPos(); + parsingContext = saveParsingContext; + return result; + } + function parseJsxOpeningOrSelfClosingElement() { + var fullStart = scanner.getStartPos(); + parseExpected(24); + var tagName = parseJsxElementName(); + var attributes = parseList(13, parseJsxAttribute); + var node; + if (parseOptional(26)) { + node = createNode(232, fullStart); + } + else { + parseExpected(37); + parseExpected(26); + node = createNode(231, fullStart); + } + node.tagName = tagName; + node.attributes = attributes; + return finishNode(node); + } + function parseJsxElementName() { + scanJsxIdentifier(); + var elementName = parseIdentifierName(); + while (parseOptional(20)) { + scanJsxIdentifier(); + var node = createNode(132, elementName.pos); + node.left = elementName; + node.right = parseIdentifierName(); + elementName = finishNode(node); + } + return elementName; + } + function parseJsxExpression() { + var node = createNode(237); + parseExpected(14); + if (token !== 15) { + node.expression = parseExpression(); + } + parseExpected(15); + return finishNode(node); + } + function parseJsxAttribute() { + if (token === 14) { + return parseJsxSpreadAttribute(); + } + scanJsxIdentifier(); + var node = createNode(235); + node.name = parseIdentifierName(); + if (parseOptional(54)) { + switch (token) { + case 8: + node.initializer = parseLiteralNode(); + break; + default: + node.initializer = parseJsxExpression(); + break; + } + } + return finishNode(node); + } + function parseJsxSpreadAttribute() { + var node = createNode(236); + parseExpected(14); + parseExpected(21); + node.expression = parseExpression(); + parseExpected(15); + return finishNode(node); + } + function parseJsxClosingElement() { + var node = createNode(234); + parseExpected(25); + node.tagName = parseJsxElementName(); + parseExpected(26); + return finishNode(node); + } function parseTypeAssertion() { - var node = createNode(163); + var node = createNode(168); parseExpected(24); node.type = parseType(); - parseExpected(25); + parseExpected(26); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } @@ -7176,7 +7609,7 @@ var ts; while (true) { var dotToken = parseOptionalToken(20); if (dotToken) { - var propertyAccess = createNode(158, expression.pos); + var propertyAccess = createNode(163, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); @@ -7184,7 +7617,7 @@ var ts; continue; } if (!inDecoratorContext() && parseOptional(18)) { - var indexedAccess = createNode(159, expression.pos); + var indexedAccess = createNode(164, expression.pos); indexedAccess.expression = expression; if (token !== 19) { indexedAccess.argumentExpression = allowInAnd(parseExpression); @@ -7198,7 +7631,7 @@ var ts; continue; } if (token === 10 || token === 11) { - var tagExpression = createNode(162, expression.pos); + var tagExpression = createNode(167, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 10 ? parseLiteralNode() @@ -7217,7 +7650,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(160, expression.pos); + var callExpr = createNode(165, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -7225,7 +7658,7 @@ var ts; continue; } else if (token === 16) { - var callExpr = createNode(160, expression.pos); + var callExpr = createNode(165, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -7244,8 +7677,8 @@ var ts; if (!parseOptional(24)) { return undefined; } - var typeArguments = parseDelimitedList(16, parseType); - if (!parseExpected(25)) { + var typeArguments = parseDelimitedList(18, parseType); + if (!parseExpected(26)) { return undefined; } return typeArguments && canFollowTypeArgumentsInExpression() @@ -7258,18 +7691,18 @@ var ts; case 20: case 17: case 19: - case 51: + case 52: case 22: - case 50: - case 28: - case 30: + case 51: case 29: case 31: - case 48: + case 30: + case 32: case 49: - case 45: - case 43: + case 50: + case 46: case 44: + case 45: case 15: case 1: return true; @@ -7285,11 +7718,11 @@ var ts; case 8: case 10: return parseLiteralNode(); - case 93: - case 91: - case 89: - case 95: - case 80: + case 94: + case 92: + case 90: + case 96: + case 81: return parseTokenNode(); case 16: return parseParenthesizedExpression(); @@ -7297,14 +7730,19 @@ var ts; return parseArrayLiteralExpression(); case 14: return parseObjectLiteralExpression(); - case 69: - return parseClassExpression(); - case 83: + case 115: + if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { + break; + } return parseFunctionExpression(); - case 88: + case 70: + return parseClassExpression(); + case 84: + return parseFunctionExpression(); + case 89: return parseNewExpression(); - case 36: - case 57: + case 37: + case 58: if (reScanSlashToken() === 9) { return parseLiteralNode(); } @@ -7315,41 +7753,41 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(164); + var node = createNode(169); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); return finishNode(node); } function parseSpreadElement() { - var node = createNode(176); + var node = createNode(182); parseExpected(21); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 21 ? parseSpreadElement() : - token === 23 ? createNode(178) : + token === 23 ? createNode(184) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(156); + var node = createNode(161); parseExpected(18); if (scanner.hasPrecedingLineBreak()) - node.flags |= 512; - node.elements = parseDelimitedList(13, parseArgumentOrArrayLiteralElement); + node.flags |= 2048; + node.elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement); parseExpected(19); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(116)) { - return parseAccessorDeclaration(138, fullStart, decorators, modifiers); + if (parseContextualModifier(120)) { + return parseAccessorDeclaration(142, fullStart, decorators, modifiers); } - else if (parseContextualModifier(122)) { - return parseAccessorDeclaration(139, fullStart, decorators, modifiers); + else if (parseContextualModifier(126)) { + return parseAccessorDeclaration(143, fullStart, decorators, modifiers); } return undefined; } @@ -7361,34 +7799,34 @@ var ts; if (accessor) { return accessor; } - var asteriskToken = parseOptionalToken(35); + var asteriskToken = parseOptionalToken(36); var tokenIsIdentifier = isIdentifier(); var nameToken = token; var propertyName = parsePropertyName(); - var questionToken = parseOptionalToken(50); + var questionToken = parseOptionalToken(51); if (asteriskToken || token === 16 || token === 24) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } if ((token === 23 || token === 15) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(228, fullStart); + var shorthandDeclaration = createNode(243, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(227, fullStart); + var propertyAssignment = createNode(242, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(51); + parseExpected(52); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return finishNode(propertyAssignment); } } function parseObjectLiteralExpression() { - var node = createNode(157); + var node = createNode(162); parseExpected(14); if (scanner.hasPrecedingLineBreak()) { - node.flags |= 512; + node.flags |= 2048; } node.properties = parseDelimitedList(12, parseObjectLiteralElement, true); parseExpected(15); @@ -7399,12 +7837,19 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(165); - parseExpected(83); - node.asteriskToken = parseOptionalToken(35); - node.name = node.asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(51, !!node.asteriskToken, false, node); - node.body = parseFunctionBlock(!!node.asteriskToken, false); + var node = createNode(170); + setModifiers(node, parseModifiers()); + parseExpected(84); + node.asteriskToken = parseOptionalToken(36); + var isGenerator = !!node.asteriskToken; + var isAsync = !!(node.flags & 512); + node.name = + isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : + isGenerator ? doInYieldContext(parseOptionalIdentifier) : + isAsync ? doInAwaitContext(parseOptionalIdentifier) : + parseOptionalIdentifier(); + fillSignature(52, isGenerator, isAsync, false, node); + node.body = parseFunctionBlock(isGenerator, isAsync, false); if (saveDecoratorContext) { setDecoratorContext(true); } @@ -7414,8 +7859,8 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(161); - parseExpected(88); + var node = createNode(166); + parseExpected(89); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token === 16) { @@ -7424,7 +7869,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(182); + var node = createNode(189); if (parseExpected(14, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(1, parseStatement); parseExpected(15); @@ -7434,9 +7879,11 @@ var ts; } return finishNode(node); } - function parseFunctionBlock(allowYield, ignoreMissingOpenBrace, diagnosticMessage) { + function parseFunctionBlock(allowYield, allowAwait, ignoreMissingOpenBrace, diagnosticMessage) { var savedYieldContext = inYieldContext(); setYieldContext(allowYield); + var savedAwaitContext = inAwaitContext(); + setAwaitContext(allowAwait); var saveDecoratorContext = inDecoratorContext(); if (saveDecoratorContext) { setDecoratorContext(false); @@ -7446,28 +7893,29 @@ var ts; setDecoratorContext(true); } setYieldContext(savedYieldContext); + setAwaitContext(savedAwaitContext); return block; } function parseEmptyStatement() { - var node = createNode(184); + var node = createNode(191); parseExpected(22); return finishNode(node); } function parseIfStatement() { - var node = createNode(186); - parseExpected(84); + var node = createNode(193); + parseExpected(85); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(76) ? parseStatement() : undefined; + node.elseStatement = parseOptional(77) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(187); - parseExpected(75); + var node = createNode(194); + parseExpected(76); node.statement = parseStatement(); - parseExpected(100); + parseExpected(101); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); @@ -7475,8 +7923,8 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(188); - parseExpected(100); + var node = createNode(195); + parseExpected(101); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); @@ -7485,11 +7933,11 @@ var ts; } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(82); + parseExpected(83); parseExpected(16); var initializer = undefined; if (token !== 22) { - if (token === 98 || token === 104 || token === 70) { + if (token === 99 || token === 105 || token === 71) { initializer = parseVariableDeclarationList(true); } else { @@ -7497,22 +7945,22 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(86)) { - var forInStatement = createNode(190, pos); + if (parseOptional(87)) { + var forInStatement = createNode(197, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(17); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(127)) { - var forOfStatement = createNode(191, pos); + else if (parseOptional(131)) { + var forOfStatement = createNode(198, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(17); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(189, pos); + var forStatement = createNode(196, pos); forStatement.initializer = initializer; parseExpected(22); if (token !== 22 && token !== 17) { @@ -7530,7 +7978,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 193 ? 66 : 71); + parseExpected(kind === 200 ? 67 : 72); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -7538,8 +7986,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(194); - parseExpected(90); + var node = createNode(201); + parseExpected(91); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -7547,8 +7995,8 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(195); - parseExpected(101); + var node = createNode(202); + parseExpected(102); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); @@ -7556,30 +8004,30 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(223); - parseExpected(67); + var node = createNode(238); + parseExpected(68); node.expression = allowInAnd(parseExpression); - parseExpected(51); + parseExpected(52); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(224); - parseExpected(73); - parseExpected(51); + var node = createNode(239); + parseExpected(74); + parseExpected(52); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token === 67 ? parseCaseClause() : parseDefaultClause(); + return token === 68 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(196); - parseExpected(92); + var node = createNode(203); + parseExpected(93); parseExpected(16); node.expression = allowInAnd(parseExpression); parseExpected(17); - var caseBlock = createNode(210, scanner.getStartPos()); + var caseBlock = createNode(217, scanner.getStartPos()); parseExpected(14); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(15); @@ -7589,26 +8037,26 @@ var ts; function parseThrowStatement() { // ThrowStatement[Yield] : // throw [no LineTerminator here]Expression[In, ?Yield]; - var node = createNode(198); - parseExpected(94); + var node = createNode(205); + parseExpected(95); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(199); - parseExpected(96); + var node = createNode(206); + parseExpected(97); node.tryBlock = parseBlock(false); - node.catchClause = token === 68 ? parseCatchClause() : undefined; - if (!node.catchClause || token === 81) { - parseExpected(81); + node.catchClause = token === 69 ? parseCatchClause() : undefined; + if (!node.catchClause || token === 82) { + parseExpected(82); node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(226); - parseExpected(68); + var result = createNode(241); + parseExpected(69); if (parseExpected(16)) { result.variableDeclaration = parseVariableDeclaration(); } @@ -7617,34 +8065,38 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(200); - parseExpected(72); + var node = createNode(207); + parseExpected(73); parseSemicolon(); return finishNode(node); } function parseExpressionOrLabeledStatement() { var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 65 && parseOptional(51)) { - var labeledStatement = createNode(197, fullStart); + if (expression.kind === 66 && parseOptional(52)) { + var labeledStatement = createNode(204, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(185, fullStart); + var expressionStatement = createNode(192, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); } } function isIdentifierOrKeyword() { - return token >= 65; + return token >= 66; } function nextTokenIsIdentifierOrKeywordOnSameLine() { nextToken(); return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak(); } + function nextTokenIsFunctionKeywordOnSameLine() { + nextToken(); + return token === 84 && !scanner.hasPrecedingLineBreak(); + } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); return (isIdentifierOrKeyword() || token === 7) && !scanner.hasPrecedingLineBreak(); @@ -7652,40 +8104,42 @@ var ts; function isDeclaration() { while (true) { switch (token) { - case 98: - case 104: + case 99: + case 105: + case 71: + case 84: case 70: - case 83: - case 69: - case 77: + case 78: return true; - case 103: - case 125: + case 104: + case 129: return nextTokenIsIdentifierOnSameLine(); - case 118: - case 119: + case 122: + case 123: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); case 115: + case 119: nextToken(); if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 85: + case 86: nextToken(); - return token === 8 || token === 35 || + return token === 8 || token === 36 || token === 14 || isIdentifierOrKeyword(); - case 78: + case 79: nextToken(); - if (token === 53 || token === 35 || - token === 14 || token === 73) { + if (token === 54 || token === 36 || + token === 14 || token === 74) { return true; } continue; - case 108: - case 106: - case 107: case 109: + case 107: + case 108: + case 110: + case 112: nextToken(); continue; default: @@ -7698,43 +8152,44 @@ var ts; } function isStartOfStatement() { switch (token) { - case 52: + case 53: case 22: case 14: - case 98: - case 104: - case 83: - case 69: - case 77: + case 99: + case 105: case 84: - case 75: - case 100: - case 82: - case 71: - case 66: - case 90: - case 101: - case 92: - case 94: - case 96: - case 72: - case 68: - case 81: - return true; case 70: case 78: case 85: + case 76: + case 101: + case 83: + case 72: + case 67: + case 91: + case 102: + case 93: + case 95: + case 97: + case 73: + case 69: + case 82: + return true; + case 71: + case 79: + case 86: return isStartOfDeclaration(); case 115: - case 103: - case 118: case 119: - case 125: + case 104: + case 122: + case 123: + case 129: return true; - case 108: - case 106: - case 107: case 109: + case 107: + case 108: + case 110: return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: return isStartOfExpression(); @@ -7753,58 +8208,60 @@ var ts; return parseEmptyStatement(); case 14: return parseBlock(false); - case 98: + case 99: return parseVariableStatement(scanner.getStartPos(), undefined, undefined); - case 104: + case 105: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), undefined, undefined); } break; - case 83: - return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); - case 69: - return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); case 84: - return parseIfStatement(); - case 75: - return parseDoStatement(); - case 100: - return parseWhileStatement(); - case 82: - return parseForOrForInOrForOfStatement(); - case 71: - return parseBreakOrContinueStatement(192); - case 66: - return parseBreakOrContinueStatement(193); - case 90: - return parseReturnStatement(); - case 101: - return parseWithStatement(); - case 92: - return parseSwitchStatement(); - case 94: - return parseThrowStatement(); - case 96: - case 68: - case 81: - return parseTryStatement(); - case 72: - return parseDebuggerStatement(); - case 52: - return parseDeclaration(); - case 103: - case 125: - case 118: - case 119: - case 115: + return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); case 70: - case 77: - case 78: + return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); case 85: - case 106: + return parseIfStatement(); + case 76: + return parseDoStatement(); + case 101: + return parseWhileStatement(); + case 83: + return parseForOrForInOrForOfStatement(); + case 72: + return parseBreakOrContinueStatement(199); + case 67: + return parseBreakOrContinueStatement(200); + case 91: + return parseReturnStatement(); + case 102: + return parseWithStatement(); + case 93: + return parseSwitchStatement(); + case 95: + return parseThrowStatement(); + case 97: + case 69: + case 82: + return parseTryStatement(); + case 73: + return parseDebuggerStatement(); + case 53: + return parseDeclaration(); + case 115: + case 104: + case 129: + case 122: + case 123: + case 119: + case 71: + case 78: + case 79: + case 86: case 107: case 108: case 109: + case 112: + case 110: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -7817,33 +8274,33 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token) { - case 98: - case 104: - case 70: + case 99: + case 105: + case 71: return parseVariableStatement(fullStart, decorators, modifiers); - case 83: + case 84: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 69: + case 70: return parseClassDeclaration(fullStart, decorators, modifiers); - case 103: + case 104: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 125: + case 129: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 77: - return parseEnumDeclaration(fullStart, decorators, modifiers); - case 118: - case 119: - return parseModuleDeclaration(fullStart, decorators, modifiers); - case 85: - return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); case 78: + return parseEnumDeclaration(fullStart, decorators, modifiers); + case 122: + case 123: + return parseModuleDeclaration(fullStart, decorators, modifiers); + case 86: + return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); + case 79: nextToken(); - return token === 73 || token === 53 ? + return token === 74 || token === 54 ? parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: if (decorators || modifiers) { - var node = createMissingNode(221, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(228, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -7855,47 +8312,47 @@ var ts; nextToken(); return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 8); } - function parseFunctionBlockOrSemicolon(isGenerator, diagnosticMessage) { + function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { if (token !== 14 && canParseSemicolon()) { parseSemicolon(); return; } - return parseFunctionBlock(isGenerator, false, diagnosticMessage); + return parseFunctionBlock(isGenerator, isAsync, false, diagnosticMessage); } function parseArrayBindingElement() { if (token === 23) { - return createNode(178); + return createNode(184); } - var node = createNode(155); + var node = createNode(160); node.dotDotDotToken = parseOptionalToken(21); node.name = parseIdentifierOrPattern(); - node.initializer = parseInitializer(false); + node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(155); + var node = createNode(160); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token !== 51) { + if (tokenIsIdentifier && token !== 52) { node.name = propertyName; } else { - parseExpected(51); + parseExpected(52); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } - node.initializer = parseInitializer(false); + node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(153); + var node = createNode(158); parseExpected(14); node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(15); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(154); + var node = createNode(159); parseExpected(18); node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(19); @@ -7914,7 +8371,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(201); + var node = createNode(208); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -7923,21 +8380,21 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(202); + var node = createNode(209); switch (token) { - case 98: + case 99: break; - case 104: - node.flags |= 4096; + case 105: + node.flags |= 16384; break; - case 70: - node.flags |= 8192; + case 71: + node.flags |= 32768; break; default: ts.Debug.fail(); } nextToken(); - if (token === 127 && lookAhead(canFollowContextualOfKeyword)) { + if (token === 131 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -7952,7 +8409,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 17; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(183, fullStart); + var node = createNode(190, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); @@ -7960,38 +8417,42 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(203, fullStart); + var node = createNode(210, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(83); - node.asteriskToken = parseOptionalToken(35); - node.name = node.flags & 256 ? parseOptionalIdentifier() : parseIdentifier(); - fillSignature(51, !!node.asteriskToken, false, node); - node.body = parseFunctionBlockOrSemicolon(!!node.asteriskToken, ts.Diagnostics.or_expected); + parseExpected(84); + node.asteriskToken = parseOptionalToken(36); + node.name = node.flags & 1024 ? parseOptionalIdentifier() : parseIdentifier(); + var isGenerator = !!node.asteriskToken; + var isAsync = !!(node.flags & 512); + fillSignature(52, isGenerator, isAsync, false, node); + node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(137, pos); + var node = createNode(141, pos); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(114); - fillSignature(51, false, false, node); - node.body = parseFunctionBlockOrSemicolon(false, ts.Diagnostics.or_expected); + parseExpected(118); + fillSignature(52, 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(136, fullStart); + var method = createNode(140, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; method.name = name; method.questionToken = questionToken; - fillSignature(51, !!asteriskToken, false, method); - method.body = parseFunctionBlockOrSemicolon(!!asteriskToken, diagnosticMessage); + var isGenerator = !!asteriskToken; + var isAsync = !!(method.flags & 512); + fillSignature(52, isGenerator, isAsync, false, method); + method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(134, fullStart); + var property = createNode(138, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -7999,14 +8460,14 @@ var ts; property.type = parseTypeAnnotation(); property.initializer = modifiers && modifiers.flags & 128 ? allowInAnd(parseNonParameterInitializer) - : doOutsideOfContext(4 | 2, parseNonParameterInitializer); + : doOutsideOfContext(2 | 1, parseNonParameterInitializer); parseSemicolon(); return finishNode(property); } function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(35); + var asteriskToken = parseOptionalToken(36); var name = parsePropertyName(); - var questionToken = parseOptionalToken(50); + var questionToken = parseOptionalToken(51); if (asteriskToken || token === 16 || token === 24) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } @@ -8022,16 +8483,16 @@ var ts; node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(51, false, false, node); - node.body = parseFunctionBlockOrSemicolon(false); + fillSignature(52, false, false, false, node); + node.body = parseFunctionBlockOrSemicolon(false, false); return finishNode(node); } function isClassMemberModifier(idToken) { switch (idToken) { - case 108: - case 106: - case 107: case 109: + case 107: + case 108: + case 110: return true; default: return false; @@ -8039,7 +8500,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token === 52) { + if (token === 53) { return true; } while (ts.isModifier(token)) { @@ -8049,7 +8510,7 @@ var ts; } nextToken(); } - if (token === 35) { + if (token === 36) { return true; } if (isLiteralPropertyName()) { @@ -8060,15 +8521,15 @@ var ts; return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 122 || idToken === 116) { + if (!ts.isKeyword(idToken) || idToken === 126 || idToken === 120) { return true; } switch (token) { case 16: case 24: + case 52: + case 54: case 51: - case 53: - case 50: return true; default: return canParseSemicolon(); @@ -8080,14 +8541,14 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(52)) { + if (!parseOptional(53)) { break; } if (!decorators) { decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(132, decoratorStart); + var decorator = createNode(136, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -8118,9 +8579,25 @@ var ts; } return modifiers; } + function parseModifiersForArrowFunction() { + var flags = 0; + var modifiers; + if (token === 115) { + var modifierStart = scanner.getStartPos(); + var modifierKind = token; + nextToken(); + modifiers = []; + modifiers.pos = modifierStart; + flags |= ts.modifierToFlag(modifierKind); + modifiers.push(finishNode(createNode(modifierKind, modifierStart))); + modifiers.flags = flags; + modifiers.end = scanner.getStartPos(); + } + return modifiers; + } function parseClassElement() { if (token === 22) { - var result = createNode(181); + var result = createNode(188); nextToken(); return finishNode(result); } @@ -8131,7 +8608,7 @@ var ts; if (accessor) { return accessor; } - if (token === 114) { + if (token === 118) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -8140,34 +8617,32 @@ var ts; if (isIdentifierOrKeyword() || token === 8 || token === 7 || - token === 35 || + token === 36 || token === 18) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name_6 = createMissingNode(65, true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_6, undefined); + var name_8 = createMissingNode(66, 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, 177); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 183); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 204); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 211); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(69); + parseExpected(70); node.name = parseOptionalIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(true); if (parseExpected(14)) { - node.members = inGeneratorParameterContext() - ? doOutsideOfYieldContext(parseClassMembers) - : parseClassMembers(); + node.members = parseClassMembers(); parseExpected(15); } else { @@ -8176,22 +8651,19 @@ var ts; return finishNode(node); } function parseHeritageClauses(isClassHeritageClause) { - // ClassTail[Yield,GeneratorParameter] : See 14.5 - // [~GeneratorParameter]ClassHeritage[?Yield]opt { ClassBody[?Yield]opt } - // [+GeneratorParameter] ClassHeritageopt { ClassBodyopt } + // ClassTail[Yield,Await] : (Modified) See 14.5 + // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } if (isHeritageClause()) { - return isClassHeritageClause && inGeneratorParameterContext() - ? doOutsideOfYieldContext(parseHeritageClausesWorker) - : parseHeritageClausesWorker(); + return parseList(20, parseHeritageClause); } return undefined; } function parseHeritageClausesWorker() { - return parseList(18, parseHeritageClause); + return parseList(20, parseHeritageClause); } function parseHeritageClause() { - if (token === 79 || token === 102) { - var node = createNode(225); + if (token === 80 || token === 103) { + var node = createNode(240); node.token = token; nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); @@ -8200,24 +8672,24 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(179); + var node = createNode(185); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === 24) { - node.typeArguments = parseBracketedList(16, parseType, 24, 25); + node.typeArguments = parseBracketedList(18, parseType, 24, 26); } return finishNode(node); } function isHeritageClause() { - return token === 79 || token === 102; + return token === 80 || token === 103; } function parseClassMembers() { return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(205, fullStart); + var node = createNode(212, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(103); + parseExpected(104); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(false); @@ -8225,28 +8697,28 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(206, fullStart); + var node = createNode(213, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(125); + parseExpected(129); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(53); + parseExpected(54); node.type = parseType(); parseSemicolon(); return finishNode(node); } function parseEnumMember() { - var node = createNode(229, scanner.getStartPos()); + var node = createNode(244, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(207, fullStart); + var node = createNode(214, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(77); + parseExpected(78); node.name = parseIdentifier(); if (parseExpected(14)) { node.members = parseDelimitedList(6, parseEnumMember); @@ -8258,7 +8730,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(209, scanner.getStartPos()); + var node = createNode(216, scanner.getStartPos()); if (parseExpected(14)) { node.statements = parseList(1, parseStatement); parseExpected(15); @@ -8269,7 +8741,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(208, fullStart); + var node = createNode(215, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; @@ -8280,7 +8752,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(208, fullStart); + var node = createNode(215, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(true); @@ -8289,11 +8761,11 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(119)) { - flags |= 32768; + if (parseOptional(123)) { + flags |= 131072; } else { - parseExpected(118); + parseExpected(122); if (token === 8) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -8301,61 +8773,64 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 120 && + return token === 124 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { return nextToken() === 16; } + function nextTokenIsSlash() { + return nextToken() === 37; + } function nextTokenIsCommaOrFromKeyword() { nextToken(); return token === 23 || - token === 126; + token === 130; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(85); + parseExpected(86); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 23 && token !== 126) { - var importEqualsDeclaration = createNode(211, fullStart); + if (token !== 23 && token !== 130) { + var importEqualsDeclaration = createNode(218, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; - parseExpected(53); + parseExpected(54); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(importEqualsDeclaration); } } - var importDeclaration = createNode(212, fullStart); + var importDeclaration = createNode(219, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); if (identifier || - token === 35 || + token === 36 || token === 14) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(126); + parseExpected(130); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - //ImportClause: + // ImportClause: // ImportedDefaultBinding // NameSpaceImport // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(213, fullStart); + var importClause = createNode(220, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(23)) { - importClause.namedBindings = token === 35 ? parseNamespaceImport() : parseNamedImportsOrExports(215); + importClause.namedBindings = token === 36 ? parseNamespaceImport() : parseNamedImportsOrExports(222); } return finishNode(importClause); } @@ -8365,8 +8840,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(222); - parseExpected(120); + var node = createNode(229); + parseExpected(124); parseExpected(16); node.expression = parseModuleSpecifier(); parseExpected(17); @@ -8380,22 +8855,22 @@ var ts; return result; } function parseNamespaceImport() { - var namespaceImport = createNode(214); - parseExpected(35); - parseExpected(111); + var namespaceImport = createNode(221); + parseExpected(36); + parseExpected(113); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(19, kind === 215 ? parseImportSpecifier : parseExportSpecifier, 14, 15); + node.elements = parseBracketedList(21, kind === 222 ? parseImportSpecifier : parseExportSpecifier, 14, 15); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(220); + return parseImportOrExportSpecifier(227); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(216); + return parseImportOrExportSpecifier(223); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -8403,9 +8878,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token === 111) { + if (token === 113) { node.propertyName = identifierName; - parseExpected(111); + parseExpected(113); checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -8414,22 +8889,22 @@ var ts; else { node.name = identifierName; } - if (kind === 216 && checkIdentifierIsKeyword) { + if (kind === 223 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(218, fullStart); + var node = createNode(225, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(35)) { - parseExpected(126); + if (parseOptional(36)) { + parseExpected(130); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(219); - if (parseOptional(126)) { + node.exportClause = parseNamedImportsOrExports(226); + if (parseOptional(130)) { node.moduleSpecifier = parseModuleSpecifier(); } } @@ -8437,21 +8912,21 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(217, fullStart); + var node = createNode(224, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(53)) { + if (parseOptional(54)) { node.isExportEquals = true; } else { - parseExpected(73); + parseExpected(74); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); return finishNode(node); } function processReferenceComments(sourceFile) { - var triviaScanner = ts.createScanner(sourceFile.languageVersion, false, sourceText); + var triviaScanner = ts.createScanner(sourceFile.languageVersion, false, 0, sourceText); var referencedFiles = []; var amdDependencies = []; var amdModuleName; @@ -8507,10 +8982,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 - || node.kind === 211 && node.moduleReference.kind === 222 - || node.kind === 212 - || node.kind === 217 - || node.kind === 218 + || node.kind === 218 && node.moduleReference.kind === 229 + || node.kind === 219 + || node.kind === 224 + || node.kind === 225 ? node : undefined; }); @@ -8519,16 +8994,16 @@ var ts; (function (JSDocParser) { function isJSDocType() { switch (token) { - case 35: - case 50: + case 36: + case 51: case 16: case 18: - case 46: + case 47: case 14: - case 83: + case 84: case 21: - case 88: - case 93: + case 89: + case 94: return true; } return isIdentifierOrKeyword(); @@ -8545,7 +9020,7 @@ var ts; function parseJSDocTypeExpression(start, length) { scanner.setText(sourceText, start, length); token = nextToken(); - var result = createNode(231); + var result = createNode(246); parseExpected(14); result.type = parseJSDocTopLevelType(); parseExpected(15); @@ -8555,13 +9030,13 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token === 44) { - var unionType = createNode(235, type.pos); + if (token === 45) { + var unionType = createNode(250, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token === 53) { - var optionalType = createNode(242, type.pos); + if (token === 54) { + var optionalType = createNode(257, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -8572,20 +9047,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token === 18) { - var arrayType = createNode(234, type.pos); + var arrayType = createNode(249, type.pos); arrayType.elementType = type; nextToken(); parseExpected(19); type = finishNode(arrayType); } - else if (token === 50) { - var nullableType = createNode(237, type.pos); + else if (token === 51) { + var nullableType = createNode(252, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token === 46) { - var nonNullableType = createNode(238, type.pos); + else if (token === 47) { + var nonNullableType = createNode(253, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -8598,82 +9073,82 @@ var ts; } function parseBasicTypeExpression() { switch (token) { - case 35: + case 36: return parseJSDocAllType(); - case 50: + case 51: return parseJSDocUnknownOrNullableType(); case 16: return parseJSDocUnionType(); case 18: return parseJSDocTupleType(); - case 46: + case 47: return parseJSDocNonNullableType(); case 14: return parseJSDocRecordType(); - case 83: + case 84: return parseJSDocFunctionType(); case 21: return parseJSDocVariadicType(); - case 88: + case 89: return parseJSDocConstructorType(); - case 93: + case 94: return parseJSDocThisType(); - case 112: - case 123: - case 121: - case 113: - case 124: - case 99: + case 114: + case 127: + case 125: + case 117: + case 128: + case 100: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(246); + var result = createNode(261); nextToken(); - parseExpected(51); + parseExpected(52); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(245); + var result = createNode(260); nextToken(); - parseExpected(51); + parseExpected(52); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(244); + var result = createNode(259); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(243); + var result = createNode(258); nextToken(); parseExpected(16); - result.parameters = parseDelimitedList(20, parseJSDocParameter); + result.parameters = parseDelimitedList(22, parseJSDocParameter); checkForTrailingComma(result.parameters); parseExpected(17); - if (token === 51) { + if (token === 52) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(131); + var parameter = createNode(135); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type) { - var result = createNode(242, type.pos); + var result = createNode(257, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference() { - var result = createNode(241); + var result = createNode(256); result.name = parseSimplePropertyName(); while (parseOptional(20)) { if (token === 24) { @@ -8688,10 +9163,10 @@ var ts; } function parseTypeArguments() { nextToken(); - var typeArguments = parseDelimitedList(21, parseJSDocType); + var typeArguments = parseDelimitedList(23, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); - parseExpected(25); + parseExpected(26); return typeArguments; } function checkForEmptyTypeArgumentList(typeArguments) { @@ -8702,38 +9177,38 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(128, left.pos); + var result = createNode(132, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(239); + var result = createNode(254); nextToken(); - result.members = parseDelimitedList(22, parseJSDocRecordMember); + result.members = parseDelimitedList(24, parseJSDocRecordMember); checkForTrailingComma(result.members); parseExpected(15); return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(240); + var result = createNode(255); result.name = parseSimplePropertyName(); - if (token === 51) { + if (token === 52) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(238); + var result = createNode(253); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(236); + var result = createNode(251); nextToken(); - result.types = parseDelimitedList(23, parseJSDocType); + result.types = parseDelimitedList(25, parseJSDocType); checkForTrailingComma(result.types); parseExpected(19); return finishNode(result); @@ -8745,7 +9220,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(235); + var result = createNode(250); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(17); @@ -8756,14 +9231,14 @@ var ts; var types = []; types.pos = firstType.pos; types.push(firstType); - while (parseOptional(44)) { + while (parseOptional(45)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); return types; } function parseJSDocAllType() { - var result = createNode(232); + var result = createNode(247); nextToken(); return finishNode(result); } @@ -8773,14 +9248,14 @@ var ts; if (token === 23 || token === 15 || token === 17 || - token === 25 || - token === 53 || - token === 44) { - var result = createNode(233, pos); + token === 26 || + token === 54 || + token === 45) { + var result = createNode(248, pos); return finishNode(result); } else { - var result = createNode(237, pos); + var result = createNode(252, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -8851,7 +9326,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(247, start); + var result = createNode(262, start); result.tags = tags; return finishNode(result, end); } @@ -8862,9 +9337,8 @@ var ts; } function parseTag() { ts.Debug.assert(content.charCodeAt(pos - 1) === 64); - var atToken = createNode(52, pos - 1); + var atToken = createNode(53, pos - 1); atToken.end = pos; - var startPos = pos; var tagName = scanIdentifier(); if (!tagName) { return; @@ -8889,7 +9363,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(248, atToken.pos); + var result = createNode(263, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -8941,7 +9415,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(249, atToken.pos); + var result = createNode(264, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -8951,27 +9425,27 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 250; })) { + if (ts.forEach(tags, function (t) { return t.kind === 265; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(250, atToken.pos); + var result = createNode(265, 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 === 251; })) { + if (ts.forEach(tags, function (t) { return t.kind === 266; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(251, atToken.pos); + var result = createNode(266, 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 === 252; })) { + if (ts.forEach(tags, function (t) { return t.kind === 267; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = []; @@ -8979,13 +9453,13 @@ var ts; while (true) { skipWhitespace(); var startPos = pos; - var name_7 = scanIdentifier(); - if (!name_7) { + var name_9 = scanIdentifier(); + if (!name_9) { parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(130, name_7.pos); - typeParameter.name = name_7; + var typeParameter = createNode(134, name_9.pos); + typeParameter.name = name_9; finishNode(typeParameter, pos); typeParameters.push(typeParameter); skipWhitespace(); @@ -8995,7 +9469,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(252, atToken.pos); + var result = createNode(267, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -9016,7 +9490,7 @@ var ts; if (startPos === pos) { return undefined; } - var result = createNode(65, startPos); + var result = createNode(66, startPos); result.text = content.substring(startPos, pos); return finishNode(result, pos); } @@ -9060,8 +9534,9 @@ var ts; } return; function visitNode(node) { + var text = ''; if (aggressiveChecks && shouldCheckNode(node)) { - var text = oldText.substring(node.pos, node.end); + text = oldText.substring(node.pos, node.end); } if (node._children) { node._children = undefined; @@ -9091,7 +9566,7 @@ var ts; switch (node.kind) { case 8: case 7: - case 65: + case 66: return true; } return false; @@ -9310,16 +9785,16 @@ var ts; (function (ts) { ts.bindTime = 0; function getModuleInstanceState(node) { - if (node.kind === 205 || node.kind === 206) { + if (node.kind === 212 || node.kind === 213) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 212 || node.kind === 211) && !(node.flags & 1)) { + else if ((node.kind === 219 || node.kind === 218) && !(node.flags & 1)) { return 0; } - else if (node.kind === 209) { + else if (node.kind === 216) { var state = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -9335,7 +9810,7 @@ var ts; }); return state; } - else if (node.kind === 208) { + else if (node.kind === 215) { return getModuleInstanceState(node.body); } else { @@ -9387,10 +9862,10 @@ var ts; } function getDeclarationName(node) { if (node.name) { - if (node.kind === 208 && node.name.kind === 8) { + if (node.kind === 215 && node.name.kind === 8) { return '"' + node.name.text + '"'; } - if (node.name.kind === 129) { + if (node.name.kind === 133) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -9398,23 +9873,23 @@ var ts; return node.name.text; } switch (node.kind) { - case 137: - return "__constructor"; - case 145: - case 140: - return "__call"; - case 146: case 141: + return "__constructor"; + case 149: + case 144: + return "__call"; + case 150: + case 145: return "__new"; - case 142: + case 146: return "__index"; - case 218: + case 225: return "__export"; - case 217: + case 224: return node.isExportEquals ? "export=" : "default"; - case 203: - case 204: - return node.flags & 256 ? "default" : undefined; + case 210: + case 211: + return node.flags & 1024 ? "default" : undefined; } } function getDisplayName(node) { @@ -9422,7 +9897,7 @@ var ts; } function declareSymbol(symbolTable, parent, node, includes, excludes) { ts.Debug.assert(!ts.hasDynamicName(node)); - var name = node.flags & 256 && parent ? "default" : getDeclarationName(node); + var name = node.flags & 1024 && parent ? "default" : getDeclarationName(node); var symbol; if (name !== undefined) { symbol = ts.hasProperty(symbolTable, name) @@ -9455,7 +9930,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 220 || (node.kind === 211 && hasExportModifier)) { + if (node.kind === 227 || (node.kind === 218 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -9463,7 +9938,7 @@ var ts; } } else { - if (hasExportModifier || container.flags & 65536) { + if (hasExportModifier || container.flags & 262144) { var exportKind = (symbolFlags & 107455 ? 1048576 : 0) | (symbolFlags & 793056 ? 2097152 : 0) | (symbolFlags & 1536 ? 4194304 : 0); @@ -9501,37 +9976,37 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 177: - case 204: - case 205: - case 207: - case 148: - case 157: + case 183: + case 211: + case 212: + case 214: + case 152: + case 162: return 1; - case 140: - case 141: - case 142: - case 136: - case 135: - case 203: - case 137: - case 138: - case 139: + case 144: case 145: case 146: - case 165: - case 166: - case 208: - case 230: - case 206: - return 5; - case 226: - case 189: - case 190: - case 191: + case 140: + case 139: case 210: + case 141: + case 142: + case 143: + case 149: + case 150: + case 170: + case 171: + case 215: + case 245: + case 213: + return 5; + case 241: + case 196: + case 197: + case 198: + case 217: return 2; - case 182: + case 189: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -9547,33 +10022,33 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 208: + case 215: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 230: + case 245: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 177: - case 204: + case 183: + case 211: return declareClassMember(node, symbolFlags, symbolExcludes); - case 207: + case 214: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 148: - case 157: - case 205: + case 152: + case 162: + case 212: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); + case 149: + case 150: + case 144: case 145: case 146: case 140: + case 139: case 141: case 142: - case 136: - case 135: - case 137: - case 138: - case 139: - case 203: - case 165: - case 166: - case 206: + case 143: + case 210: + case 170: + case 171: + case 213: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -9597,11 +10072,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 230 ? node : node.body; - if (body.kind === 230 || body.kind === 209) { + var body = node.kind === 245 ? node : node.body; + if (body.kind === 245 || body.kind === 216) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 218 || stat.kind === 217) { + if (stat.kind === 225 || stat.kind === 224) { return true; } } @@ -9610,10 +10085,10 @@ var ts; } function setExportContextFlag(node) { if (isAmbientContext(node) && !hasExportDeclarations(node)) { - node.flags |= 65536; + node.flags |= 262144; } else { - node.flags &= ~65536; + node.flags &= ~262144; } } function bindModuleDeclaration(node) { @@ -9651,11 +10126,11 @@ var ts; var seen = {}; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 65) { + if (prop.name.kind !== 66) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 227 || prop.kind === 228 || prop.kind === 136 + var currentKind = prop.kind === 242 || prop.kind === 243 || prop.kind === 140 ? 1 : 2; var existingKind = seen[identifier.text]; @@ -9677,10 +10152,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 208: + case 215: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 230: + case 245: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -9698,8 +10173,8 @@ var ts; } function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 102 && - node.originalKeywordKind <= 110 && + node.originalKeywordKind >= 103 && + node.originalKeywordKind <= 111 && !ts.isIdentifierName(node)) { if (!file.parseDiagnostics.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); @@ -9726,17 +10201,17 @@ var ts; } } function checkStrictModeDeleteExpression(node) { - if (inStrictMode && node.expression.kind === 65) { + if (inStrictMode && node.expression.kind === 66) { var span = ts.getErrorSpanForNode(file, node.expression); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 65 && + return node.kind === 66 && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 65) { + if (name && name.kind === 66) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { var span = ts.getErrorSpanForNode(file, name); @@ -9759,7 +10234,7 @@ var ts; } } function checkStrictModeNumericLiteral(node) { - if (inStrictMode && node.flags & 16384) { + if (inStrictMode && node.flags & 65536) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); } } @@ -9770,7 +10245,7 @@ var ts; } function checkStrictModePrefixUnaryExpression(node) { if (inStrictMode) { - if (node.operator === 38 || node.operator === 39) { + if (node.operator === 39 || node.operator === 40) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -9799,17 +10274,17 @@ var ts; } function updateStrictMode(node) { switch (node.kind) { - case 230: - case 209: + case 245: + case 216: updateStrictModeStatementList(node.statements); return; - case 182: + case 189: if (ts.isFunctionLike(node.parent)) { updateStrictModeStatementList(node.statements); } return; - case 204: - case 177: + case 211: + case 183: inStrictMode = true; return; } @@ -9832,87 +10307,88 @@ var ts; } function bindWorker(node) { switch (node.kind) { - case 65: + case 66: return checkStrictModeIdentifier(node); - case 172: + case 178: return checkStrictModeBinaryExpression(node); - case 226: + case 241: return checkStrictModeCatchClause(node); - case 167: + case 172: return checkStrictModeDeleteExpression(node); case 7: return checkStrictModeNumericLiteral(node); - case 171: + case 177: return checkStrictModePostfixUnaryExpression(node); - case 170: + case 176: return checkStrictModePrefixUnaryExpression(node); - case 195: + case 202: return checkStrictModeWithStatement(node); - case 130: - return declareSymbolAndAddToSymbolTable(node, 262144, 530912); - case 131: - return bindParameter(node); - case 201: - case 155: - return bindVariableDeclarationOrBindingElement(node); case 134: - case 133: - return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); - case 227: - case 228: - return bindPropertyOrMethodOrAccessor(node, 4, 107455); - case 229: - return bindPropertyOrMethodOrAccessor(node, 8, 107455); - case 140: - case 141: - case 142: - return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 136: + return declareSymbolAndAddToSymbolTable(node, 262144, 530912); case 135: - return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); - case 203: - checkStrictModeFunctionName(node); - return declareSymbolAndAddToSymbolTable(node, 16, 106927); - case 137: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); + return bindParameter(node); + case 208: + case 160: + return bindVariableDeclarationOrBindingElement(node); case 138: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); - case 139: - return bindPropertyOrMethodOrAccessor(node, 65536, 74687); + case 137: + return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 536870912 : 0), 107455); + case 242: + case 243: + return bindPropertyOrMethodOrAccessor(node, 4, 107455); + case 244: + return bindPropertyOrMethodOrAccessor(node, 8, 107455); + case 144: case 145: case 146: - return bindFunctionOrConstructorType(node); - case 148: - return bindAnonymousDeclaration(node, 2048, "__type"); - case 157: - return bindObjectLiteralExpression(node); - case 165: - case 166: + return declareSymbolAndAddToSymbolTable(node, 131072, 0); + case 140: + case 139: + return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 536870912 : 0), ts.isObjectLiteralMethod(node) ? 107455 : 99263); + case 210: checkStrictModeFunctionName(node); - return bindAnonymousDeclaration(node, 16, "__function"); - case 177: - case 204: - return bindClassLikeDeclaration(node); - case 205: - return bindBlockScopedDeclaration(node, 64, 792992); - case 206: - return bindBlockScopedDeclaration(node, 524288, 793056); - case 207: - return bindEnumDeclaration(node); - case 208: - return bindModuleDeclaration(node); + return declareSymbolAndAddToSymbolTable(node, 16, 106927); + case 141: + return declareSymbolAndAddToSymbolTable(node, 16384, 0); + case 142: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 143: + return bindPropertyOrMethodOrAccessor(node, 65536, 74687); + case 149: + case 150: + return bindFunctionOrConstructorType(node); + case 152: + return bindAnonymousDeclaration(node, 2048, "__type"); + case 162: + return bindObjectLiteralExpression(node); + case 170: + case 171: + checkStrictModeFunctionName(node); + var bindingName = node.name ? node.name.text : "__function"; + return bindAnonymousDeclaration(node, 16, bindingName); + case 183: case 211: - case 214: - case 216: - case 220: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + return bindClassLikeDeclaration(node); + case 212: + return bindBlockScopedDeclaration(node, 64, 792960); case 213: - return bindImportClause(node); + return bindBlockScopedDeclaration(node, 524288, 793056); + case 214: + return bindEnumDeclaration(node); + case 215: + return bindModuleDeclaration(node); case 218: + case 221: + case 223: + case 227: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 220: + return bindImportClause(node); + case 225: return bindExportDeclaration(node); - case 217: + case 224: return bindExportAssignment(node); - case 230: + case 245: return bindSourceFileIfExternalModule(); } } @@ -9926,7 +10402,7 @@ var ts; if (!container.symbol || !container.symbol.exports) { bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } - else if (node.expression.kind === 65) { + else if (node.expression.kind === 66) { declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 107455 | 8388608); } else { @@ -9947,11 +10423,12 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 204) { - bindBlockScopedDeclaration(node, 32, 899583); + if (node.kind === 211) { + bindBlockScopedDeclaration(node, 32, 899519); } else { - bindAnonymousDeclaration(node, 32, "__class"); + var bindingName = node.name ? node.name.text : "__class"; + bindAnonymousDeclaration(node, 32, bindingName); } var symbol = node.symbol; var prototypeSymbol = createSymbol(4 | 134217728, "prototype"); @@ -9996,7 +10473,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 1, 107455); } if (node.flags & 112 && - node.parent.kind === 137 && + node.parent.kind === 141 && ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4, 107455); @@ -10030,6 +10507,7 @@ var ts; } ts.getSymbolId = getSymbolId; function createTypeChecker(host, produceDiagnostics) { + var cancellationToken; var Symbol = ts.objectAllocator.getSymbolConstructor(); var Type = ts.objectAllocator.getTypeConstructor(); var Signature = ts.objectAllocator.getSignatureConstructor(); @@ -10075,7 +10553,9 @@ var ts; isImplementationOfOverload: isImplementationOfOverload, getAliasedSymbol: resolveAlias, getEmitResolver: getEmitResolver, - getExportsOfModule: getExportsOfModuleAsArray + getExportsOfModule: getExportsOfModuleAsArray, + getJsxElementAttributesType: getJsxElementAttributesType, + getJsxIntrinsicTagNames: getJsxIntrinsicTagNames }; var unknownSymbol = createSymbol(4 | 67108864, "unknown"); var resolvingSymbol = createSymbol(67108864, "__resolving__"); @@ -10083,10 +10563,10 @@ var ts; var stringType = createIntrinsicType(2, "string"); var numberType = createIntrinsicType(4, "number"); var booleanType = createIntrinsicType(8, "boolean"); - var esSymbolType = createIntrinsicType(2097152, "symbol"); + var esSymbolType = createIntrinsicType(4194304, "symbol"); var voidType = createIntrinsicType(16, "void"); - var undefinedType = createIntrinsicType(32 | 524288, "undefined"); - var nullType = createIntrinsicType(64 | 524288, "null"); + var undefinedType = createIntrinsicType(32 | 1048576, "undefined"); + var nullType = createIntrinsicType(64 | 1048576, "null"); var unknownType = createIntrinsicType(1, "unknown"); var circularType = createIntrinsicType(1, "__circular__"); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); @@ -10098,6 +10578,7 @@ var ts; var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); var globals = {}; var globalESSymbolConstructorSymbol; + var getGlobalPromiseConstructorSymbol; var globalObjectType; var globalFunctionType; var globalArrayType; @@ -10107,23 +10588,39 @@ var ts; var globalRegExpType; var globalTemplateStringsArrayType; var globalESSymbolType; + var jsxElementType; + var jsxIntrinsicElementsType; var globalIterableType; var globalIteratorType; var globalIterableIteratorType; var anyArrayType; + var getGlobalClassDecoratorType; + var getGlobalParameterDecoratorType; + var getGlobalPropertyDecoratorType; + var getGlobalMethodDecoratorType; var getGlobalTypedPropertyDescriptorType; + var getGlobalPromiseType; + var tryGetGlobalPromiseType; + var getGlobalPromiseLikeType; + var getInstantiatedGlobalPromiseLikeType; + var getGlobalPromiseConstructorLikeType; + var getGlobalThenableType; var tupleTypes = {}; var unionTypes = {}; + var intersectionTypes = {}; var stringLiteralTypes = {}; var emitExtends = false; var emitDecorate = false; var emitParam = false; + var emitAwaiter = false; + var emitGenerator = false; var resolutionTargets = []; var resolutionResults = []; var mergedSymbols = []; var symbolLinks = []; var nodeLinks = []; var potentialThisCollisions = []; + var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); var primitiveTypeInfo = { "string": { @@ -10140,16 +10637,23 @@ var ts; }, "symbol": { type: esSymbolType, - flags: 2097152 + flags: 4194304 } }; + var JsxNames = { + JSX: "JSX", + IntrinsicElements: "IntrinsicElements", + ElementClass: "ElementClass", + ElementAttributesPropertyNameContainer: "ElementAttributesProperty", + Element: "Element" + }; var subtypeRelation = {}; var assignableRelation = {}; var identityRelation = {}; initializeTypeChecker(); return checker; - function getEmitResolver(sourceFile) { - getDiagnostics(sourceFile); + function getEmitResolver(sourceFile, cancellationToken) { + getDiagnostics(sourceFile, cancellationToken); return emitResolver; } function error(location, message, arg0, arg1, arg2) { @@ -10174,9 +10678,9 @@ var ts; if (flags & 16) result |= 106927; if (flags & 32) - result |= 899583; + result |= 899519; if (flags & 64) - result |= 792992; + result |= 792960; if (flags & 256) result |= 899327; if (flags & 128) @@ -10287,10 +10791,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 230); + return ts.getAncestor(node, 245); } function isGlobalSourceFile(node) { - return node.kind === 230 && !ts.isExternalModule(node); + return node.kind === 245 && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -10338,16 +10842,16 @@ var ts; } } switch (location.kind) { - case 230: + case 245: if (!ts.isExternalModule(location)) break; - case 208: + case 215: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 230 || - (location.kind === 208 && location.name.kind === 8)) { + if (location.kind === 245 || + (location.kind === 215 && location.name.kind === 8)) { if (ts.hasProperty(moduleExports, name) && moduleExports[name].flags === 8388608 && - ts.getDeclarationOfKind(moduleExports[name], 220)) { + ts.getDeclarationOfKind(moduleExports[name], 227)) { break; } result = moduleExports["default"]; @@ -10361,13 +10865,13 @@ var ts; break loop; } break; - case 207: + case 214: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; - case 134: - case 133: + case 138: + case 137: if (ts.isClassLike(location.parent) && !(location.flags & 128)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -10377,9 +10881,9 @@ var ts; } } break; - case 204: - case 177: - case 205: + case 211: + case 183: + case 212: 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); @@ -10387,7 +10891,7 @@ var ts; } break loop; } - if (location.kind === 177 && meaning & 32) { + if (location.kind === 183 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -10395,28 +10899,28 @@ var ts; } } break; - case 129: + case 133: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 205) { + if (ts.isClassLike(grandparent) || grandparent.kind === 212) { 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 136: - case 135: - case 137: - case 138: + case 140: case 139: - case 203: - case 166: + case 141: + case 142: + case 143: + case 210: + case 171: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 165: + case 170: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -10429,8 +10933,8 @@ var ts; } } break; - case 132: - if (location.parent && location.parent.kind === 131) { + case 136: + if (location.parent && location.parent.kind === 135) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -10468,14 +10972,14 @@ var ts; ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); var isUsedBeforeDeclaration = !isDefinedBefore(declaration, errorLocation); if (!isUsedBeforeDeclaration) { - var variableDeclaration = ts.getAncestor(declaration, 201); + var variableDeclaration = ts.getAncestor(declaration, 208); var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 183 || - variableDeclaration.parent.parent.kind === 189) { + if (variableDeclaration.parent.parent.kind === 190 || + variableDeclaration.parent.parent.kind === 196) { isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); } - else if (variableDeclaration.parent.parent.kind === 191 || - variableDeclaration.parent.parent.kind === 190) { + else if (variableDeclaration.parent.parent.kind === 198 || + variableDeclaration.parent.parent.kind === 197) { var expression = variableDeclaration.parent.parent.expression; isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); } @@ -10497,10 +11001,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 211) { + if (node.kind === 218) { return node; } - while (node && node.kind !== 212) { + while (node && node.kind !== 219) { node = node.parent; } return node; @@ -10510,7 +11014,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 222) { + if (node.moduleReference.kind === 229) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -10572,15 +11076,15 @@ var ts; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); if (targetSymbol) { - var name_8 = specifier.propertyName || specifier.name; - if (name_8.text) { - var symbolFromModule = getExportOfModule(targetSymbol, name_8.text); - var symbolFromVariable = getPropertyOfVariable(targetSymbol, name_8.text); + var name_10 = specifier.propertyName || specifier.name; + if (name_10.text) { + var symbolFromModule = getExportOfModule(targetSymbol, name_10.text); + var symbolFromVariable = getPropertyOfVariable(targetSymbol, name_10.text); var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable; if (!symbol) { - error(name_8, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_8)); + error(name_10, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_10)); } return symbol; } @@ -10599,17 +11103,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 211: + case 218: return getTargetOfImportEqualsDeclaration(node); - case 213: - return getTargetOfImportClause(node); - case 214: - return getTargetOfNamespaceImport(node); - case 216: - return getTargetOfImportSpecifier(node); case 220: + return getTargetOfImportClause(node); + case 221: + return getTargetOfNamespaceImport(node); + case 223: + return getTargetOfImportSpecifier(node); + case 227: return getTargetOfExportSpecifier(node); - case 217: + case 224: return getTargetOfExportAssignment(node); } } @@ -10651,10 +11155,10 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 217) { + if (node.kind === 224) { checkExpressionCached(node.expression); } - else if (node.kind === 220) { + else if (node.kind === 227) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -10664,45 +11168,47 @@ var ts; } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 211); + importDeclaration = ts.getAncestor(entityName, 218); ts.Debug.assert(importDeclaration !== undefined); } - if (entityName.kind === 65 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 66 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 65 || entityName.parent.kind === 128) { + if (entityName.kind === 66 || entityName.parent.kind === 132) { return resolveEntityName(entityName, 1536); } else { - ts.Debug.assert(entityName.parent.kind === 211); + ts.Debug.assert(entityName.parent.kind === 218); return resolveEntityName(entityName, 107455 | 793056 | 1536); } } function getFullyQualifiedName(symbol) { return symbol.parent ? getFullyQualifiedName(symbol.parent) + "." + symbolToString(symbol) : symbolToString(symbol); } - function resolveEntityName(name, meaning) { + function resolveEntityName(name, meaning, ignoreErrors) { if (ts.nodeIsMissing(name)) { return undefined; } var symbol; - if (name.kind === 65) { + if (name.kind === 66) { var message = meaning === 1536 ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; - symbol = resolveName(name, name.text, meaning, message, name); + symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 128 || name.kind === 158) { - var left = name.kind === 128 ? name.left : name.expression; - var right = name.kind === 128 ? name.right : name.name; - var namespace = resolveEntityName(left, 1536); + else if (name.kind === 132 || name.kind === 163) { + var left = name.kind === 132 ? name.left : name.expression; + var right = name.kind === 132 ? name.right : name.name; + var namespace = resolveEntityName(left, 1536, ignoreErrors); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; } symbol = getSymbol(getExportsOfSymbol(namespace), right.text, meaning); if (!symbol) { - error(right, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(namespace), ts.declarationNameToString(right)); + if (!ignoreErrors) { + error(right, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(namespace), ts.declarationNameToString(right)); + } return undefined; } } @@ -10840,7 +11346,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 137 && ts.nodeIsPresent(member.body)) { + if (member.kind === 141 && ts.nodeIsPresent(member.body)) { return member; } } @@ -10894,7 +11400,7 @@ var ts; return type; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { - return setObjectTypeMembers(createObjectType(32768, symbol), members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + return setObjectTypeMembers(createObjectType(65536, symbol), members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; @@ -10905,17 +11411,17 @@ var ts; } } switch (location_1.kind) { - case 230: + case 245: if (!ts.isExternalModule(location_1)) { break; } - case 208: + case 215: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 204: - case 205: + case 211: + case 212: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -10946,7 +11452,9 @@ var ts; return [symbol]; } return ts.forEachValue(symbols, function (symbolFromSymbolTable) { - if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=") { + if (symbolFromSymbolTable.flags & 8388608 + && symbolFromSymbolTable.name !== "export=" + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 227)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -10975,7 +11483,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 227)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -11030,8 +11538,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 208 && declaration.name.kind === 8) || - (declaration.kind === 230 && ts.isExternalModule(declaration)); + return (declaration.kind === 215 && declaration.name.kind === 8) || + (declaration.kind === 245 && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -11063,11 +11571,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 147) { + if (entityName.parent.kind === 151) { meaning = 107455 | 1048576; } - else if (entityName.kind === 128 || entityName.kind === 158 || - entityName.parent.kind === 211) { + else if (entityName.kind === 132 || entityName.kind === 163 || + entityName.parent.kind === 218) { meaning = 1536; } else { @@ -11118,10 +11626,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { var node = type.symbol.declarations[0].parent; - while (node.kind === 152) { + while (node.kind === 157) { node = node.parent; } - if (node.kind === 206) { + if (node.kind === 213) { return getSymbolOfNode(node); } } @@ -11136,10 +11644,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 177: + case 183: return "(Anonymous class)"; - case 165: - case 166: + case 170: + case 171: return "(Anonymous function)"; } } @@ -11202,7 +11710,7 @@ var ts; var globalFlagsToPass = globalFlags & 16; return writeType(type, globalFlags); function writeType(type, flags) { - if (type.flags & 2097279) { + if (type.flags & 4194431) { writer.writeKeyword(!(globalFlags & 16) && isTypeAny(type) ? "any" : type.intrinsicName); @@ -11216,10 +11724,10 @@ var ts; else if (type.flags & 8192) { writeTupleType(type); } - else if (type.flags & 16384) { - writeUnionType(type, flags); + else if (type.flags & 49152) { + writeUnionOrIntersectionType(type, flags); } - else if (type.flags & 32768) { + else if (type.flags & 65536) { writeAnonymousType(type, flags); } else if (type.flags & 256) { @@ -11233,16 +11741,16 @@ var ts; writePunctuation(writer, 15); } } - function writeTypeList(types, union) { + function writeTypeList(types, delimiter) { for (var i = 0; i < types.length; i++) { if (i > 0) { - if (union) { + if (delimiter !== 23) { writeSpace(writer); } - writePunctuation(writer, union ? 44 : 23); + writePunctuation(writer, delimiter); writeSpace(writer); } - writeType(types[i], union ? 64 : 0); + writeType(types[i], delimiter === 23 ? 0 : 64); } } function writeSymbolTypeReference(symbol, typeArguments, pos, end) { @@ -11257,7 +11765,7 @@ var ts; writeSpace(writer); writeType(typeArguments[pos++], 0); } - writePunctuation(writer, 25); + writePunctuation(writer, 26); } } function writeTypeReference(type, flags) { @@ -11289,14 +11797,14 @@ var ts; } function writeTupleType(type) { writePunctuation(writer, 18); - writeTypeList(type.elementTypes, false); + writeTypeList(type.elementTypes, 23); writePunctuation(writer, 19); } - function writeUnionType(type, flags) { + function writeUnionOrIntersectionType(type, flags) { if (flags & 64) { writePunctuation(writer, 16); } - writeTypeList(type.types, true); + writeTypeList(type.types, type.flags & 16384 ? 45 : 44); if (flags & 64) { writePunctuation(writer, 17); } @@ -11316,7 +11824,7 @@ var ts; buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793056, 0, flags); } else { - writeKeyword(writer, 112); + writeKeyword(writer, 114); } } else { @@ -11337,7 +11845,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 230 || declaration.parent.kind === 209; + return declaration.parent.kind === 245 || declaration.parent.kind === 216; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -11346,7 +11854,7 @@ var ts; } } function writeTypeofSymbol(type, typeFormatFlags) { - writeKeyword(writer, 97); + writeKeyword(writer, 98); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } @@ -11359,7 +11867,7 @@ var ts; return ts.declarationNameToString(declaration.parameters[0].name); } function writeLiteralType(type, flags) { - var resolved = resolveObjectOrUnionTypeMembers(type); + var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { writePunctuation(writer, 14); @@ -11380,7 +11888,7 @@ var ts; if (flags & 64) { writePunctuation(writer, 16); } - writeKeyword(writer, 88); + writeKeyword(writer, 89); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, symbolStack); if (flags & 64) { @@ -11400,7 +11908,7 @@ var ts; } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - writeKeyword(writer, 88); + writeKeyword(writer, 89); writeSpace(writer); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); writePunctuation(writer, 22); @@ -11409,11 +11917,11 @@ var ts; if (resolved.stringIndexType) { writePunctuation(writer, 18); writer.writeParameter(getIndexerParameterName(resolved, 0, "x")); - writePunctuation(writer, 51); + writePunctuation(writer, 52); writeSpace(writer); - writeKeyword(writer, 123); + writeKeyword(writer, 127); writePunctuation(writer, 19); - writePunctuation(writer, 51); + writePunctuation(writer, 52); writeSpace(writer); writeType(resolved.stringIndexType, 0); writePunctuation(writer, 22); @@ -11422,11 +11930,11 @@ var ts; if (resolved.numberIndexType) { writePunctuation(writer, 18); writer.writeParameter(getIndexerParameterName(resolved, 1, "x")); - writePunctuation(writer, 51); + writePunctuation(writer, 52); writeSpace(writer); - writeKeyword(writer, 121); + writeKeyword(writer, 125); writePunctuation(writer, 19); - writePunctuation(writer, 51); + writePunctuation(writer, 52); writeSpace(writer); writeType(resolved.numberIndexType, 0); writePunctuation(writer, 22); @@ -11441,7 +11949,7 @@ var ts; var signature = signatures[_f]; buildSymbolDisplay(p, writer); if (p.flags & 536870912) { - writePunctuation(writer, 50); + writePunctuation(writer, 51); } buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); writePunctuation(writer, 22); @@ -11451,9 +11959,9 @@ var ts; else { buildSymbolDisplay(p, writer); if (p.flags & 536870912) { - writePunctuation(writer, 50); + writePunctuation(writer, 51); } - writePunctuation(writer, 51); + writePunctuation(writer, 52); writeSpace(writer); writeType(t, 0); writePunctuation(writer, 22); @@ -11475,7 +11983,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 79); + writeKeyword(writer, 80); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -11487,9 +11995,9 @@ var ts; } appendSymbolNameOnly(p, writer); if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 50); + writePunctuation(writer, 51); } - writePunctuation(writer, 51); + writePunctuation(writer, 52); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } @@ -11503,7 +12011,7 @@ var ts; } buildTypeParameterDisplay(typeParameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 25); + writePunctuation(writer, 26); } } function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, symbolStack) { @@ -11516,7 +12024,7 @@ var ts; } buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, 0); } - writePunctuation(writer, 25); + writePunctuation(writer, 26); } } function buildDisplayForParametersAndDelimiters(parameters, writer, enclosingDeclaration, flags, symbolStack) { @@ -11533,13 +12041,24 @@ var ts; function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { if (flags & 8) { writeSpace(writer); - writePunctuation(writer, 32); + writePunctuation(writer, 33); } else { - writePunctuation(writer, 51); + writePunctuation(writer, 52); } writeSpace(writer); - buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags, symbolStack); + var returnType; + if (signature.typePredicate) { + writer.writeParameter(signature.typePredicate.parameterName); + writeSpace(writer); + writeKeyword(writer, 121); + writeSpace(writer); + returnType = signature.typePredicate.type; + } + else { + returnType = getReturnTypeOfSignature(signature); + } + buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); } function buildSignatureDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { if (signature.target && (flags & 32)) { @@ -11569,12 +12088,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 208) { + if (node.kind === 215) { if (node.name.kind === 8) { return node; } } - else if (node.kind === 230) { + else if (node.kind === 245) { return ts.isExternalModule(node) ? node : undefined; } } @@ -11617,58 +12136,59 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 155: + case 160: return isDeclarationVisible(node.parent.parent); - case 201: + case 208: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 208: - case 204: - case 205: - case 206: - case 203: - case 207: + case 215: case 211: + case 212: + case 213: + case 210: + case 214: + case 218: var parent_4 = getDeclarationContainer(node); if (!(ts.getCombinedNodeFlags(node) & 1) && - !(node.kind !== 211 && parent_4.kind !== 230 && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 218 && parent_4.kind !== 245 && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } return isDeclarationVisible(parent_4); - case 134: - case 133: case 138: + case 137: + case 142: + case 143: + case 140: case 139: - case 136: - case 135: if (node.flags & (32 | 64)) { return false; } - case 137: case 141: - case 140: - case 142: - case 131: - case 209: case 145: - case 146: - case 148: case 144: + case 146: + case 135: + case 216: case 149: case 150: - case 151: case 152: + case 148: + case 153: + case 154: + case 155: + case 156: + case 157: return isDeclarationVisible(node.parent); - case 213: - case 214: - case 216: + case 220: + case 221: + case 223: return false; - case 130: - case 230: + case 134: + case 245: return true; - case 217: + case 224: return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -11684,10 +12204,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 217) { + if (node.parent && node.parent.kind === 224) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793056 | 1536, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 220) { + else if (node.parent.kind === 227) { exportSymbol = getTargetOfExportSpecifier(node.parent); } var result = []; @@ -11733,7 +12253,7 @@ var ts; } function getDeclarationContainer(node) { node = ts.getRootDeclaration(node); - return node.kind === 201 ? node.parent.parent.parent : node.parent; + return node.kind === 208 ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { var classType = getDeclaredTypeOfSymbol(prototype.parent); @@ -11759,13 +12279,13 @@ var ts; return parentType; } var type; - if (pattern.kind === 153) { - var name_9 = declaration.propertyName || declaration.name; - type = getTypeOfPropertyOfType(parentType, name_9.text) || - isNumericLiteralName(name_9.text) && getIndexTypeOfType(parentType, 1) || + if (pattern.kind === 158) { + var name_11 = declaration.propertyName || declaration.name; + type = getTypeOfPropertyOfType(parentType, name_11.text) || + isNumericLiteralName(name_11.text) && getIndexTypeOfType(parentType, 1) || getIndexTypeOfType(parentType, 0); if (!type) { - error(name_9, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_9)); + error(name_11, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_11)); return unknownType; } } @@ -11796,10 +12316,10 @@ var ts; return type; } function getTypeForVariableLikeDeclaration(declaration) { - if (declaration.parent.parent.kind === 190) { + if (declaration.parent.parent.kind === 197) { return anyType; } - if (declaration.parent.parent.kind === 191) { + if (declaration.parent.parent.kind === 198) { return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; } if (ts.isBindingPattern(declaration.parent)) { @@ -11808,10 +12328,10 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 131) { + if (declaration.kind === 135) { var func = declaration.parent; - if (func.kind === 139 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 138); + if (func.kind === 143 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 142); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -11824,7 +12344,7 @@ var ts; if (declaration.initializer) { return checkExpressionCached(declaration.initializer); } - if (declaration.kind === 228) { + if (declaration.kind === 243) { return checkIdentifier(declaration.name); } return undefined; @@ -11853,7 +12373,7 @@ var ts; var hasSpreadElement = false; var elementTypes = []; ts.forEach(pattern.elements, function (e) { - elementTypes.push(e.kind === 178 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); + elementTypes.push(e.kind === 184 || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); if (e.dotDotDotToken) { hasSpreadElement = true; } @@ -11868,7 +12388,7 @@ var ts; return createTupleType(elementTypes); } function getTypeFromBindingPattern(pattern) { - return pattern.kind === 153 + return pattern.kind === 158 ? getTypeFromObjectBindingPattern(pattern) : getTypeFromArrayBindingPattern(pattern); } @@ -11878,7 +12398,7 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - return declaration.kind !== 227 ? getWidenedType(type) : type; + return declaration.kind !== 242 ? getWidenedType(type) : type; } if (ts.isBindingPattern(declaration.name)) { return getTypeFromBindingPattern(declaration.name); @@ -11886,7 +12406,7 @@ var ts; type = declaration.dotDotDotToken ? anyArrayType : anyType; if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 131 && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 135 && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -11899,10 +12419,10 @@ var ts; return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 226) { + if (declaration.parent.kind === 241) { return links.type = anyType; } - if (declaration.kind === 217) { + if (declaration.kind === 224) { return links.type = checkExpression(declaration.expression); } if (!pushTypeResolution(symbol)) { @@ -11925,16 +12445,13 @@ var ts; } return links.type; } - function getSetAccessorTypeAnnotationNode(accessor) { - return accessor && accessor.parameters.length > 0 && accessor.parameters[0].type; - } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 138) { + if (accessor.kind === 142) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { - var setterTypeAnnotation = getSetAccessorTypeAnnotationNode(accessor); + var setterTypeAnnotation = ts.getSetAccessorTypeAnnotationNode(accessor); return setterTypeAnnotation && getTypeFromTypeNode(setterTypeAnnotation); } } @@ -11946,8 +12463,8 @@ var ts; if (!pushTypeResolution(symbol)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 138); - var setter = ts.getDeclarationOfKind(symbol, 139); + var getter = ts.getDeclarationOfKind(symbol, 142); + var setter = ts.getDeclarationOfKind(symbol, 143); var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -11973,7 +12490,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 138); + var getter_1 = ts.getDeclarationOfKind(symbol, 142); 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)); } } @@ -11984,7 +12501,7 @@ var ts; function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - links.type = createObjectType(32768, symbol); + links.type = createObjectType(65536, symbol); } return links.type; } @@ -12062,9 +12579,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 204 || node.kind === 177 || - node.kind === 203 || node.kind === 165 || - node.kind === 136 || node.kind === 166) { + if (node.kind === 211 || node.kind === 183 || + node.kind === 210 || node.kind === 170 || + node.kind === 140 || node.kind === 171) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -12073,15 +12590,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 205); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 212); 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 === 205 || node.kind === 204 || - node.kind === 177 || node.kind === 206) { + if (node.kind === 212 || node.kind === 211 || + node.kind === 183 || node.kind === 213) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -12094,7 +12611,7 @@ var ts; return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); } function isConstructorType(type) { - return type.flags & 48128 && getSignaturesOfType(type, 1).length > 0; + return type.flags & 80896 && getSignaturesOfType(type, 1).length > 0; } function getBaseTypeNodeOfClass(type) { return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); @@ -12121,8 +12638,8 @@ var ts; return unknownType; } var baseConstructorType = checkExpression(baseTypeNode.expression); - if (baseConstructorType.flags & 48128) { - resolveObjectOrUnionTypeMembers(baseConstructorType); + if (baseConstructorType.flags & 80896) { + resolveStructuredTypeMembers(baseConstructorType); } if (!popTypeResolution()) { error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); @@ -12153,7 +12670,7 @@ var ts; function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = emptyArray; var baseContructorType = getBaseConstructorTypeOfClass(type); - if (!(baseContructorType.flags & 48128)) { + if (!(baseContructorType.flags & 80896)) { return; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -12186,7 +12703,7 @@ var ts; type.resolvedBaseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 205 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 212 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -12233,7 +12750,7 @@ var ts; if (!pushTypeResolution(links)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 206); + var declaration = ts.getDeclarationOfKind(symbol, 213); var type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -12264,7 +12781,7 @@ var ts; if (!links.declaredType) { var type = createType(512); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 130).constraint) { + if (!ts.getDeclarationOfKind(symbol, 134).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -12426,7 +12943,7 @@ var ts; return members; } function resolveTupleTypeMembers(type) { - var arrayType = resolveObjectOrUnionTypeMembers(createArrayType(getUnionType(type.elementTypes))); + var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes))); var members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); @@ -12483,6 +13000,23 @@ var ts; var numberIndexType = getUnionIndexType(type.types, 1); setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); } + function intersectTypes(type1, type2) { + return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); + } + function resolveIntersectionTypeMembers(type) { + var callSignatures = emptyArray; + var constructSignatures = emptyArray; + var stringIndexType = undefined; + var numberIndexType = undefined; + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(t, 0)); + constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(t, 1)); + stringIndexType = intersectTypes(stringIndexType, getIndexTypeOfType(t, 0)); + numberIndexType = intersectTypes(numberIndexType, getIndexTypeOfType(t, 1)); + } + setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); + } function resolveAnonymousTypeMembers(type) { var symbol = type.symbol; var members; @@ -12514,7 +13048,7 @@ var ts; constructSignatures = getDefaultConstructSignatures(classType); } var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & 48128) { + if (baseConstructorType.flags & 80896) { members = createSymbolTable(getNamedMembers(members)); addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); } @@ -12524,12 +13058,12 @@ var ts; } setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } - function resolveObjectOrUnionTypeMembers(type) { + function resolveStructuredTypeMembers(type) { if (!type.members) { if (type.flags & (1024 | 2048)) { resolveClassOrInterfaceMembers(type); } - else if (type.flags & 32768) { + else if (type.flags & 65536) { resolveAnonymousTypeMembers(type); } else if (type.flags & 8192) { @@ -12538,6 +13072,9 @@ var ts; else if (type.flags & 16384) { resolveUnionTypeMembers(type); } + else if (type.flags & 32768) { + resolveIntersectionTypeMembers(type); + } else { resolveTypeReferenceMembers(type); } @@ -12545,14 +13082,14 @@ var ts; return type; } function getPropertiesOfObjectType(type) { - if (type.flags & 48128) { - return resolveObjectOrUnionTypeMembers(type).properties; + if (type.flags & 80896) { + return resolveStructuredTypeMembers(type).properties; } return emptyArray; } function getPropertyOfObjectType(type, name) { - if (type.flags & 48128) { - var resolved = resolveObjectOrUnionTypeMembers(type); + if (type.flags & 80896) { + var resolved = resolveStructuredTypeMembers(type); if (ts.hasProperty(resolved.members, name)) { var symbol = resolved.members[name]; if (symbolIsValue(symbol)) { @@ -12561,19 +13098,22 @@ var ts; } } } - function getPropertiesOfUnionType(type) { - var result = []; - ts.forEach(getPropertiesOfType(type.types[0]), function (prop) { - var unionProp = getPropertyOfUnionType(type, prop.name); - if (unionProp) { - result.push(unionProp); + function getPropertiesOfUnionOrIntersectionType(type) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var current = _a[_i]; + for (var _b = 0, _c = getPropertiesOfType(current); _b < _c.length; _b++) { + var prop = _c[_b]; + getPropertyOfUnionOrIntersectionType(type, prop.name); } - }); - return result; + if (type.flags & 16384) { + break; + } + } + return type.resolvedProperties ? symbolsToArray(type.resolvedProperties) : emptyArray; } function getPropertiesOfType(type) { type = getApparentType(type); - return type.flags & 16384 ? getPropertiesOfUnionType(type) : getPropertiesOfObjectType(type); + return type.flags & 49152 ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } function getApparentType(type) { if (type.flags & 16384) { @@ -12596,51 +13136,59 @@ var ts; else if (type.flags & 8) { type = globalBooleanType; } - else if (type.flags & 2097152) { + else if (type.flags & 4194304) { type = globalESSymbolType; } return type; } - function createUnionProperty(unionType, name) { - var types = unionType.types; + function createUnionOrIntersectionProperty(containingType, name) { + var types = containingType.types; var props; for (var _i = 0; _i < types.length; _i++) { var current = types[_i]; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); - if (!prop || getDeclarationFlagsFromSymbol(prop) & (32 | 64)) { + if (prop && !(getDeclarationFlagsFromSymbol(prop) & (32 | 64))) { + if (!props) { + props = [prop]; + } + else if (!ts.contains(props, prop)) { + props.push(prop); + } + } + else if (containingType.flags & 16384) { return undefined; } - if (!props) { - props = [prop]; - } - else { - props.push(prop); - } } } + if (!props) { + return undefined; + } + if (props.length === 1) { + return props[0]; + } var propTypes = []; var declarations = []; for (var _a = 0; _a < props.length; _a++) { var prop = props[_a]; if (prop.declarations) { - declarations.push.apply(declarations, prop.declarations); + ts.addRange(declarations, prop.declarations); } propTypes.push(getTypeOfSymbol(prop)); } var result = createSymbol(4 | 67108864 | 268435456, name); - result.unionType = unionType; + result.containingType = containingType; result.declarations = declarations; - result.type = getUnionType(propTypes); + result.type = containingType.flags & 16384 ? getUnionType(propTypes) : getIntersectionType(propTypes); return result; } - function getPropertyOfUnionType(type, name) { + function getPropertyOfUnionOrIntersectionType(type, name) { var properties = type.resolvedProperties || (type.resolvedProperties = {}); if (ts.hasProperty(properties, name)) { return properties[name]; } - var property = createUnionProperty(type, name); + var property = createUnionOrIntersectionProperty(type, name); if (property) { properties[name] = property; } @@ -12648,8 +13196,8 @@ var ts; } function getPropertyOfType(type, name) { type = getApparentType(type); - if (type.flags & 48128) { - var resolved = resolveObjectOrUnionTypeMembers(type); + if (type.flags & 80896) { + var resolved = resolveStructuredTypeMembers(type); if (ts.hasProperty(resolved.members, name)) { var symbol = resolved.members[name]; if (symbolIsValue(symbol)) { @@ -12664,38 +13212,45 @@ var ts; } return getPropertyOfObjectType(globalObjectType, name); } - if (type.flags & 16384) { - return getPropertyOfUnionType(type, name); + if (type.flags & 49152) { + return getPropertyOfUnionOrIntersectionType(type, name); } return undefined; } - function getSignaturesOfObjectOrUnionType(type, kind) { - if (type.flags & (48128 | 16384)) { - var resolved = resolveObjectOrUnionTypeMembers(type); + function getSignaturesOfStructuredType(type, kind) { + if (type.flags & 130048) { + var resolved = resolveStructuredTypeMembers(type); return kind === 0 ? resolved.callSignatures : resolved.constructSignatures; } return emptyArray; } function getSignaturesOfType(type, kind) { - return getSignaturesOfObjectOrUnionType(getApparentType(type), kind); + return getSignaturesOfStructuredType(getApparentType(type), kind); } - function typeHasCallOrConstructSignatures(type) { + function typeHasConstructSignatures(type) { var apparentType = getApparentType(type); - if (apparentType.flags & (48128 | 16384)) { - var resolved = resolveObjectOrUnionTypeMembers(type); - return resolved.callSignatures.length > 0 - || resolved.constructSignatures.length > 0; + if (apparentType.flags & (80896 | 16384)) { + var resolved = resolveStructuredTypeMembers(type); + return resolved.constructSignatures.length > 0; } return false; } - function getIndexTypeOfObjectOrUnionType(type, kind) { - if (type.flags & (48128 | 16384)) { - var resolved = resolveObjectOrUnionTypeMembers(type); + function typeHasCallOrConstructSignatures(type) { + var apparentType = getApparentType(type); + if (apparentType.flags & 130048) { + var resolved = resolveStructuredTypeMembers(type); + return resolved.callSignatures.length > 0 || resolved.constructSignatures.length > 0; + } + return false; + } + function getIndexTypeOfStructuredType(type, kind) { + if (type.flags & 130048) { + var resolved = resolveStructuredTypeMembers(type); return kind === 0 ? resolved.stringIndexType : resolved.numberIndexType; } } function getIndexTypeOfType(type, kind) { - return getIndexTypeOfObjectOrUnionType(getApparentType(type), kind); + return getIndexTypeOfStructuredType(getApparentType(type), kind); } function getTypeParametersFromDeclaration(typeParameterDeclarations) { var result = []; @@ -12722,7 +13277,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 137 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 141 ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -12750,7 +13305,7 @@ var ts; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); - if (declaration.type.kind === 143) { + if (declaration.type.kind === 147) { var typePredicateNode = declaration.type; typePredicate = { parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, @@ -12760,8 +13315,8 @@ var ts; } } else { - if (declaration.kind === 138 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 139); + if (declaration.kind === 142 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 143); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -12779,19 +13334,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { + case 149: + case 150: + case 210: + case 140: + case 139: + case 141: + case 144: case 145: case 146: - case 203: - case 136: - case 135: - case 137: - case 140: - case 141: case 142: - case 138: - case 139: - case 165: - case 166: + case 143: + case 170: + case 171: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -12861,8 +13416,8 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 137 || signature.declaration.kind === 141; - var type = createObjectType(32768 | 131072); + var isConstructor = signature.declaration.kind === 141 || signature.declaration.kind === 145; + var type = createObjectType(65536 | 262144); type.members = emptySymbols; type.properties = emptyArray; type.callSignatures = !isConstructor ? [signature] : emptyArray; @@ -12875,10 +13430,9 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 121 : 123; + var syntaxKind = kind === 1 ? 125 : 127; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { - var len = indexSymbol.declarations.length; for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; var node = decl; @@ -12905,13 +13459,13 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 130).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 134).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 130).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 134).parent); } function getTypeListId(types) { switch (types.length) { @@ -12936,7 +13490,7 @@ var ts; var type = types[_i]; result |= type.flags; } - return result & 1572864; + return result & 3145728; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); @@ -12958,13 +13512,13 @@ var ts; while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { currentNode = currentNode.parent; } - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 130; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 134; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 144 && n.typeName.kind === 65) { + if (n.kind === 148 && n.typeName.kind === 66) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056, undefined, undefined); @@ -13031,7 +13585,7 @@ var ts; function getTypeFromTypeReference(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var typeNameOrExpression = node.kind === 144 ? node.typeName : + var typeNameOrExpression = node.kind === 148 ? node.typeName : ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : undefined; var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056) || unknownSymbol; @@ -13057,9 +13611,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 204: - case 205: - case 207: + case 211: + case 212: + case 214: return declaration; } } @@ -13068,7 +13622,7 @@ var ts; return arity ? emptyGenericType : emptyObjectType; } var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 48128)) { + if (!(type.flags & 80896)) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name); return arity ? emptyGenericType : emptyObjectType; } @@ -13091,6 +13645,15 @@ var ts; if (arity === void 0) { arity = 0; } return getTypeOfGlobalSymbol(getGlobalTypeSymbol(name), arity); } + function tryGetGlobalType(name, arity) { + if (arity === void 0) { arity = 0; } + return getTypeOfGlobalSymbol(getGlobalSymbol(name, 793056, undefined), arity); + } + function getExportedTypeFromNamespace(namespace, name) { + var namespaceSymbol = getGlobalSymbol(namespace, 1536, undefined); + var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793056); + return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); + } function getGlobalESSymbolConstructorSymbol() { return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol")); } @@ -13135,25 +13698,18 @@ var ts; } return links.resolvedType; } - function addTypeToSortedSet(sortedSet, type) { - if (type.flags & 16384) { - addTypesToSortedSet(sortedSet, type.types); + function addTypeToSet(typeSet, type, typeSetKind) { + if (type.flags & typeSetKind) { + addTypesToSet(typeSet, type.types, typeSetKind); } - else { - var i = 0; - var id = type.id; - while (i < sortedSet.length && sortedSet[i].id < id) { - i++; - } - if (i === sortedSet.length || sortedSet[i].id !== id) { - sortedSet.splice(i, 0, type); - } + else if (!ts.contains(typeSet, type)) { + typeSet.push(type); } } - function addTypesToSortedSet(sortedTypes, types) { + function addTypesToSet(typeSet, types, typeSetKind) { for (var _i = 0; _i < types.length; _i++) { var type = types[_i]; - addTypeToSortedSet(sortedTypes, type); + addTypeToSet(typeSet, type, typeSetKind); } } function isSubtypeOfAny(candidate, types) { @@ -13192,30 +13748,34 @@ var ts; } } } + function compareTypeIds(type1, type2) { + return type1.id - type2.id; + } function getUnionType(types, noSubtypeReduction) { if (types.length === 0) { return emptyObjectType; } - var sortedTypes = []; - addTypesToSortedSet(sortedTypes, types); + var typeSet = []; + addTypesToSet(typeSet, types, 16384); + typeSet.sort(compareTypeIds); if (noSubtypeReduction) { - if (containsTypeAny(sortedTypes)) { + if (containsTypeAny(typeSet)) { return anyType; } - removeAllButLast(sortedTypes, undefinedType); - removeAllButLast(sortedTypes, nullType); + removeAllButLast(typeSet, undefinedType); + removeAllButLast(typeSet, nullType); } else { - removeSubtypes(sortedTypes); + removeSubtypes(typeSet); } - if (sortedTypes.length === 1) { - return sortedTypes[0]; + if (typeSet.length === 1) { + return typeSet[0]; } - var id = getTypeListId(sortedTypes); + var id = getTypeListId(typeSet); var type = unionTypes[id]; if (!type) { - type = unionTypes[id] = createObjectType(16384 | getWideningFlagsOfTypes(sortedTypes)); - type.types = sortedTypes; + type = unionTypes[id] = createObjectType(16384 | getWideningFlagsOfTypes(typeSet)); + type.types = typeSet; type.reducedType = noSubtypeReduction ? undefined : type; } return type; @@ -13240,10 +13800,37 @@ var ts; } return links.resolvedType; } + function getIntersectionType(types) { + if (types.length === 0) { + return emptyObjectType; + } + var typeSet = []; + addTypesToSet(typeSet, types, 32768); + if (containsTypeAny(typeSet)) { + return anyType; + } + if (typeSet.length === 1) { + return typeSet[0]; + } + var id = getTypeListId(typeSet); + var type = intersectionTypes[id]; + if (!type) { + type = intersectionTypes[id] = createObjectType(32768 | getWideningFlagsOfTypes(typeSet)); + type.types = typeSet; + } + return type; + } + function getTypeFromIntersectionTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode)); + } + return links.resolvedType; + } function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = createObjectType(32768, node.symbol); + links.resolvedType = createObjectType(65536, node.symbol); } return links.resolvedType; } @@ -13264,42 +13851,44 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 112: + case 114: return anyType; - case 123: + case 127: return stringType; - case 121: + case 125: return numberType; - case 113: + case 117: return booleanType; - case 124: + case 128: return esSymbolType; - case 99: + case 100: return voidType; case 8: return getTypeFromStringLiteral(node); - case 144: - return getTypeFromTypeReference(node); - case 143: - return booleanType; - case 179: + case 148: return getTypeFromTypeReference(node); case 147: - return getTypeFromTypeQueryNode(node); - case 149: - return getTypeFromArrayTypeNode(node); - case 150: - return getTypeFromTupleTypeNode(node); + return booleanType; + case 185: + return getTypeFromTypeReference(node); case 151: + return getTypeFromTypeQueryNode(node); + case 153: + return getTypeFromArrayTypeNode(node); + case 154: + return getTypeFromTupleTypeNode(node); + case 155: return getTypeFromUnionTypeNode(node); - case 152: + case 156: + return getTypeFromIntersectionTypeNode(node); + case 157: return getTypeFromTypeNode(node.type); - case 145: - case 146: - case 148: + case 149: + case 150: + case 152: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 65: - case 128: + case 66: + case 132: var symbol = getSymbolInfo(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -13423,7 +14012,7 @@ var ts; return result; } function instantiateAnonymousType(type, mapper) { - var result = createObjectType(32768 | 65536, type.symbol); + 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); @@ -13441,7 +14030,7 @@ var ts; if (type.flags & 512) { return mapper(type); } - if (type.flags & 32768) { + if (type.flags & 65536) { return type.symbol && type.symbol.flags & (16 | 8192 | 32 | 2048 | 4096) ? instantiateAnonymousType(type, mapper) : type; } @@ -13454,31 +14043,34 @@ var ts; if (type.flags & 16384) { return getUnionType(instantiateList(type.types, mapper, instantiateType), true); } + if (type.flags & 32768) { + return getIntersectionType(instantiateList(type.types, mapper, instantiateType)); + } } return type; } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 136 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 140 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 165: - case 166: + case 170: + case 171: return isContextSensitiveFunctionLikeDeclaration(node); - case 157: + case 162: return ts.forEach(node.properties, isContextSensitive); - case 156: + case 161: return ts.forEach(node.elements, isContextSensitive); - case 173: + case 179: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 172: - return node.operatorToken.kind === 49 && + case 178: + return node.operatorToken.kind === 50 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 227: + case 242: return isContextSensitive(node.initializer); - case 136: - case 135: + case 140: + case 139: return isContextSensitiveFunctionLikeDeclaration(node); - case 164: + case 169: return isContextSensitive(node.expression); } return false; @@ -13487,10 +14079,10 @@ var ts; return !node.typeParameters && node.parameters.length && !ts.forEach(node.parameters, function (p) { return p.type; }); } function getTypeWithoutSignatures(type) { - if (type.flags & 48128) { - var resolved = resolveObjectOrUnionTypeMembers(type); + if (type.flags & 80896) { + var resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length) { - var result = createObjectType(32768, type.symbol); + var result = createObjectType(65536, type.symbol); result.members = resolved.members; result.properties = resolved.properties; result.callSignatures = emptyArray; @@ -13575,37 +14167,9 @@ var ts; } } var saveErrorInfo = errorInfo; - if (source.flags & 16384 || target.flags & 16384) { - if (relation === identityRelation) { - if (source.flags & 16384 && target.flags & 16384) { - if (result = unionTypeRelatedToUnionType(source, target)) { - if (result &= unionTypeRelatedToUnionType(target, source)) { - return result; - } - } - } - else if (source.flags & 16384) { - if (result = unionTypeRelatedToType(source, target, reportErrors)) { - return result; - } - } - else { - if (result = unionTypeRelatedToType(target, source, reportErrors)) { - return result; - } - } - } - else { - if (source.flags & 16384) { - if (result = unionTypeRelatedToType(source, target, reportErrors)) { - return result; - } - } - else { - if (result = typeRelatedToUnionType(source, target, reportErrors)) { - return result; - } - } + if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { + if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + return result; } } else if (source.flags & 512 && target.flags & 512) { @@ -13613,20 +14177,49 @@ var ts; return result; } } - else if (source.flags & 4096 && target.flags & 4096 && source.target === target.target) { - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { - return result; + else if (relation !== identityRelation) { + if (source.flags & 16384) { + if (result = eachTypeRelatedToType(source, target, reportErrors)) { + return result; + } + } + else if (target.flags & 32768) { + if (result = typeRelatedToEachType(source, target, reportErrors)) { + return result; + } + } + else { + if (source.flags & 32768) { + if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384))) { + return result; + } + } + if (target.flags & 16384) { + if (result = typeRelatedToSomeType(source, target, reportErrors)) { + return result; + } + } + } + } + else { + if (source.flags & 16384 && target.flags & 16384 || + source.flags & 32768 && target.flags & 32768) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { + return result; + } + } } } var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; var sourceOrApparentType = relation === identityRelation ? source : getApparentType(source); - if (sourceOrApparentType.flags & 48128 && target.flags & 48128) { + if (sourceOrApparentType.flags & (80896 | 32768) && target.flags & 80896) { if (result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors)) { errorInfo = saveErrorInfo; return result; } } - else if (source.flags & 512 && sourceOrApparentType.flags & 16384) { + else if (source.flags & 512 && sourceOrApparentType.flags & 49152) { errorInfo = saveErrorInfo; if (result = isRelatedTo(sourceOrApparentType, target, reportErrors)) { return result; @@ -13644,12 +14237,12 @@ var ts; } return 0; } - function unionTypeRelatedToUnionType(source, target) { + function eachTypeRelatedToSomeType(source, target) { var result = -1; var sourceTypes = source.types; for (var _i = 0; _i < sourceTypes.length; _i++) { var sourceType = sourceTypes[_i]; - var related = typeRelatedToUnionType(sourceType, target, false); + var related = typeRelatedToSomeType(sourceType, target, false); if (!related) { return 0; } @@ -13657,7 +14250,7 @@ var ts; } return result; } - function typeRelatedToUnionType(source, target, reportErrors) { + function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; for (var i = 0, len = targetTypes.length; i < len; i++) { var related = isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1); @@ -13667,7 +14260,30 @@ var ts; } return 0; } - function unionTypeRelatedToType(source, target, reportErrors) { + function typeRelatedToEachType(source, target, reportErrors) { + var result = -1; + var targetTypes = target.types; + for (var _i = 0; _i < targetTypes.length; _i++) { + var targetType = targetTypes[_i]; + var related = isRelatedTo(source, targetType, reportErrors); + if (!related) { + return 0; + } + result &= related; + } + return result; + } + function someTypeRelatedToType(source, target, reportErrors) { + var sourceTypes = source.types; + for (var i = 0, len = sourceTypes.length; i < len; i++) { + var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); + if (related) { + return related; + } + } + return 0; + } + function eachTypeRelatedToType(source, target, reportErrors) { var result = -1; var sourceTypes = source.types; for (var _i = 0; _i < sourceTypes.length; _i++) { @@ -13791,7 +14407,7 @@ var ts; } var result = -1; var properties = getPropertiesOfObjectType(target); - var requireOptionalProperties = relation === subtypeRelation && !(source.flags & 262144); + var requireOptionalProperties = relation === subtypeRelation && !(source.flags & 524288); for (var _i = 0; _i < properties.length; _i++) { var targetProp = properties[_i]; var sourceProp = getPropertyOfType(source, targetProp.name); @@ -13805,22 +14421,22 @@ var ts; } } else if (!(targetProp.flags & 134217728)) { - var sourceFlags = getDeclarationFlagsFromSymbol(sourceProp); - var targetFlags = getDeclarationFlagsFromSymbol(targetProp); - if (sourceFlags & 32 || targetFlags & 32) { + var sourcePropFlags = getDeclarationFlagsFromSymbol(sourceProp); + var targetPropFlags = getDeclarationFlagsFromSymbol(targetProp); + if (sourcePropFlags & 32 || targetPropFlags & 32) { if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { - if (sourceFlags & 32 && targetFlags & 32) { + if (sourcePropFlags & 32 && targetPropFlags & 32) { reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); } else { - reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourceFlags & 32 ? source : target), typeToString(sourceFlags & 32 ? target : source)); + reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 32 ? source : target), typeToString(sourcePropFlags & 32 ? target : source)); } } return 0; } } - else if (targetFlags & 64) { + else if (targetPropFlags & 64) { var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32; var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(sourceProp.parent) : undefined; var targetClass = getDeclaredTypeOfSymbol(targetProp.parent); @@ -13831,7 +14447,7 @@ var ts; return 0; } } - else if (sourceFlags & 64) { + else if (sourcePropFlags & 64) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } @@ -13857,6 +14473,9 @@ var ts; return result; } function propertiesIdenticalTo(source, target) { + if (!(source.flags & 80896 && target.flags & 80896)) { + return 0; + } var sourceProperties = getPropertiesOfObjectType(source); var targetProperties = getPropertiesOfObjectType(target); if (sourceProperties.length !== targetProperties.length) { @@ -13890,11 +14509,11 @@ var ts; var saveErrorInfo = errorInfo; outer: for (var _i = 0; _i < targetSignatures.length; _i++) { var t = targetSignatures[_i]; - if (!t.hasStringLiterals || target.flags & 131072) { + if (!t.hasStringLiterals || target.flags & 262144) { var localErrors = reportErrors; for (var _a = 0; _a < sourceSignatures.length; _a++) { var s = sourceSignatures[_a]; - if (!s.hasStringLiterals || source.flags & 131072) { + if (!s.hasStringLiterals || source.flags & 262144) { var related = signatureRelatedTo(s, t, localErrors); if (related) { result &= related; @@ -14072,12 +14691,12 @@ var ts; } } function isDeeplyNestedGeneric(type, stack, depth) { - if (type.flags & (4096 | 65536) && depth >= 5) { + if (type.flags & (4096 | 131072) && depth >= 5) { var symbol = type.symbol; var count = 0; for (var i = 0; i < depth; i++) { var t = stack[i]; - if (t.flags & (4096 | 65536) && t.symbol === symbol) { + if (t.flags & (4096 | 131072) && t.symbol === symbol) { count++; if (count >= 5) return true; @@ -14228,11 +14847,11 @@ var ts; return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); } function getWidenedType(type) { - if (type.flags & 1572864) { + if (type.flags & 3145728) { if (type.flags & (32 | 64)) { return anyType; } - if (type.flags & 262144) { + if (type.flags & 524288) { return getWidenedTypeOfObjectLiteral(type); } if (type.flags & 16384) { @@ -14257,11 +14876,11 @@ var ts; if (isArrayType(type)) { return reportWideningErrorsInType(type.typeArguments[0]); } - if (type.flags & 262144) { + if (type.flags & 524288) { var errorReported = false; ts.forEach(getPropertiesOfObjectType(type), function (p) { var t = getTypeOfSymbol(p); - if (t.flags & 524288) { + if (t.flags & 1048576) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); } @@ -14276,22 +14895,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 134: - case 133: + case 138: + case 137: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 131: + case 135: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 203: - case 136: - case 135: - case 138: + case 210: + case 140: case 139: - case 165: - case 166: + case 142: + case 143: + case 170: + case 171: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -14304,7 +14923,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 524288) { + if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 1048576) { if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); } @@ -14391,7 +15010,7 @@ var ts; inferFromTypes(sourceTypes[i], targetTypes[i]); } } - else if (target.flags & 16384) { + else if (target.flags & 49152) { var targetTypes = target.types; var typeParameterCount = 0; var typeParameter; @@ -14405,21 +15024,21 @@ var ts; inferFromTypes(source, t); } } - if (typeParameterCount === 1) { + if (target.flags & 16384 && typeParameterCount === 1) { inferiority++; inferFromTypes(source, typeParameter); inferiority--; } } - else if (source.flags & 16384) { + else if (source.flags & 49152) { var sourceTypes = source.types; for (var _a = 0; _a < sourceTypes.length; _a++) { var sourceType = sourceTypes[_a]; inferFromTypes(sourceType, target); } } - else if (source.flags & 48128 && (target.flags & (4096 | 8192) || - (target.flags & 32768) && target.symbol && target.symbol.flags & (8192 | 2048))) { + else if (source.flags & 80896 && (target.flags & (4096 | 8192) || + (target.flags & 65536) && target.symbol && target.symbol.flags & (8192 | 2048 | 32))) { if (isInProcess(source, target)) { return; } @@ -14531,10 +15150,10 @@ var ts; function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 147: + case 151: return true; - case 65: - case 128: + case 66: + case 132: node = node.parent; continue; default: @@ -14574,12 +15193,12 @@ var ts; } return links.assignmentChecks[symbol.id] = isAssignedIn(node); function isAssignedInBinaryExpression(node) { - if (node.operatorToken.kind >= 53 && node.operatorToken.kind <= 64) { + if (node.operatorToken.kind >= 54 && node.operatorToken.kind <= 65) { var n = node.left; - while (n.kind === 164) { + while (n.kind === 169) { n = n.expression; } - if (n.kind === 65 && getResolvedSymbol(n) === symbol) { + if (n.kind === 66 && getResolvedSymbol(n) === symbol) { return true; } } @@ -14593,46 +15212,55 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 172: + case 178: return isAssignedInBinaryExpression(node); - case 201: - case 155: + case 208: + case 160: return isAssignedInVariableDeclaration(node); - case 153: - case 154: - case 156: - case 157: case 158: case 159: - case 160: case 161: + case 162: case 163: case 164: - case 170: - case 167: + case 165: + case 166: case 168: - case 169: - case 171: - case 173: - case 176: - case 182: - case 183: - case 185: case 186: - case 187: - case 188: + case 169: + case 176: + case 172: + case 175: + case 173: + case 174: + case 177: + case 181: + case 179: + case 182: case 189: case 190: - case 191: + case 192: + case 193: case 194: case 195: case 196: - case 223: - case 224: case 197: case 198: - case 199: - case 226: + case 201: + case 202: + case 203: + case 238: + case 239: + case 204: + case 205: + case 206: + case 241: + case 230: + case 231: + case 235: + case 236: + case 232: + case 237: return ts.forEachChild(node, isAssignedIn); } return false; @@ -14663,40 +15291,40 @@ var ts; function getNarrowedTypeOfSymbol(symbol, node) { var type = getTypeOfSymbol(symbol); if (node && symbol.flags & 3) { - if (isTypeAny(type) || type.flags & (48128 | 16384 | 512)) { + if (isTypeAny(type) || type.flags & (80896 | 16384 | 512)) { loop: while (node.parent) { var child = node; node = node.parent; var narrowedType = type; switch (node.kind) { - case 186: + case 193: if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 173: + case 179: if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 172: + case 178: if (child === node.right) { - if (node.operatorToken.kind === 48) { + if (node.operatorToken.kind === 49) { narrowedType = narrowType(type, node.left, true); } - else if (node.operatorToken.kind === 49) { + else if (node.operatorToken.kind === 50) { narrowedType = narrowType(type, node.left, false); } } break; - case 230: - case 208: - case 203: - case 136: - case 135: - case 138: + case 245: + case 215: + case 210: + case 140: case 139: - case 137: + case 142: + case 143: + case 141: break loop; } if (narrowedType !== type) { @@ -14710,21 +15338,21 @@ var ts; } return type; function narrowTypeByEquality(type, expr, assumeTrue) { - if (expr.left.kind !== 168 || expr.right.kind !== 8) { + if (expr.left.kind !== 173 || expr.right.kind !== 8) { return type; } var left = expr.left; var right = expr.right; - if (left.expression.kind !== 65 || getResolvedSymbol(left.expression) !== symbol) { + if (left.expression.kind !== 66 || getResolvedSymbol(left.expression) !== symbol) { return type; } var typeInfo = primitiveTypeInfo[right.text]; - if (expr.operatorToken.kind === 31) { + if (expr.operatorToken.kind === 32) { assumeTrue = !assumeTrue; } if (assumeTrue) { if (!typeInfo) { - return removeTypesFromUnionType(type, 258 | 132 | 8 | 2097152, true, false); + return removeTypesFromUnionType(type, 258 | 132 | 8 | 4194304, true, false); } if (isTypeSubtypeOf(typeInfo.type, type)) { return typeInfo.type; @@ -14761,7 +15389,7 @@ var ts; } } function narrowTypeByInstanceof(type, expr, assumeTrue) { - if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 65 || getResolvedSymbol(expr.left) !== symbol) { + if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 66 || getResolvedSymbol(expr.left) !== symbol) { return type; } var rightType = checkExpression(expr.right); @@ -14781,7 +15409,7 @@ var ts; if (rightType.flags & 2048) { constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures; } - else if (rightType.flags & 32768) { + else if (rightType.flags & 65536) { constructSignatures = getSignaturesOfType(rightType, 1); } if (constructSignatures && constructSignatures.length) { @@ -14822,27 +15450,27 @@ var ts; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 160: + case 165: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 164: + case 169: return narrowType(type, expr.expression, assumeTrue); - case 172: + case 178: var operator = expr.operatorToken.kind; - if (operator === 30 || operator === 31) { + if (operator === 31 || operator === 32) { return narrowTypeByEquality(type, expr, assumeTrue); } - else if (operator === 48) { + else if (operator === 49) { return narrowTypeByAnd(type, expr, assumeTrue); } - else if (operator === 49) { + else if (operator === 50) { return narrowTypeByOr(type, expr, assumeTrue); } - else if (operator === 87) { + else if (operator === 88) { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 170: - if (expr.operator === 46) { + case 176: + if (expr.operator === 47) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -14852,8 +15480,17 @@ var ts; } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); - if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 166 && languageVersion < 2) { - error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); + if (symbol === argumentsSymbol) { + var container = ts.getContainingFunction(node); + if (container.kind === 171) { + 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); + } + } + if (node.parserContextFlags & 8) { + getNodeLinks(container).flags |= 4096; + getNodeLinks(node).flags |= 2048; + } } if (symbol.flags & 8388608 && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { markAliasSymbolAsReferenced(symbol); @@ -14876,15 +15513,15 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 || (symbol.flags & 2) === 0 || - symbol.valueDeclaration.parent.kind === 226) { + symbol.valueDeclaration.parent.kind === 241) { return; } var container = symbol.valueDeclaration; - while (container.kind !== 202) { + while (container.kind !== 209) { container = container.parent; } container = container.parent; - if (container.kind === 183) { + if (container.kind === 190) { container = container.parent; } var inFunction = isInsideFunction(node.parent, container); @@ -14894,7 +15531,7 @@ var ts; if (inFunction) { grammarErrorOnFirstToken(current, ts.Diagnostics.Loop_contains_block_scoped_variable_0_referenced_by_a_function_in_the_loop_This_is_only_supported_in_ECMAScript_6_or_higher, ts.declarationNameToString(node)); } - getNodeLinks(symbol.valueDeclaration).flags |= 256; + getNodeLinks(symbol.valueDeclaration).flags |= 16384; break; } current = current.parent; @@ -14902,7 +15539,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 134 || container.kind === 137) { + if (container.kind === 138 || container.kind === 141) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -14913,29 +15550,29 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 166) { + if (container.kind === 171) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 208: + case 215: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 207: + case 214: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 137: + case 141: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 134: - case 133: + case 138: + case 137: if (container.flags & 128) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 129: + case 133: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -14950,14 +15587,14 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 131) { + if (n.kind === 135) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 160 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 165 && node.parent.expression === node; var classDeclaration = ts.getContainingClass(node); var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); var baseClassType = classType && getBaseTypes(classType)[0]; @@ -14972,45 +15609,45 @@ var ts; var canUseSuperExpression = false; var needToCaptureLexicalThis; if (isCallExpression) { - canUseSuperExpression = container.kind === 137; + canUseSuperExpression = container.kind === 141; } else { needToCaptureLexicalThis = false; - while (container && container.kind === 166) { + while (container && container.kind === 171) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } if (container && ts.isClassLike(container.parent)) { if (container.flags & 128) { canUseSuperExpression = - container.kind === 136 || - container.kind === 135 || - container.kind === 138 || - container.kind === 139; + container.kind === 140 || + container.kind === 139 || + container.kind === 142 || + container.kind === 143; } else { canUseSuperExpression = - container.kind === 136 || - container.kind === 135 || - container.kind === 138 || + container.kind === 140 || container.kind === 139 || - container.kind === 134 || - container.kind === 133 || - container.kind === 137; + container.kind === 142 || + container.kind === 143 || + container.kind === 138 || + container.kind === 137 || + container.kind === 141; } } } if (canUseSuperExpression) { var returnType; if ((container.flags & 128) || isCallExpression) { - getNodeLinks(node).flags |= 32; + getNodeLinks(node).flags |= 512; returnType = getBaseConstructorTypeOfClass(classType); } else { - getNodeLinks(node).flags |= 16; + getNodeLinks(node).flags |= 256; returnType = baseClassType; } - if (container.kind === 137 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 141 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); returnType = unknownType; } @@ -15020,7 +15657,7 @@ var ts; return returnType; } } - if (container && container.kind === 129) { + if (container && container.kind === 133) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { @@ -15058,7 +15695,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 131) { + if (declaration.kind === 135) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -15089,10 +15726,19 @@ var ts; } return undefined; } + function isInParameterInitializerBeforeContainingFunction(node) { + while (node.parent && !ts.isFunctionLike(node.parent)) { + if (node.parent.kind === 135 && node.parent.initializer === node) { + return true; + } + node = node.parent; + } + return false; + } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 137 || - functionDecl.kind === 138 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 139))) { + functionDecl.kind === 141 || + functionDecl.kind === 142 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 143))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -15111,7 +15757,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 162) { + if (template.parent.kind === 167) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -15119,12 +15765,12 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 53 && operator <= 64) { + if (operator >= 54 && operator <= 65) { if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); } } - else if (operator === 49) { + else if (operator === 50) { var type = getContextualType(binaryExpression); if (!type && node === binaryExpression.right) { type = checkExpression(binaryExpression.left); @@ -15159,18 +15805,18 @@ var ts; } function getTypeOfPropertyOfContextualType(type, name) { return applyToContextualType(type, function (t) { - var prop = getPropertyOfObjectType(t, name); + var prop = t.flags & 130048 ? getPropertyOfType(t, name) : undefined; return prop ? getTypeOfSymbol(prop) : undefined; }); } function getIndexTypeOfContextualType(type, kind) { - return applyToContextualType(type, function (t) { return getIndexTypeOfObjectOrUnionType(t, kind); }); + return applyToContextualType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }); } function contextualTypeIsTupleLikeType(type) { return !!(type.flags & 16384 ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); } function contextualTypeHasIndexSignature(type, kind) { - return !!(type.flags & 16384 ? ts.forEach(type.types, function (t) { return getIndexTypeOfObjectOrUnionType(t, kind); }) : getIndexTypeOfObjectOrUnionType(type, kind)); + return !!(type.flags & 16384 ? ts.forEach(type.types, function (t) { return getIndexTypeOfStructuredType(t, kind); }) : getIndexTypeOfStructuredType(type, kind)); } function getContextualTypeForObjectLiteralMethod(node) { ts.Debug.assert(ts.isObjectLiteralMethod(node)); @@ -15210,7 +15856,27 @@ var ts; var conditional = node.parent; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } + function getContextualTypeForJsxExpression(expr) { + if (expr.parent.kind === 235) { + var attrib = expr.parent; + var attrsType = getJsxElementAttributesType(attrib.parent); + if (!attrsType || isTypeAny(attrsType)) { + return undefined; + } + else { + return getTypeOfPropertyOfType(attrsType, attrib.name.text); + } + } + if (expr.kind === 236) { + return getJsxElementAttributesType(expr.parent); + } + return undefined; + } function getContextualType(node) { + var type = getContextualTypeWorker(node); + return type && getApparentType(type); + } + function getContextualTypeWorker(node) { if (isInsideWithStatementBody(node)) { return undefined; } @@ -15219,40 +15885,44 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 201: - case 131: - case 134: - case 133: - case 155: - return getContextualTypeForInitializerExpression(node); - case 166: - case 194: - return getContextualTypeForReturnExpression(node); - case 175: - return getContextualTypeForYieldOperand(parent); + case 208: + case 135: + case 138: + case 137: case 160: - case 161: + return getContextualTypeForInitializerExpression(node); + case 171: + case 201: + return getContextualTypeForReturnExpression(node); + case 181: + return getContextualTypeForYieldOperand(parent); + case 165: + case 166: return getContextualTypeForArgument(parent, node); - case 163: + case 168: + case 186: return getTypeFromTypeNode(parent.type); - case 172: + case 178: return getContextualTypeForBinaryOperand(node); - case 227: + case 242: return getContextualTypeForObjectLiteralElement(parent); - case 156: + case 161: return getContextualTypeForElementExpression(node); - case 173: + case 179: return getContextualTypeForConditionalOperand(node); - case 180: - ts.Debug.assert(parent.parent.kind === 174); + case 187: + ts.Debug.assert(parent.parent.kind === 180); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 164: + case 169: return getContextualType(parent); + case 237: + case 236: + return getContextualTypeForJsxExpression(parent); } return undefined; } function getNonGenericSignature(type) { - var signatures = getSignaturesOfObjectOrUnionType(type, 0); + var signatures = getSignaturesOfStructuredType(type, 0); if (signatures.length === 1) { var signature = signatures[0]; if (!signature.typeParameters) { @@ -15261,7 +15931,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 165 || node.kind === 166; + return node.kind === 170 || node.kind === 171; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -15269,7 +15939,7 @@ var ts; : undefined; } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 136 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 140 || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -15284,7 +15954,7 @@ var ts; for (var _i = 0; _i < types.length; _i++) { var current = types[_i]; if (signatureList && - getSignaturesOfObjectOrUnionType(current, 0).length > 1) { + getSignaturesOfStructuredType(current, 0).length > 1) { return undefined; } var signature = getNonGenericSignature(current); @@ -15313,13 +15983,13 @@ var ts; } function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 172 && parent.operatorToken.kind === 53 && parent.left === node) { + if (parent.kind === 178 && parent.operatorToken.kind === 54 && parent.left === node) { return true; } - if (parent.kind === 227) { + if (parent.kind === 242) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 156) { + if (parent.kind === 161) { return isAssignmentTarget(parent); } return false; @@ -15338,7 +16008,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 176) { + if (inDestructuringPattern && e.kind === 182) { var restArrayType = checkExpression(e.expression, contextualMapper); var restElementType = getIndexTypeOfType(restArrayType, 1) || (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); @@ -15350,7 +16020,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 176; + hasSpreadElement = hasSpreadElement || e.kind === 182; } if (!hasSpreadElement) { var contextualType = getContextualType(node); @@ -15361,7 +16031,7 @@ var ts; return createArrayType(getUnionType(elementTypes)); } function isNumericName(name) { - return name.kind === 129 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 133 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 132); @@ -15376,7 +16046,7 @@ var ts; var links = getNodeLinks(node.expression); if (!links.resolvedType) { links.resolvedType = checkExpression(node.expression); - if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 | 258 | 2097152)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 | 258 | 4194304)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } else { @@ -15394,18 +16064,18 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 227 || - memberDecl.kind === 228 || + if (memberDecl.kind === 242 || + memberDecl.kind === 243 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 227) { + if (memberDecl.kind === 242) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 136) { + else if (memberDecl.kind === 140) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 228); + ts.Debug.assert(memberDecl.kind === 243); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -15420,7 +16090,7 @@ var ts; member = prop; } else { - ts.Debug.assert(memberDecl.kind === 138 || memberDecl.kind === 139); + ts.Debug.assert(memberDecl.kind === 142 || memberDecl.kind === 143); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -15431,7 +16101,7 @@ var ts; var stringIndexType = getIndexType(0); var numberIndexType = getIndexType(1); var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); - result.flags |= 262144 | 1048576 | (typeFlags & 524288); + result.flags |= 524288 | 2097152 | (typeFlags & 1048576); return result; function getIndexType(kind) { if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { @@ -15452,39 +16122,367 @@ var ts; return undefined; } } + function checkJsxSelfClosingElement(node) { + checkJsxOpeningLikeElement(node); + return jsxElementType || anyType; + } + function tagNamesAreEquivalent(lhs, rhs) { + if (lhs.kind !== rhs.kind) { + return false; + } + if (lhs.kind === 66) { + return lhs.text === rhs.text; + } + return lhs.right.text === rhs.right.text && + tagNamesAreEquivalent(lhs.left, rhs.left); + } + function checkJsxElement(node) { + if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) { + error(node.closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNode(node.openingElement.tagName)); + } + checkJsxOpeningLikeElement(node.openingElement); + for (var _i = 0, _a = node.children; _i < _a.length; _i++) { + var child = _a[_i]; + switch (child.kind) { + case 237: + checkJsxExpression(child); + break; + case 230: + checkJsxElement(child); + break; + case 231: + checkJsxSelfClosingElement(child); + break; + default: + ts.Debug.assert(child.kind === 233); + } + } + return jsxElementType || anyType; + } + function isUnhyphenatedJsxName(name) { + return name.indexOf("-") < 0; + } + function isJsxIntrinsicIdentifier(tagName) { + if (tagName.kind === 132) { + return false; + } + else { + return ts.isIntrinsicJsxName(tagName.text); + } + } + function checkJsxAttribute(node, elementAttributesType, nameTable) { + var correspondingPropType = undefined; + if (elementAttributesType === emptyObjectType && isUnhyphenatedJsxName(node.name.text)) { + error(node.parent, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, getJsxElementPropertiesName()); + } + else if (elementAttributesType && !isTypeAny(elementAttributesType)) { + var correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); + correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); + if (!correspondingPropType && isUnhyphenatedJsxName(node.name.text)) { + error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); + return unknownType; + } + } + var exprType; + if (node.initializer) { + exprType = checkExpression(node.initializer); + } + else { + exprType = booleanType; + } + if (correspondingPropType) { + checkTypeAssignableTo(exprType, correspondingPropType, node); + } + nameTable[node.name.text] = true; + return exprType; + } + function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { + var type = checkExpression(node.expression); + var props = getPropertiesOfType(type); + for (var _i = 0; _i < props.length; _i++) { + var prop = props[_i]; + if (!nameTable[prop.name]) { + var targetPropSym = getPropertyOfType(elementAttributesType, prop.name); + if (targetPropSym) { + var msg = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property, prop.name); + checkTypeAssignableTo(getTypeOfSymbol(prop), getTypeOfSymbol(targetPropSym), node, undefined, msg); + } + nameTable[prop.name] = true; + } + } + return type; + } + function getJsxIntrinsicElementsType() { + if (!jsxIntrinsicElementsType) { + jsxIntrinsicElementsType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.IntrinsicElements) || unknownType; + } + return jsxIntrinsicElementsType; + } + function getJsxElementTagSymbol(node) { + var flags = 8; + var links = getNodeLinks(node); + if (!links.resolvedSymbol) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + links.resolvedSymbol = lookupIntrinsicTag(node); + } + else { + links.resolvedSymbol = lookupClassTag(node); + } + } + return links.resolvedSymbol; + function lookupIntrinsicTag(node) { + var intrinsicElementsType = getJsxIntrinsicElementsType(); + if (intrinsicElementsType !== unknownType) { + var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.text); + if (intrinsicProp) { + links.jsxFlags |= 1; + return intrinsicProp; + } + var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0); + if (indexSignatureType) { + links.jsxFlags |= 2; + return intrinsicElementsType.symbol; + } + error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, 'JSX.' + JsxNames.IntrinsicElements); + return unknownSymbol; + } + else { + if (compilerOptions.noImplicitAny) { + error(node, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, JsxNames.IntrinsicElements); + } + } + } + function lookupClassTag(node) { + var valueSymbol; + if (node.tagName.kind === 66) { + var tag = node.tagName; + var sym = getResolvedSymbol(tag); + valueSymbol = sym.exportSymbol || sym; + } + else { + valueSymbol = checkQualifiedName(node.tagName).symbol; + } + if (valueSymbol && valueSymbol !== unknownSymbol) { + links.jsxFlags |= 4; + getSymbolLinks(valueSymbol).referenced = true; + } + return valueSymbol || unknownSymbol; + } + } + function getJsxElementInstanceType(node) { + if (!(getNodeLinks(node).jsxFlags & 4)) { + return undefined; + } + var classSymbol = getJsxElementTagSymbol(node); + if (classSymbol === unknownSymbol) { + return anyType; + } + var valueType = getTypeOfSymbol(classSymbol); + if (isTypeAny(valueType)) { + return anyType; + } + var signatures = getSignaturesOfType(valueType, 1); + if (signatures.length === 0) { + signatures = getSignaturesOfType(valueType, 0); + if (signatures.length === 0) { + error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); + return undefined; + } + } + var returnType = getUnionType(signatures.map(function (s) { return getReturnTypeOfSignature(s); })); + if (!isTypeAny(returnType) && !(returnType.flags & 80896)) { + error(node.tagName, ts.Diagnostics.The_return_type_of_a_JSX_element_constructor_must_return_an_object_type); + return undefined; + } + var elemClassType = getJsxGlobalElementClassType(); + if (elemClassType) { + checkTypeRelatedTo(returnType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + } + return returnType; + } + function getJsxElementPropertiesName() { + var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1536, undefined); + var attribsPropTypeSym = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.ElementAttributesPropertyNameContainer, 793056); + var attribPropType = attribsPropTypeSym && getDeclaredTypeOfSymbol(attribsPropTypeSym); + var attribProperties = attribPropType && getPropertiesOfType(attribPropType); + if (attribProperties) { + if (attribProperties.length === 0) { + return ""; + } + else if (attribProperties.length === 1) { + return attribProperties[0].name; + } + else { + error(attribsPropTypeSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, JsxNames.ElementAttributesPropertyNameContainer); + return undefined; + } + } + else { + return undefined; + } + } + function getJsxElementAttributesType(node) { + var links = getNodeLinks(node); + if (!links.resolvedJsxType) { + var sym = getJsxElementTagSymbol(node); + if (links.jsxFlags & 4) { + var elemInstanceType = getJsxElementInstanceType(node); + if (isTypeAny(elemInstanceType)) { + return links.resolvedJsxType = anyType; + } + var propsName = getJsxElementPropertiesName(); + if (propsName === undefined) { + return links.resolvedJsxType = anyType; + } + else if (propsName === "") { + return links.resolvedJsxType = elemInstanceType; + } + else { + var attributesType = getTypeOfPropertyOfType(elemInstanceType, propsName); + if (!attributesType) { + return links.resolvedJsxType = emptyObjectType; + } + else if (isTypeAny(attributesType) || (attributesType === unknownType)) { + return links.resolvedJsxType = attributesType; + } + else if (!(attributesType.flags & 80896)) { + error(node.tagName, ts.Diagnostics.JSX_element_attributes_type_0_must_be_an_object_type, typeToString(attributesType)); + return links.resolvedJsxType = anyType; + } + else { + return links.resolvedJsxType = attributesType; + } + } + } + else if (links.jsxFlags & 1) { + return links.resolvedJsxType = getTypeOfSymbol(sym); + } + else if (links.jsxFlags & 2) { + return links.resolvedJsxType = getIndexTypeOfSymbol(sym, 0); + } + else { + return links.resolvedJsxType = anyType; + } + } + return links.resolvedJsxType; + } + function getJsxAttributePropertySymbol(attrib) { + var attributesType = getJsxElementAttributesType(attrib.parent); + var prop = getPropertyOfType(attributesType, attrib.name.text); + return prop || unknownSymbol; + } + var jsxElementClassType = undefined; + function getJsxGlobalElementClassType() { + if (!jsxElementClassType) { + jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); + } + return jsxElementClassType; + } + function getJsxIntrinsicTagNames() { + var intrinsics = getJsxIntrinsicElementsType(); + return intrinsics ? getPropertiesOfType(intrinsics) : emptyArray; + } + function checkJsxPreconditions(errorNode) { + if ((compilerOptions.jsx || 0) === 0) { + error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided); + } + if (jsxElementType === undefined) { + if (compilerOptions.noImplicitAny) { + error(errorNode, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist); + } + } + } + function checkJsxOpeningLikeElement(node) { + checkGrammarJsxElement(node); + checkJsxPreconditions(node); + if (compilerOptions.jsx === 2) { + var reactSym = resolveName(node.tagName, 'React', 107455, ts.Diagnostics.Cannot_find_name_0, 'React'); + if (reactSym) { + getSymbolLinks(reactSym).referenced = true; + } + } + var targetAttributesType = getJsxElementAttributesType(node); + var nameTable = {}; + var sawSpreadedAny = false; + for (var i = node.attributes.length - 1; i >= 0; i--) { + if (node.attributes[i].kind === 235) { + checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); + } + else { + ts.Debug.assert(node.attributes[i].kind === 236); + var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); + if (isTypeAny(spreadType)) { + sawSpreadedAny = true; + } + } + } + if (targetAttributesType && !sawSpreadedAny) { + var targetProperties = getPropertiesOfType(targetAttributesType); + for (var i = 0; i < targetProperties.length; i++) { + if (!(targetProperties[i].flags & 536870912) && + nameTable[targetProperties[i].name] === undefined) { + error(node, ts.Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType)); + } + } + } + } + function checkJsxExpression(node) { + if (node.expression) { + return checkExpression(node.expression); + } + else { + return unknownType; + } + } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 134; + return s.valueDeclaration ? s.valueDeclaration.kind : 138; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 ? 16 | 128 : 0; } function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); + var declaringClass = getDeclaredTypeOfSymbol(prop.parent); + if (left.kind === 92) { + var errorNode = node.kind === 163 ? + node.name : + node.right; + if (getDeclarationKindFromSymbol(prop) !== 140) { + error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + return false; + } + if (flags & 256) { + error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(declaringClass)); + return false; + } + } if (!(flags & (32 | 64))) { - return; + return true; } var enclosingClassDeclaration = ts.getContainingClass(node); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; - var declaringClass = getDeclaredTypeOfSymbol(prop.parent); if (flags & 32) { if (declaringClass !== enclosingClass) { error(node, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); + return false; } - return; + return true; } - if (left.kind === 91) { - return; + if (left.kind === 92) { + return true; } if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass)); - return; + return false; } if (flags & 128) { - return; + return true; } 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; } + return true; } function checkPropertyAccessExpression(node) { return checkPropertyAccessExpressionOrQualifiedName(node, node.expression, node.name); @@ -15510,31 +16508,19 @@ var ts; } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32) { - if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 136) { - error(right, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); - } - else { - checkClassPropertyAccess(node, left, type, prop); - } + checkClassPropertyAccess(node, left, type, prop); } return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 158 + var left = node.kind === 163 ? node.expression : node.left; var type = checkExpression(left); if (type !== unknownType && !isTypeAny(type)) { var prop = getPropertyOfType(getWidenedType(type), propertyName); if (prop && prop.parent && prop.parent.flags & 32) { - if (left.kind === 91 && getDeclarationKindFromSymbol(prop) !== 136) { - return false; - } - else { - var modificationCount = diagnostics.getModificationCount(); - checkClassPropertyAccess(node, left, type, prop); - return diagnostics.getModificationCount() === modificationCount; - } + return checkClassPropertyAccess(node, left, type, prop); } } return true; @@ -15542,7 +16528,7 @@ var ts; function checkIndexedAccess(node) { if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 161 && node.parent.expression === node) { + if (node.parent.kind === 166 && 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); @@ -15565,20 +16551,20 @@ var ts; return unknownType; } if (node.argumentExpression) { - var name_10 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); - if (name_10 !== undefined) { - var prop = getPropertyOfType(objectType, name_10); + var name_12 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); + if (name_12 !== undefined) { + var prop = getPropertyOfType(objectType, name_12); if (prop) { getNodeLinks(node).resolvedSymbol = prop; return getTypeOfSymbol(prop); } else if (isConstEnum) { - error(node.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_const_enum_1, name_10, symbolToString(objectType.symbol)); + error(node.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_const_enum_1, name_12, symbolToString(objectType.symbol)); return unknownType; } } } - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 | 132 | 2097152)) { + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 | 132 | 4194304)) { if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132)) { var numberIndexType = getIndexTypeOfType(objectType, 1); if (numberIndexType) { @@ -15614,7 +16600,7 @@ var ts; if (!ts.isWellKnownSymbolSyntactically(expression)) { return false; } - if ((expressionType.flags & 2097152) === 0) { + if ((expressionType.flags & 4194304) === 0) { if (reportError) { error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); } @@ -15638,10 +16624,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 162) { + if (node.kind === 167) { checkExpression(node.template); } - else if (node.kind !== 132) { + else if (node.kind !== 136) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -15692,7 +16678,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 176) { + if (arg && arg.kind === 182) { return i; } } @@ -15704,11 +16690,11 @@ var ts; var callIsIncomplete; var isDecorator; var spreadArgIndex = -1; - if (node.kind === 162) { + if (node.kind === 167) { var tagExpression = node; adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 174) { + if (tagExpression.template.kind === 180) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -15720,7 +16706,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 132) { + else if (node.kind === 136) { isDecorator = true; typeArguments = undefined; adjustedArgCount = getEffectiveArgumentCount(node, undefined, signature); @@ -15728,7 +16714,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 161); + ts.Debug.assert(callExpression.kind === 166); return signature.minArgumentCount === 0; } adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length; @@ -15751,8 +16737,8 @@ var ts; return callIsIncomplete || hasEnoughArguments; } function getSingleCallSignature(type) { - if (type.flags & 48128) { - var resolved = resolveObjectOrUnionTypeMembers(type); + if (type.flags & 80896) { + var resolved = resolveStructuredTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && resolved.properties.length === 0 && !resolved.stringIndexType && !resolved.numberIndexType) { return resolved.callSignatures[0]; @@ -15781,7 +16767,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 !== 178) { + if (arg === undefined || arg.kind !== 184) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { @@ -15828,7 +16814,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 !== 178) { + if (arg === undefined || arg.kind !== 184) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); if (argType === undefined) { @@ -15847,16 +16833,16 @@ var ts; } function getEffectiveCallArguments(node) { var args; - if (node.kind === 162) { + if (node.kind === 167) { var template = node.template; args = [undefined]; - if (template.kind === 174) { + if (template.kind === 180) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 132) { + else if (node.kind === 136) { return undefined; } else { @@ -15865,18 +16851,18 @@ var ts; return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 132) { + if (node.kind === 136) { switch (node.parent.kind) { - case 204: - case 177: + case 211: + case 183: return 1; - case 134: - return 2; - case 136: case 138: - case 139: + return 2; + case 140: + case 142: + case 143: return signature.parameters.length >= 3 ? 3 : 2; - case 131: + case 135: return 3; } } @@ -15886,20 +16872,20 @@ var ts; } function getEffectiveDecoratorFirstArgumentType(node) { switch (node.kind) { - case 204: - case 177: + case 211: + case 183: var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); - case 131: + case 135: node = node.parent; - if (node.kind === 137) { + if (node.kind === 141) { var classSymbol_1 = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol_1); } - case 134: - case 136: case 138: - case 139: + case 140: + case 142: + case 143: return getParentTypeOfClassElement(node); default: ts.Debug.fail("Unsupported decorator target."); @@ -15908,27 +16894,27 @@ var ts; } function getEffectiveDecoratorSecondArgumentType(node) { switch (node.kind) { - case 204: + case 211: ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; - case 131: + case 135: node = node.parent; - if (node.kind === 137) { + if (node.kind === 141) { return anyType; } - case 134: - case 136: case 138: - case 139: + case 140: + case 142: + case 143: var element = node; switch (element.name.kind) { - case 65: + case 66: case 7: case 8: return getStringLiteralType(element.name); - case 129: + case 133: var nameType = checkComputedPropertyName(element.name); - if (allConstituentTypesHaveKind(nameType, 2097152)) { + if (allConstituentTypesHaveKind(nameType, 4194304)) { return nameType; } else { @@ -15945,17 +16931,17 @@ var ts; } function getEffectiveDecoratorThirdArgumentType(node) { switch (node.kind) { - case 204: + case 211: ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; - case 131: + case 135: return numberType; - case 134: + case 138: ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; - case 136: - case 138: - case 139: + case 140: + case 142: + case 143: var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); default: @@ -15977,26 +16963,26 @@ var ts; return unknownType; } function getEffectiveArgumentType(node, argIndex, arg) { - if (node.kind === 132) { + if (node.kind === 136) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 162) { + else if (argIndex === 0 && node.kind === 167) { return globalTemplateStringsArrayType; } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 132 || - (argIndex === 0 && node.kind === 162)) { + if (node.kind === 136 || + (argIndex === 0 && node.kind === 167)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 132) { + if (node.kind === 136) { return node.expression; } - else if (argIndex === 0 && node.kind === 162) { + else if (argIndex === 0 && node.kind === 167) { return node.template; } else { @@ -16004,12 +16990,12 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 162; - var isDecorator = node.kind === 132; + var isTaggedTemplate = node.kind === 167; + var isDecorator = node.kind === 136; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; - if (node.expression.kind !== 91) { + if (node.expression.kind !== 92) { ts.forEach(typeArguments, checkSourceElement); } } @@ -16144,7 +17130,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 91) { + if (node.expression.kind === 92) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); @@ -16189,6 +17175,11 @@ var ts; if (expressionType === unknownType) { return resolveErrorCall(node); } + var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 211); + 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); + } if (isTypeAny(expressionType)) { if (node.typeArguments) { error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); @@ -16228,16 +17219,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 204: - case 177: + case 211: + case 183: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 131: + case 135: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 134: - return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 136: case 138: - case 139: + return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; + case 140: + case 142: + case 143: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -16265,16 +17256,16 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 160) { + if (node.kind === 165) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 161) { + else if (node.kind === 166) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 162) { + else if (node.kind === 167) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } - else if (node.kind === 132) { + else if (node.kind === 136) { links.resolvedSignature = resolveDecorator(node, candidatesOutArray); } else { @@ -16286,15 +17277,15 @@ var ts; function checkCallExpression(node) { checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 91) { + if (node.expression.kind === 92) { return voidType; } - if (node.kind === 161) { + if (node.kind === 166) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 137 && declaration.kind !== 141 && - declaration.kind !== 146) { + declaration.kind !== 145 && + declaration.kind !== 150) { if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } @@ -16306,7 +17297,7 @@ var ts; function checkTaggedTemplateExpression(node) { return getReturnTypeOfSignature(getResolvedSignature(node)); } - function checkTypeAssertion(node) { + function checkAssertion(node) { var exprType = checkExpression(node.expression); var targetType = getTypeFromTypeNode(node.type); if (produceDiagnostics && targetType !== unknownType) { @@ -16335,14 +17326,26 @@ var ts; links.type = instantiateType(getTypeOfSymbol(ts.lastOrUndefined(context.parameters)), mapper); } } + function createPromiseType(promisedType) { + var globalPromiseType = getGlobalPromiseType(); + if (globalPromiseType !== emptyObjectType) { + promisedType = getAwaitedType(promisedType); + return createTypeReference(globalPromiseType, [promisedType]); + } + return emptyObjectType; + } function getReturnTypeFromBody(func, contextualMapper) { var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); if (!func.body) { return unknownType; } + var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 182) { + if (func.body.kind !== 189) { 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); + } } else { var types; @@ -16358,9 +17361,19 @@ var ts; } } else { - types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper); + types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper, isAsync); if (types.length === 0) { - return voidType; + if (isAsync) { + var promiseType = createPromiseType(voidType); + if (promiseType === emptyObjectType) { + error(func, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return unknownType; + } + return promiseType; + } + else { + return voidType; + } } } type = contextualSignature ? getUnionType(types) : getCommonSupertype(types); @@ -16381,7 +17394,18 @@ var ts; if (!contextualSignature) { reportErrorsFromWidening(func, type); } - return getWidenedType(type); + var widenedType = getWidenedType(type); + if (isAsync) { + var promiseType = createPromiseType(widenedType); + if (promiseType === emptyObjectType) { + error(func, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return unknownType; + } + return promiseType; + } + else { + return widenedType; + } } function checkAndAggregateYieldOperandTypes(body, contextualMapper) { var aggregatedTypes = []; @@ -16399,12 +17423,15 @@ var ts; }); return aggregatedTypes; } - function checkAndAggregateReturnExpressionTypes(body, contextualMapper) { + function checkAndAggregateReturnExpressionTypes(body, contextualMapper, isAsync) { var aggregatedTypes = []; ts.forEachReturnStatement(body, function (returnStatement) { var expr = returnStatement.expression; if (expr) { var type = checkExpressionCached(expr, contextualMapper); + if (isAsync) { + type = checkAwaitedType(type, body.parent, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + } if (!ts.contains(aggregatedTypes, type)) { aggregatedTypes.push(type); } @@ -16418,7 +17445,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 198); + return (body.statements.length === 1) && (body.statements[0].kind === 205); } function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { if (!produceDiagnostics) { @@ -16427,7 +17454,7 @@ var ts; if (returnType === voidType || isTypeAny(returnType)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 182) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 189) { return; } var bodyBlock = func.body; @@ -16440,20 +17467,24 @@ 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 !== 136 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 140 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 165) { + if (!hasGrammarError && node.kind === 170) { checkGrammarForGenerator(node); } if (contextualMapper === identityMapper && isContextSensitive(node)) { return anyFunctionType; } + var isAsync = ts.isAsyncFunctionLike(node); + if (isAsync) { + emitAwaiter = true; + } var links = getNodeLinks(node); var type = getTypeOfSymbol(node.symbol); - if (!(links.flags & 64)) { + if (!(links.flags & 1024)) { var contextualSignature = getContextualSignature(node); - if (!(links.flags & 64)) { - links.flags |= 64; + if (!(links.flags & 1024)) { + links.flags |= 1024; if (contextualSignature) { var signature = getSignaturesOfType(type, 0)[0]; if (isContextSensitive(node)) { @@ -16469,28 +17500,43 @@ var ts; checkSignatureDeclaration(node); } } - if (produceDiagnostics && node.kind !== 136 && node.kind !== 135) { + if (produceDiagnostics && node.kind !== 140 && node.kind !== 139) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 136 || ts.isObjectLiteralMethod(node)); - if (node.type && !node.asteriskToken) { - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); + ts.Debug.assert(node.kind !== 140 || ts.isObjectLiteralMethod(node)); + var isAsync = ts.isAsyncFunctionLike(node); + if (isAsync) { + emitAwaiter = true; + } + var returnType = node.type && getTypeFromTypeNode(node.type); + var promisedType; + if (returnType && isAsync) { + promisedType = checkAsyncFunctionReturnType(node); + } + if (returnType && !node.asteriskToken) { + checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); } if (node.body) { if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 182) { + if (node.body.kind === 189) { checkSourceElement(node.body); } else { var exprType = checkExpression(node.body); - if (node.type) { - checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), node.body, undefined); + if (returnType) { + if (isAsync) { + var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member); + checkTypeAssignableTo(awaitedType, promisedType, node.body); + } + else { + checkTypeAssignableTo(exprType, returnType, node.body); + } } checkFunctionAndClassExpressionBodies(node.body); } @@ -16510,17 +17556,17 @@ var ts; } function isReferenceOrErrorExpression(n) { switch (n.kind) { - case 65: { + case 66: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3) !== 0; } - case 158: { + case 163: { var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || (symbol.flags & ~8) !== 0; } - case 159: - return true; case 164: + return true; + case 169: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -16528,22 +17574,22 @@ var ts; } function isConstVariableReference(n) { switch (n.kind) { - case 65: - case 158: { + case 66: + case 163: { var symbol = findSymbol(n); - return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 8192) !== 0; + return symbol && (symbol.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768) !== 0; } - case 159: { + case 164: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); if (symbol && index && index.kind === 8) { - var name_11 = index.text; - var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_11); - return prop && (prop.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 8192) !== 0; + var name_13 = index.text; + var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_13); + return prop && (prop.flags & 3) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 32768) !== 0; } return false; } - case 164: + case 169: return isConstVariableReference(n.expression); default: return false; @@ -16564,27 +17610,39 @@ var ts; return booleanType; } function checkTypeOfExpression(node) { - var operandType = checkExpression(node.expression); + checkExpression(node.expression); return stringType; } function checkVoidExpression(node) { - var operandType = checkExpression(node.expression); + checkExpression(node.expression); return undefinedType; } + function checkAwaitExpression(node) { + if (produceDiagnostics) { + if (!(node.parserContextFlags & 8)) { + grammarErrorOnFirstToken(node, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); + } + if (isInParameterInitializerBeforeContainingFunction(node)) { + error(node, ts.Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer); + } + } + var operandType = checkExpression(node.expression); + return checkAwaitedType(operandType, node); + } function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); switch (node.operator) { - case 33: case 34: - case 47: - if (someConstituentTypeHasKind(operandType, 2097152)) { + case 35: + case 48: + if (someConstituentTypeHasKind(operandType, 4194304)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 46: + case 47: return booleanType; - case 38: case 39: + case 40: 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); @@ -16605,7 +17663,7 @@ var ts; if (type.flags & kind) { return true; } - if (type.flags & 16384) { + if (type.flags & 49152) { var types = type.types; for (var _i = 0; _i < types.length; _i++) { var current = types[_i]; @@ -16621,7 +17679,7 @@ var ts; if (type.flags & kind) { return true; } - if (type.flags & 16384) { + if (type.flags & 49152) { var types = type.types; for (var _i = 0; _i < types.length; _i++) { var current = types[_i]; @@ -16634,13 +17692,13 @@ var ts; return false; } function isConstEnumObjectType(type) { - return type.flags & (48128 | 32768) && type.symbol && isConstEnumSymbol(type.symbol); + return type.flags & (80896 | 65536) && type.symbol && isConstEnumSymbol(type.symbol); } function isConstEnumSymbol(symbol) { return (symbol.flags & 128) !== 0; } function checkInstanceOfExpression(node, leftType, rightType) { - if (allConstituentTypesHaveKind(leftType, 2097662)) { + if (allConstituentTypesHaveKind(leftType, 4194814)) { 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); } if (!(isTypeAny(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) { @@ -16649,10 +17707,10 @@ var ts; return booleanType; } function checkInExpression(node, leftType, rightType) { - if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 | 132 | 2097152)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 | 132 | 4194304)) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 48128 | 512)) { + 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); } return booleanType; @@ -16661,18 +17719,18 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 227 || p.kind === 228) { - var name_12 = p.name; + if (p.kind === 242 || p.kind === 243) { + var name_14 = p.name; var type = isTypeAny(sourceType) ? sourceType - : getTypeOfPropertyOfType(sourceType, name_12.text) || - isNumericLiteralName(name_12.text) && getIndexTypeOfType(sourceType, 1) || + : getTypeOfPropertyOfType(sourceType, name_14.text) || + isNumericLiteralName(name_14.text) && getIndexTypeOfType(sourceType, 1) || getIndexTypeOfType(sourceType, 0); if (type) { - checkDestructuringAssignment(p.initializer || name_12, type); + checkDestructuringAssignment(p.initializer || name_14, type); } else { - error(name_12, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_12)); + error(name_14, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_14)); } } else { @@ -16686,8 +17744,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 178) { - if (e.kind !== 176) { + if (e.kind !== 184) { + if (e.kind !== 182) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -16712,7 +17770,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 172 && restExpression.operatorToken.kind === 53) { + if (restExpression.kind === 178 && restExpression.operatorToken.kind === 54) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -16725,14 +17783,14 @@ var ts; return sourceType; } function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 172 && target.operatorToken.kind === 53) { + if (target.kind === 178 && target.operatorToken.kind === 54) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 157) { + if (target.kind === 162) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 156) { + if (target.kind === 161) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -16746,32 +17804,32 @@ var ts; } function checkBinaryExpression(node, contextualMapper) { var operator = node.operatorToken.kind; - if (operator === 53 && (node.left.kind === 157 || node.left.kind === 156)) { + if (operator === 54 && (node.left.kind === 162 || node.left.kind === 161)) { return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); } var leftType = checkExpression(node.left, contextualMapper); var rightType = checkExpression(node.right, contextualMapper); switch (operator) { - case 35: - case 56: case 36: case 57: case 37: case 58: - case 34: - case 55: - case 40: + case 38: case 59: + case 35: + case 56: case 41: case 60: case 42: case 61: - case 44: - case 63: - case 45: - case 64: case 43: case 62: + case 45: + case 64: + case 46: + case 65: + case 44: + case 63: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -16790,8 +17848,8 @@ var ts; } } return numberType; - case 33: - case 54: + case 34: + case 55: if (leftType.flags & (32 | 64)) leftType = rightType; if (rightType.flags & (32 | 64)) @@ -16815,42 +17873,42 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 54) { + if (operator === 55) { checkAssignmentOperator(resultType); } return resultType; case 24: - case 25: case 26: case 27: + case 28: if (!checkForDisallowedESSymbolOperand(operator)) { return booleanType; } - case 28: case 29: case 30: case 31: + case 32: if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { reportOperatorError(); } return booleanType; - case 87: + case 88: return checkInstanceOfExpression(node, leftType, rightType); - case 86: + case 87: return checkInExpression(node, leftType, rightType); - case 48: - return rightType; case 49: + return rightType; + case 50: return getUnionType([leftType, rightType]); - case 53: + case 54: checkAssignmentOperator(rightType); return rightType; case 23: return rightType; } function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 2097152) ? node.left : - someConstituentTypeHasKind(rightType, 2097152) ? node.right : + var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 4194304) ? node.left : + someConstituentTypeHasKind(rightType, 4194304) ? node.right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -16860,21 +17918,21 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { + case 45: + case 64: + return 50; + case 46: + case 65: + return 32; case 44: case 63: return 49; - case 45: - case 64: - return 31; - case 43: - case 62: - return 48; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 53 && operator <= 64) { + if (produceDiagnostics && operator >= 54 && operator <= 65) { 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 (ok) { checkTypeAssignableTo(valueType, leftType, node.left, undefined); @@ -16901,8 +17959,13 @@ var ts; return false; } function checkYieldExpression(node) { - if (!(node.parserContextFlags & 4) || isYieldExpressionInClass(node)) { - grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); + if (produceDiagnostics) { + if (!(node.parserContextFlags & 2) || isYieldExpressionInClass(node)) { + grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); + } + if (isInParameterInitializerBeforeContainingFunction(node)) { + error(node, ts.Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer); + } } if (node.expression) { var func = ts.getContainingFunction(node); @@ -16953,14 +18016,14 @@ var ts; return links.resolvedType; } function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 129) { + if (node.name.kind === 133) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); } function checkObjectLiteralMethod(node, contextualMapper) { checkGrammarMethod(node); - if (node.name.kind === 129) { + if (node.name.kind === 133) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -16983,7 +18046,7 @@ var ts; } function checkExpression(node, contextualMapper) { var type; - if (node.kind === 128) { + if (node.kind === 132) { type = checkQualifiedName(node); } else { @@ -16991,9 +18054,9 @@ var ts; type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 158 && node.parent.expression === node) || - (node.parent.kind === 159 && node.parent.expression === node) || - ((node.kind === 65 || node.kind === 128) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 163 && node.parent.expression === node) || + (node.parent.kind === 164 && node.parent.expression === node) || + ((node.kind === 66 || node.kind === 132) && 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); } @@ -17006,68 +18069,79 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 65: + case 66: return checkIdentifier(node); - case 93: + case 94: return checkThisExpression(node); - case 91: + case 92: return checkSuperExpression(node); - case 89: + case 90: return nullType; - case 95: - case 80: + case 96: + case 81: return booleanType; case 7: return checkNumericLiteral(node); - case 174: + case 180: return checkTemplateExpression(node); case 8: case 10: return stringType; case 9: return globalRegExpType; - case 156: - return checkArrayLiteral(node, contextualMapper); - case 157: - return checkObjectLiteral(node, contextualMapper); - case 158: - return checkPropertyAccessExpression(node); - case 159: - return checkIndexedAccess(node); - case 160: case 161: - return checkCallExpression(node); + return checkArrayLiteral(node, contextualMapper); case 162: - return checkTaggedTemplateExpression(node); + return checkObjectLiteral(node, contextualMapper); case 163: - return checkTypeAssertion(node); + return checkPropertyAccessExpression(node); case 164: - return checkExpression(node.expression, contextualMapper); - case 177: - return checkClassExpression(node); + return checkIndexedAccess(node); case 165: case 166: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 168: - return checkTypeOfExpression(node); + return checkCallExpression(node); case 167: - return checkDeleteExpression(node); + return checkTaggedTemplateExpression(node); case 169: - return checkVoidExpression(node); + return checkExpression(node.expression, contextualMapper); + case 183: + return checkClassExpression(node); case 170: - return checkPrefixUnaryExpression(node); case 171: - return checkPostfixUnaryExpression(node); - case 172: - return checkBinaryExpression(node, contextualMapper); + return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); case 173: - return checkConditionalExpression(node, contextualMapper); - case 176: - return checkSpreadElementExpression(node, contextualMapper); - case 178: - return undefinedType; + return checkTypeOfExpression(node); + case 168: + case 186: + return checkAssertion(node); + case 172: + return checkDeleteExpression(node); + case 174: + return checkVoidExpression(node); case 175: + return checkAwaitExpression(node); + case 176: + return checkPrefixUnaryExpression(node); + case 177: + return checkPostfixUnaryExpression(node); + case 178: + return checkBinaryExpression(node, contextualMapper); + case 179: + return checkConditionalExpression(node, contextualMapper); + case 182: + return checkSpreadElementExpression(node, contextualMapper); + case 184: + return undefinedType; + case 181: return checkYieldExpression(node); + case 237: + return checkJsxExpression(node); + case 230: + return checkJsxElement(node); + case 231: + return checkJsxSelfClosingElement(node); + case 232: + ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; } @@ -17091,7 +18165,7 @@ var ts; var func = ts.getContainingFunction(node); if (node.flags & 112) { func = ts.getContainingFunction(node); - if (!(func.kind === 137 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 141 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -17106,15 +18180,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 136 || - node.kind === 203 || - node.kind === 165; + return node.kind === 140 || + node.kind === 210 || + node.kind === 170; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 65 && + if (param.name.kind === 66 && param.name.text === parameter.text) { return i; } @@ -17124,30 +18198,30 @@ var ts; } function isInLegalTypePredicatePosition(node) { switch (node.parent.kind) { - case 166: + case 171: + case 144: + case 210: + case 170: + case 149: case 140: - case 203: - case 165: - case 145: - case 136: - case 135: + case 139: return node === node.parent.type; } return false; } function checkSignatureDeclaration(node) { - if (node.kind === 142) { + if (node.kind === 146) { checkGrammarIndexSignature(node); } - else if (node.kind === 145 || node.kind === 203 || node.kind === 146 || - node.kind === 140 || node.kind === 137 || - node.kind === 141) { + else if (node.kind === 149 || node.kind === 210 || node.kind === 150 || + node.kind === 144 || node.kind === 141 || + node.kind === 145) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { - if (node.type.kind === 143) { + if (node.type.kind === 147) { var typePredicate = getSignatureFromDeclaration(node).typePredicate; var typePredicateNode = node.type; if (isInLegalTypePredicatePosition(typePredicateNode)) { @@ -17166,19 +18240,19 @@ var ts; if (hasReportedError) { break; } - if (param.name.kind === 153 || - param.name.kind === 154) { + if (param.name.kind === 158 || + param.name.kind === 159) { (function checkBindingPattern(pattern) { for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.name.kind === 65 && + if (element.name.kind === 66 && element.name.text === typePredicate.parameterName) { error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); hasReportedError = true; break; } - else if (element.name.kind === 154 || - element.name.kind === 153) { + else if (element.name.kind === 159 || + element.name.kind === 158) { checkBindingPattern(element.name); } } @@ -17202,10 +18276,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 141: + case 145: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 140: + case 144: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -17227,7 +18301,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 205) { + if (node.kind === 212) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -17242,7 +18316,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 123: + case 127: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -17250,7 +18324,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 121: + case 125: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -17270,6 +18344,9 @@ var ts; function checkMethodDeclaration(node) { checkGrammarMethod(node) || checkGrammarComputedPropertyName(node.name); checkFunctionLikeDeclaration(node); + if (node.flags & 256 && node.body) { + error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); + } } function checkConstructorDeclaration(node) { checkSignatureDeclaration(node); @@ -17287,30 +18364,30 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 160 && n.expression.kind === 91; + return n.kind === 165 && n.expression.kind === 92; } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } switch (n.kind) { - case 165: - case 203: - case 166: - case 157: return false; + case 170: + case 210: + case 171: + case 162: return false; default: return ts.forEachChild(n, containsSuperCall); } } function markThisReferencesAsErrors(n) { - if (n.kind === 93) { + if (n.kind === 94) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 165 && n.kind !== 203) { + else if (n.kind !== 170 && n.kind !== 210) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 134 && + return n.kind === 138 && !(n.flags & 128) && !!n.initializer; } @@ -17320,7 +18397,7 @@ var ts; ts.forEach(node.parameters, function (p) { return p.flags & (16 | 32 | 64); }); if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 185 || !isSuperCallExpression(statements[0].expression)) { + if (!statements.length || statements[0].kind !== 192 || !isSuperCallExpression(statements[0].expression)) { error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); } else { @@ -17336,13 +18413,13 @@ var ts; function checkAccessorDeclaration(node) { if (produceDiagnostics) { checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 138) { + if (node.kind === 142) { 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 === 138 ? 139 : 138; + var otherKind = node.kind === 142 ? 143 : 142; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112) !== (otherAccessor.flags & 112))) { @@ -17408,7 +18485,7 @@ var ts; } ts.forEach(node.elementTypes, checkSourceElement); } - function checkUnionType(node) { + function checkUnionOrIntersectionType(node) { ts.forEach(node.types, checkSourceElement); } function isPrivateWithinAmbient(node) { @@ -17427,9 +18504,9 @@ var ts; return; } var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 205) { - ts.Debug.assert(signatureDeclarationNode.kind === 140 || signatureDeclarationNode.kind === 141); - var signatureKind = signatureDeclarationNode.kind === 140 ? 0 : 1; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 212) { + ts.Debug.assert(signatureDeclarationNode.kind === 144 || signatureDeclarationNode.kind === 145); + var signatureKind = signatureDeclarationNode.kind === 144 ? 0 : 1; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -17447,7 +18524,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 205 && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 212 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; } @@ -17478,6 +18555,9 @@ var ts; else if (deviation & (32 | 64)) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } + else if (deviation & 256) { + error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract); + } }); } } @@ -17492,7 +18572,7 @@ var ts; }); } } - var flagsToCheck = 1 | 2 | 32 | 64; + var flagsToCheck = 1 | 2 | 32 | 64 | 256; var someNodeFlags = 0; var allNodeFlags = flagsToCheck; var someHaveQuestionToken = false; @@ -17520,7 +18600,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 === 136 || node.kind === 135); + ts.Debug.assert(node.kind === 140 || node.kind === 139); 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); @@ -17537,7 +18617,12 @@ var ts; error(errorNode, ts.Diagnostics.Constructor_implementation_is_missing); } else { - error(errorNode, ts.Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration); + if (node.flags & 256) { + error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); + } + else { + error(errorNode, ts.Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration); + } } } var isExportSymbolInsideModule = symbol.parent && symbol.parent.flags & 1536; @@ -17547,11 +18632,11 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 205 || node.parent.kind === 148 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 212 || node.parent.kind === 152 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 203 || node.kind === 136 || node.kind === 135 || node.kind === 137) { + if (node.kind === 210 || node.kind === 140 || node.kind === 139 || node.kind === 141) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -17592,7 +18677,8 @@ var ts; error(declaration.name, ts.Diagnostics.Duplicate_function_implementation); }); } - if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body) { + if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && + !(lastSeenNonAmbientDeclaration.flags & 256)) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { @@ -17648,16 +18734,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 205: + case 212: return 2097152; - case 208: + case 215: return d.name.kind === 8 || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 204: - case 207: - return 2097152 | 1048576; case 211: + case 214: + return 2097152 | 1048576; + case 218: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -17667,6 +18753,121 @@ var ts; } } } + function checkNonThenableType(type, location, message) { + if (!(type.flags & 1) && isTypeAssignableTo(type, getGlobalThenableType())) { + if (location) { + if (!message) { + message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; + } + error(location, message); + } + return unknownType; + } + return type; + } + function getPromisedType(promise) { + // + // { // promise + // then( // thenFunction + // onfulfilled: ( // onfulfilledParameterType + // value: T // valueParameterType + // ) => any + // ): any; + // } + // + if (promise.flags & 1) { + return undefined; + } + if ((promise.flags & 4096) && promise.target === tryGetGlobalPromiseType()) { + return promise.typeArguments[0]; + } + var globalPromiseLikeType = getInstantiatedGlobalPromiseLikeType(); + if (globalPromiseLikeType === emptyObjectType || !isTypeAssignableTo(promise, globalPromiseLikeType)) { + return undefined; + } + var thenFunction = getTypeOfPropertyOfType(promise, "then"); + if (thenFunction && (thenFunction.flags & 1)) { + return undefined; + } + var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0) : emptyArray; + if (thenSignatures.length === 0) { + return undefined; + } + var onfulfilledParameterType = getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)); + if (onfulfilledParameterType.flags & 1) { + return undefined; + } + var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0); + if (onfulfilledParameterSignatures.length === 0) { + return undefined; + } + var valueParameterType = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature)); + return valueParameterType; + } + function getTypeOfFirstParameterOfSignature(signature) { + return getTypeAtPosition(signature, 0); + } + function getAwaitedType(type) { + return checkAwaitedType(type, undefined, undefined); + } + function checkAwaitedType(type, location, message) { + return checkAwaitedTypeWorker(type); + function checkAwaitedTypeWorker(type) { + if (type.flags & 16384) { + var types = []; + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var constituentType = _a[_i]; + types.push(checkAwaitedTypeWorker(constituentType)); + } + return getUnionType(types); + } + else { + var promisedType = getPromisedType(type); + if (promisedType === undefined) { + return checkNonThenableType(type, location, message); + } + else { + if (type.id === promisedType.id || awaitedTypeStack.indexOf(promisedType.id) >= 0) { + if (location) { + error(location, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method, symbolToString(type.symbol)); + } + return unknownType; + } + awaitedTypeStack.push(type.id); + var awaitedType = checkAwaitedTypeWorker(promisedType); + awaitedTypeStack.pop(); + return awaitedType; + } + } + } + } + function checkAsyncFunctionReturnType(node) { + var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); + if (globalPromiseConstructorLikeType === emptyObjectType) { + return unknownType; + } + var promiseType = getTypeFromTypeNode(node.type); + if (promiseType === unknownType && compilerOptions.isolatedModules) { + return unknownType; + } + var promiseConstructor = getMergedSymbol(promiseType.symbol); + if (!promiseConstructor || !symbolIsValue(promiseConstructor)) { + error(node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeToString(promiseType)); + return unknownType; + } + var promiseConstructorType = getTypeOfSymbol(promiseConstructor); + if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type)) { + return unknownType; + } + var promiseName = ts.getEntityNameFromTypeNode(node.type); + var root = getFirstIdentifier(promiseName); + var rootSymbol = getSymbol(node.locals, root.text, 107455); + if (rootSymbol) { + error(rootSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, root.text, getFullyQualifiedName(promiseConstructor)); + return unknownType; + } + return checkAwaitedType(promiseType, node, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + } function checkDecorator(node) { var signature = getResolvedSignature(node); var returnType = getReturnTypeOfSignature(signature); @@ -17677,22 +18878,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 204: + case 211: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 131: + case 135: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 134: + case 138: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 136: - case 138: - case 139: + case 140: + case 142: + case 143: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -17701,33 +18902,30 @@ var ts; checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, errorInfo); } function checkTypeNodeAsExpression(node) { - if (node && node.kind === 144) { - var type = getTypeFromTypeNode(node); - var shouldCheckIfUnknownType = type === unknownType && compilerOptions.isolatedModules; - if (!type || (!shouldCheckIfUnknownType && type.flags & (2097279 | 132 | 258))) { - return; - } - if (shouldCheckIfUnknownType || type.symbol.valueDeclaration) { - checkExpression(node.typeName); + if (node && node.kind === 148) { + var root = getFirstIdentifier(node.typeName); + var rootSymbol = resolveName(root, root.text, 107455, undefined, undefined); + if (rootSymbol && rootSymbol.flags & 8388608 && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { + markAliasSymbolAsReferenced(rootSymbol); } } } function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 134: - checkTypeNodeAsExpression(node.type); - break; - case 131: - checkTypeNodeAsExpression(node.type); - break; - case 136: - checkTypeNodeAsExpression(node.type); - break; case 138: checkTypeNodeAsExpression(node.type); break; - case 139: - checkTypeNodeAsExpression(getSetAccessorTypeAnnotationNode(node)); + case 135: + checkTypeNodeAsExpression(node.type); + break; + case 140: + checkTypeNodeAsExpression(node.type); + break; + case 142: + checkTypeNodeAsExpression(node.type); + break; + case 143: + checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node)); break; } } @@ -17749,24 +18947,24 @@ var ts; } if (compilerOptions.emitDecoratorMetadata) { switch (node.kind) { - case 204: + case 211: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 136: + case 140: checkParameterTypeAnnotationsAsExpressions(node); - case 139: + case 143: + case 142: case 138: - case 134: - case 131: + case 135: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 131) { + if (node.kind === 135) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); @@ -17782,7 +18980,14 @@ var ts; function checkFunctionLikeDeclaration(node) { checkDecorators(node); checkSignatureDeclaration(node); - if (node.name && node.name.kind === 129) { + 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 === 133) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -17800,7 +19005,12 @@ var ts; } checkSourceElement(node.body); if (node.type && !isAccessor(node.kind) && !node.asteriskToken) { - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); + var returnType = getTypeFromTypeNode(node.type); + var promisedType; + if (isAsync) { + promisedType = checkAsyncFunctionReturnType(node); + } + checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); } if (produceDiagnostics && !node.type) { if (compilerOptions.noImplicitAny && ts.nodeIsMissing(node.body) && !isPrivateWithinAmbient(node)) { @@ -17812,11 +19022,11 @@ var ts; } } function checkBlock(node) { - if (node.kind === 182) { + if (node.kind === 189) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 209) { + if (ts.isFunctionBlock(node) || node.kind === 216) { checkFunctionAndClassExpressionBodies(node); } } @@ -17834,19 +19044,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 134 || - node.kind === 133 || - node.kind === 136 || - node.kind === 135 || - node.kind === 138 || - node.kind === 139) { + if (node.kind === 138 || + node.kind === 137 || + node.kind === 140 || + node.kind === 139 || + node.kind === 142 || + node.kind === 143) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 131 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 135 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -17860,7 +19070,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4) { - var isDeclaration_1 = node.kind !== 65; + var isDeclaration_1 = node.kind !== 66; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -17881,7 +19091,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 65; + var isDeclaration_2 = node.kind !== 66; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -17894,11 +19104,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 208 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 215 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 230 && ts.isExternalModule(parent)) { + if (parent.kind === 245 && 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)); } } @@ -17906,10 +19116,10 @@ var ts; // - 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) & 12288) !== 0 || ts.isParameterDeclaration(node)) { + if ((ts.getCombinedNodeFlags(node) & 49152) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 201 && !node.initializer) { + if (node.kind === 208 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -17918,35 +19128,35 @@ var ts; if (localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { - if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 12288) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 202); - var container = varDeclList.parent.kind === 183 && varDeclList.parent.parent + if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152) { + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 209); + var container = varDeclList.parent.kind === 190 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 182 && ts.isFunctionLike(container.parent) || - container.kind === 209 || - container.kind === 208 || - container.kind === 230); + (container.kind === 189 && ts.isFunctionLike(container.parent) || + container.kind === 216 || + container.kind === 215 || + container.kind === 245); if (!namesShareScope) { - var name_13 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_13, name_13); + 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); } } } } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 131) { + if (ts.getRootDeclaration(node).kind !== 135) { return; } var func = ts.getContainingFunction(node); visit(node.initializer); function visit(n) { - if (n.kind === 65) { + if (n.kind === 66) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 131) { + if (referencedSymbol.valueDeclaration.kind === 135) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -17966,7 +19176,7 @@ var ts; function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 129) { + if (node.name.kind === 133) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -17975,7 +19185,7 @@ var ts; if (ts.isBindingPattern(node.name)) { ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 131 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 135 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -18003,9 +19213,9 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 134 && node.kind !== 133) { + if (node.kind !== 138 && node.kind !== 137) { checkExportsOnMergedDeclarations(node); - if (node.kind === 201 || node.kind === 155) { + if (node.kind === 208 || node.kind === 160) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -18025,21 +19235,18 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarVariableDeclarationList(node.declarationList) || checkGrammarForDisallowedLetOrConstStatement(node); ts.forEach(node.declarationList.declarations, checkSourceElement); } - function checkGrammarDisallowedModifiersInBlockOrObjectLiteralExpression(node) { - if (node.modifiers) { - if (inBlockOrObjectLiteralExpression(node)) { + function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { + if (node.modifiers && node.parent.kind === 162) { + if (ts.isAsyncFunctionLike(node)) { + if (node.modifiers.length > 1) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + } + else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } } } - function inBlockOrObjectLiteralExpression(node) { - while (node) { - if (node.kind === 182 || node.kind === 157) { - return true; - } - node = node.parent; - } - } function checkExpressionStatement(node) { checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); @@ -18062,12 +19269,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 202) { + if (node.initializer && node.initializer.kind === 209) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 202) { + if (node.initializer.kind === 209) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -18082,13 +19289,13 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 202) { + if (node.initializer.kind === 209) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 156 || varExpr.kind === 157) { + if (varExpr.kind === 161 || varExpr.kind === 162) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -18103,7 +19310,7 @@ var ts; } function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 202) { + if (node.initializer.kind === 209) { 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); @@ -18113,7 +19320,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 156 || varExpr.kind === 157) { + if (varExpr.kind === 161 || varExpr.kind === 162) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258)) { @@ -18124,7 +19331,7 @@ var ts; } } var rightType = checkExpression(node.expression); - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 48128 | 512)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 | 512)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); } checkSourceElement(node.statement); @@ -18275,7 +19482,7 @@ var ts; checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 138 && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 139))); + return !!(node.kind === 142 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 143))); } function checkReturnStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { @@ -18293,22 +19500,33 @@ var ts; if (func.asteriskToken) { return; } - if (func.kind === 139) { + if (func.kind === 143) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 137) { + else if (func.kind === 141) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func) || signature.typePredicate) { - checkTypeAssignableTo(exprType, returnType, node.expression, undefined); + 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); + } + else { + checkTypeAssignableTo(exprType, returnType, node.expression); + } } } } } function checkWithStatement(node) { - checkGrammarStatementInAmbientContext(node); + if (!checkGrammarStatementInAmbientContext(node)) { + if (node.parserContextFlags & 8) { + grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); + } + } checkExpression(node.expression); error(node.expression, ts.Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any); } @@ -18318,7 +19536,7 @@ var ts; var hasDuplicateDefaultClause = false; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 224 && !hasDuplicateDefaultClause) { + if (clause.kind === 239 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -18330,7 +19548,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 223) { + if (produceDiagnostics && clause.kind === 238) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); if (!isTypeAssignableTo(expressionType, caseType)) { @@ -18347,7 +19565,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 197 && current.label.text === node.label.text) { + if (current.kind === 204 && 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; @@ -18373,7 +19591,7 @@ var ts; var catchClause = node.catchClause; if (catchClause) { if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 65) { + if (catchClause.variableDeclaration.name.kind !== 66) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -18441,7 +19659,7 @@ var ts; return; } var errorNode; - if (prop.valueDeclaration.name.kind === 129 || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 133 || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -18490,10 +19708,13 @@ var ts; return getTypeOfSymbol(getSymbolOfNode(node)); } function checkClassDeclaration(node) { - if (!node.name && !(node.flags & 256)) { + if (!node.name && !(node.flags & 1024)) { 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) { @@ -18587,43 +19808,52 @@ var ts; continue; } var derived = getTargetSymbol(getPropertyOfObjectType(type, base.name)); + var baseDeclarationFlags = getDeclarationFlagsFromSymbol(base); + ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); if (derived) { - var baseDeclarationFlags = getDeclarationFlagsFromSymbol(base); - var derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); - if ((baseDeclarationFlags & 32) || (derivedDeclarationFlags & 32)) { - continue; - } - if ((baseDeclarationFlags & 128) !== (derivedDeclarationFlags & 128)) { - continue; - } - if ((base.flags & derived.flags & 8192) || ((base.flags & 98308) && (derived.flags & 98308))) { - continue; - } - var errorMessage = void 0; - if (base.flags & 8192) { - if (derived.flags & 98304) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; + if (derived === base) { + var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 211); + 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)); } - else { - ts.Debug.assert((derived.flags & 4) !== 0); - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; - } - } - else if (base.flags & 4) { - ts.Debug.assert((derived.flags & 8192) !== 0); - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; } else { - ts.Debug.assert((base.flags & 98304) !== 0); - ts.Debug.assert((derived.flags & 8192) !== 0); - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + var derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); + if ((baseDeclarationFlags & 32) || (derivedDeclarationFlags & 32)) { + continue; + } + if ((baseDeclarationFlags & 128) !== (derivedDeclarationFlags & 128)) { + continue; + } + if ((base.flags & derived.flags & 8192) || ((base.flags & 98308) && (derived.flags & 98308))) { + continue; + } + var errorMessage = void 0; + if (base.flags & 8192) { + if (derived.flags & 98304) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; + } + else { + ts.Debug.assert((derived.flags & 4) !== 0); + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; + } + } + else if (base.flags & 4) { + ts.Debug.assert((derived.flags & 8192) !== 0); + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + } + else { + ts.Debug.assert((base.flags & 98304) !== 0); + ts.Debug.assert((derived.flags & 8192) !== 0); + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } + error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } - error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } } } function isAccessor(kind) { - return kind === 138 || kind === 139; + return kind === 142 || kind === 143; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -18689,7 +19919,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 205); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 212); 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); @@ -18704,6 +19934,15 @@ var ts; checkIndexConstraints(type); } } + if (symbol && symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 211 && !ts.isInAmbientContext(declaration)) { + error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); + break; + } + } + } } ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) { if (!ts.isSupportedExpressionWithTypeArguments(heritageElement)) { @@ -18723,14 +19962,14 @@ var ts; } function computeEnumMemberValues(node) { var nodeLinks = getNodeLinks(node); - if (!(nodeLinks.flags & 128)) { + if (!(nodeLinks.flags & 8192)) { var enumSymbol = getSymbolOfNode(node); var enumType = getDeclaredTypeOfSymbol(enumSymbol); var autoValue = 0; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); ts.forEach(node.members, function (member) { - if (member.name.kind !== 129 && isNumericLiteralName(member.name.text)) { + if (member.name.kind !== 133 && isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } var initializer = member.initializer; @@ -18760,24 +19999,24 @@ var ts; getNodeLinks(member).enumMemberValue = autoValue++; } }); - nodeLinks.flags |= 128; + nodeLinks.flags |= 8192; } function getConstantValueForEnumMemberInitializer(initializer) { return evalConstant(initializer); function evalConstant(e) { switch (e.kind) { - case 170: + case 176: var value = evalConstant(e.operand); if (value === undefined) { return undefined; } switch (e.operator) { - case 33: return value; - case 34: return -value; - case 47: return ~value; + case 34: return value; + case 35: return -value; + case 48: return ~value; } return undefined; - case 172: + case 178: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -18787,37 +20026,37 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 44: return left | right; - case 43: return left & right; - case 41: return left >> right; - case 42: return left >>> right; - case 40: return left << right; - case 45: return left ^ right; - case 35: return left * right; - case 36: return left / right; - case 33: return left + right; - case 34: return left - right; - case 37: return left % right; + case 45: return left | right; + case 44: return left & right; + case 42: return left >> right; + case 43: return left >>> right; + case 41: return left << right; + case 46: return left ^ right; + case 36: return left * right; + case 37: return left / right; + case 34: return left + right; + case 35: return left - right; + case 38: return left % right; } return undefined; case 7: return +e.text; - case 164: + case 169: return evalConstant(e.expression); - case 65: - case 159: - case 158: + case 66: + case 164: + case 163: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType; var propertyName; - if (e.kind === 65) { + if (e.kind === 66) { enumType = currentType; propertyName = e.text; } else { var expression; - if (e.kind === 159) { + if (e.kind === 164) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 8) { return undefined; @@ -18831,10 +20070,10 @@ var ts; } var current = expression; while (current) { - if (current.kind === 65) { + if (current.kind === 66) { break; } - else if (current.kind === 158) { + else if (current.kind === 163) { current = current.expression; } else { @@ -18891,7 +20130,7 @@ var ts; } var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 207) { + if (declaration.kind !== 214) { return false; } var enumDeclaration = declaration; @@ -18914,8 +20153,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 204 || - (declaration.kind === 203 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 211 || + (declaration.kind === 210 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -18966,10 +20205,10 @@ 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, 204); + var mergedClass = ts.getDeclarationOfKind(symbol, 211); if (mergedClass && inSameLexicalScope(node, mergedClass)) { - getNodeLinks(node).flags |= 2048; + getNodeLinks(node).flags |= 32768; } } if (isAmbientExternalModule) { @@ -18985,17 +20224,17 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 128) { + if (node.kind === 132) { node = node.left; } - else if (node.kind === 158) { + else if (node.kind === 163) { node = node.expression; } else { break; } } - ts.Debug.assert(node.kind === 65); + ts.Debug.assert(node.kind === 66); return node; } function checkExternalImportOrExportDeclaration(node) { @@ -19004,9 +20243,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 209 && node.parent.parent.name.kind === 8; - if (node.parent.kind !== 230 && !inAmbientExternalModule) { - error(moduleName, node.kind === 218 ? + var inAmbientExternalModule = node.parent.kind === 216 && node.parent.parent.name.kind === 8; + if (node.parent.kind !== 245 && !inAmbientExternalModule) { + error(moduleName, node.kind === 225 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -19025,7 +20264,7 @@ var ts; (symbol.flags & 793056 ? 793056 : 0) | (symbol.flags & 1536 ? 1536 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 220 ? + var message = node.kind === 227 ? 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)); @@ -19041,7 +20280,7 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) { return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -19051,7 +20290,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 214) { + if (importClause.namedBindings.kind === 221) { checkImportBinding(importClause.namedBindings); } else { @@ -19096,14 +20335,14 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) { return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 209 && node.parent.parent.name.kind === 8; - if (node.parent.kind !== 230 && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 216 && node.parent.parent.name.kind === 8; + if (node.parent.kind !== 245 && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -19116,7 +20355,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 230 && node.parent.kind !== 209 && node.parent.kind !== 208) { + if (node.parent.kind !== 245 && node.parent.kind !== 216 && node.parent.kind !== 215) { return grammarErrorOnFirstToken(node, errorMessage); } } @@ -19130,15 +20369,15 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 230 ? node.parent : node.parent.parent; - if (container.kind === 208 && container.name.kind === 65) { + var container = node.parent.kind === 245 ? node.parent : node.parent.parent; + if (container.kind === 215 && container.name.kind === 66) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 65) { + if (node.expression.kind === 66) { markExportAsReferenced(node); } else { @@ -19155,10 +20394,10 @@ var ts; } } function getModuleStatements(node) { - if (node.kind === 230) { + if (node.kind === 245) { return node.statements; } - if (node.kind === 208 && node.body.kind === 209) { + if (node.kind === 215 && node.body.kind === 216) { return node.body.statements; } return emptyArray; @@ -19189,197 +20428,218 @@ var ts; } } function checkSourceElement(node) { - if (!node) + if (!node) { return; - switch (node.kind) { - case 130: - return checkTypeParameter(node); - case 131: - return checkParameter(node); + } + var kind = node.kind; + if (cancellationToken) { + switch (kind) { + case 215: + case 211: + case 212: + case 210: + cancellationToken.throwIfCancellationRequested(); + } + } + switch (kind) { case 134: - case 133: - return checkPropertyDeclaration(node); - case 145: - case 146: - case 140: - case 141: - return checkSignatureDeclaration(node); - case 142: - return checkSignatureDeclaration(node); - case 136: + return checkTypeParameter(node); case 135: - return checkMethodDeclaration(node); - case 137: - return checkConstructorDeclaration(node); + return checkParameter(node); case 138: - case 139: - return checkAccessorDeclaration(node); - case 144: - return checkTypeReferenceNode(node); - case 143: - return checkTypePredicate(node); - case 147: - return checkTypeQuery(node); - case 148: - return checkTypeLiteral(node); + case 137: + return checkPropertyDeclaration(node); case 149: - return checkArrayType(node); case 150: - return checkTupleType(node); + case 144: + case 145: + return checkSignatureDeclaration(node); + case 146: + return checkSignatureDeclaration(node); + case 140: + case 139: + return checkMethodDeclaration(node); + case 141: + return checkConstructorDeclaration(node); + case 142: + case 143: + return checkAccessorDeclaration(node); + case 148: + return checkTypeReferenceNode(node); + case 147: + return checkTypePredicate(node); case 151: - return checkUnionType(node); + return checkTypeQuery(node); case 152: - return checkSourceElement(node.type); - case 203: - return checkFunctionDeclaration(node); - case 182: - case 209: - return checkBlock(node); - case 183: - return checkVariableStatement(node); - case 185: - return checkExpressionStatement(node); - case 186: - return checkIfStatement(node); - case 187: - return checkDoStatement(node); - case 188: - return checkWhileStatement(node); - case 189: - return checkForStatement(node); - case 190: - return checkForInStatement(node); - case 191: - return checkForOfStatement(node); - case 192: - case 193: - return checkBreakOrContinueStatement(node); - case 194: - return checkReturnStatement(node); - case 195: - return checkWithStatement(node); - case 196: - return checkSwitchStatement(node); - case 197: - return checkLabeledStatement(node); - case 198: - return checkThrowStatement(node); - case 199: - return checkTryStatement(node); - case 201: - return checkVariableDeclaration(node); + return checkTypeLiteral(node); + case 153: + return checkArrayType(node); + case 154: + return checkTupleType(node); case 155: - return checkBindingElement(node); - case 204: - return checkClassDeclaration(node); - case 205: - return checkInterfaceDeclaration(node); - case 206: - return checkTypeAliasDeclaration(node); - case 207: - return checkEnumDeclaration(node); - case 208: - return checkModuleDeclaration(node); - case 212: - return checkImportDeclaration(node); - case 211: - return checkImportEqualsDeclaration(node); - case 218: - return checkExportDeclaration(node); - case 217: - return checkExportAssignment(node); - case 184: - checkGrammarStatementInAmbientContext(node); - return; + case 156: + return checkUnionOrIntersectionType(node); + case 157: + return checkSourceElement(node.type); + case 210: + return checkFunctionDeclaration(node); + case 189: + case 216: + return checkBlock(node); + case 190: + return checkVariableStatement(node); + case 192: + return checkExpressionStatement(node); + case 193: + return checkIfStatement(node); + case 194: + return checkDoStatement(node); + case 195: + return checkWhileStatement(node); + case 196: + return checkForStatement(node); + case 197: + return checkForInStatement(node); + case 198: + return checkForOfStatement(node); + case 199: case 200: + return checkBreakOrContinueStatement(node); + case 201: + return checkReturnStatement(node); + case 202: + return checkWithStatement(node); + case 203: + return checkSwitchStatement(node); + case 204: + return checkLabeledStatement(node); + case 205: + return checkThrowStatement(node); + case 206: + return checkTryStatement(node); + case 208: + return checkVariableDeclaration(node); + case 160: + return checkBindingElement(node); + case 211: + return checkClassDeclaration(node); + case 212: + return checkInterfaceDeclaration(node); + case 213: + return checkTypeAliasDeclaration(node); + case 214: + return checkEnumDeclaration(node); + case 215: + return checkModuleDeclaration(node); + case 219: + return checkImportDeclaration(node); + case 218: + return checkImportEqualsDeclaration(node); + case 225: + return checkExportDeclaration(node); + case 224: + return checkExportAssignment(node); + case 191: checkGrammarStatementInAmbientContext(node); return; - case 221: + case 207: + checkGrammarStatementInAmbientContext(node); + return; + case 228: return checkMissingDeclaration(node); } } function checkFunctionAndClassExpressionBodies(node) { switch (node.kind) { - case 165: - case 166: + case 170: + case 171: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 177: + case 183: ts.forEach(node.members, checkSourceElement); break; - case 136: - case 135: + case 140: + case 139: ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 137: - case 138: - case 139: - case 203: + case 141: + case 142: + case 143: + case 210: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); break; - case 195: + case 202: checkFunctionAndClassExpressionBodies(node.expression); break; - case 132: - case 131: - case 134: - case 133: - case 153: - case 154: - case 155: - case 156: - case 157: - case 227: + case 136: + case 135: + case 138: + case 137: case 158: case 159: case 160: case 161: case 162: - case 174: - case 180: + case 242: case 163: case 164: - case 168: - case 169: + case 165: + case 166: case 167: - case 170: - case 171: - case 172: - case 173: - case 176: - case 182: - case 209: - case 183: - case 185: - case 186: + case 180: case 187: - case 188: + case 168: + case 186: + case 169: + case 173: + case 174: + case 175: + case 172: + case 176: + case 177: + case 178: + case 179: + case 182: + case 181: case 189: + case 216: case 190: - case 191: case 192: case 193: case 194: + case 195: case 196: - case 210: - case 223: - case 224: case 197: case 198: case 199: - case 226: + case 200: case 201: - case 202: - case 204: - case 207: - case 229: + case 203: case 217: + case 238: + case 239: + case 204: + case 205: + case 206: + case 241: + case 208: + case 209: + case 211: + case 214: + case 244: + case 224: + case 245: + case 237: case 230: + case 231: + case 235: + case 236: + case 232: ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; } @@ -19413,15 +20673,30 @@ var ts; links.flags |= 8; } if (emitDecorate) { - links.flags |= 512; + links.flags |= 16; } if (emitParam) { - links.flags |= 1024; + links.flags |= 32; + } + if (emitAwaiter) { + links.flags |= 64; + } + if (emitGenerator || (emitAwaiter && languageVersion < 2)) { + links.flags |= 128; } links.flags |= 1; } } - function getDiagnostics(sourceFile) { + function getDiagnostics(sourceFile, ct) { + try { + cancellationToken = ct; + return getDiagnosticsWorker(sourceFile); + } + finally { + cancellationToken = undefined; + } + } + function getDiagnosticsWorker(sourceFile) { throwIfNonDiagnosticsProducing(); if (sourceFile) { checkSourceFile(sourceFile); @@ -19442,7 +20717,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 195 && node.parent.statement === node) { + if (node.parent.kind === 202 && node.parent.statement === node) { return true; } node = node.parent; @@ -19464,28 +20739,30 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 230: + case 245: if (!ts.isExternalModule(location)) { break; } - case 208: + case 215: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 207: + case 214: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 177: - if (location.name) { + case 183: + var className = location.name; + if (className) { copySymbol(location.symbol, meaning); } - case 204: - case 205: + case 211: + case 212: if (!(memberFlags & 128)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056); } break; - case 165: - if (location.name) { + case 170: + var funcName = location.name; + if (funcName) { copySymbol(location.symbol, meaning); } break; @@ -19498,7 +20775,7 @@ var ts; function copySymbol(symbol, meaning) { if (symbol.flags & meaning) { var id = symbol.name; - if (!isReservedMemberName(id) && !ts.hasProperty(symbols, id)) { + if (!ts.hasProperty(symbols, id)) { symbols[id] = symbol; } } @@ -19506,50 +20783,49 @@ var ts; function copySymbols(source, meaning) { if (meaning) { for (var id in source) { - if (ts.hasProperty(source, id)) { - copySymbol(source[id], meaning); - } + var symbol = source[id]; + copySymbol(symbol, meaning); } } } } function isTypeDeclarationName(name) { - return name.kind === 65 && + return name.kind === 66 && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 130: - case 204: - case 205: - case 206: - case 207: + case 134: + case 211: + case 212: + case 213: + case 214: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 128) { + while (node.parent && node.parent.kind === 132) { node = node.parent; } - return node.parent && node.parent.kind === 144; + return node.parent && node.parent.kind === 148; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 158) { + while (node.parent && node.parent.kind === 163) { node = node.parent; } - return node.parent && node.parent.kind === 179; + return node.parent && node.parent.kind === 185; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 128) { + while (nodeOnRightSide.parent.kind === 132) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 211) { + if (nodeOnRightSide.parent.kind === 218) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 217) { + if (nodeOnRightSide.parent.kind === 224) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -19561,10 +20837,10 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 217) { + if (entityName.parent.kind === 224) { return resolveEntityName(entityName, 107455 | 793056 | 1536 | 8388608); } - if (entityName.kind !== 158) { + if (entityName.kind !== 163) { if (isInRightSideOfImportOrExportAssignment(entityName)) { return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); } @@ -19573,26 +20849,29 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 179 ? 793056 : 1536; + var meaning = entityName.parent.kind === 185 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } + else if ((entityName.parent.kind === 232) || (entityName.parent.kind === 231)) { + return getJsxElementTagSymbol(entityName.parent); + } else if (ts.isExpression(entityName)) { if (ts.nodeIsMissing(entityName)) { return undefined; } - if (entityName.kind === 65) { + if (entityName.kind === 66) { var meaning = 107455 | 8388608; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 158) { + else if (entityName.kind === 163) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 128) { + else if (entityName.kind === 132) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -19601,11 +20880,14 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 144 ? 793056 : 1536; + var meaning = entityName.parent.kind === 148 ? 793056 : 1536; meaning |= 8388608; return resolveEntityName(entityName, meaning); } - if (entityName.parent.kind === 143) { + else if (entityName.parent.kind === 235) { + return getJsxAttributePropertySymbol(entityName.parent); + } + if (entityName.parent.kind === 147) { return resolveEntityName(entityName, 1); } return undefined; @@ -19617,36 +20899,35 @@ var ts; if (ts.isDeclarationName(node)) { return getSymbolOfNode(node.parent); } - if (node.kind === 65 && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 217 + if (node.kind === 66 && isInRightSideOfImportOrExportAssignment(node)) { + return node.parent.kind === 224 ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } switch (node.kind) { - case 65: - case 158: - case 128: + case 66: + case 163: + case 132: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 93: - case 91: + case 94: + case 92: var type = checkExpression(node); return type.symbol; - case 114: + case 118: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 137) { + if (constructorDeclaration && constructorDeclaration.kind === 141) { return constructorDeclaration.parent.symbol; } return undefined; case 8: - var moduleName; if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 212 || node.parent.kind === 218) && + ((node.parent.kind === 219 || node.parent.kind === 225) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } case 7: - if (node.parent.kind === 159 && node.parent.argumentExpression === node) { + if (node.parent.kind === 164 && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -19660,7 +20941,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 228) { + if (location && location.kind === 243) { return resolveEntityName(location.name, 107455); } return undefined; @@ -19694,6 +20975,9 @@ var ts; var symbol = getSymbolInfo(node); return symbol && getTypeOfSymbol(symbol); } + if (ts.isBindingPattern(node)) { + return getTypeForVariableLikeDeclaration(node.parent); + } if (isInRightSideOfImportOrExportAssignment(node)) { var symbol = getSymbolInfo(node); var declaredType = symbol && getDeclaredTypeOfSymbol(symbol); @@ -19728,9 +21012,9 @@ var ts; function getRootSymbols(symbol) { if (symbol.flags & 268435456) { var symbols = []; - var name_14 = symbol.name; - ts.forEach(getSymbolLinks(symbol).unionType.types, function (t) { - symbols.push(getPropertyOfType(t, name_14)); + var name_16 = symbol.name; + ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { + symbols.push(getPropertyOfType(t, name_16)); }); return symbols; } @@ -19754,11 +21038,11 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 230) { + if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 245) { return parentSymbol.valueDeclaration; } for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 208 || n.kind === 207) && getSymbolOfNode(n) === parentSymbol) { + if ((n.kind === 215 || n.kind === 214) && getSymbolOfNode(n) === parentSymbol) { return n; } } @@ -19771,11 +21055,11 @@ var ts; } function isStatementWithLocals(node) { switch (node.kind) { - case 182: - case 210: case 189: - case 190: - case 191: + case 217: + case 196: + case 197: + case 198: return true; } return false; @@ -19801,22 +21085,22 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 211: - case 213: - case 214: - case 216: - case 220: - return isAliasResolvedToValue(getSymbolOfNode(node)); case 218: + case 220: + case 221: + case 223: + case 227: + return isAliasResolvedToValue(getSymbolOfNode(node)); + case 225: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 217: - return node.expression && node.expression.kind === 65 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + case 224: + return node.expression && node.expression.kind === 66 ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 230 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 245 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -19861,7 +21145,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 229) { + if (node.kind === 244) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -19872,149 +21156,50 @@ var ts; } return undefined; } - function serializeEntityName(node, fallbackPath) { - if (node.kind === 65) { - var text = node.text; - if (fallbackPath) { - fallbackPath.push(text); - } - else { - return text; - } + function isFunctionType(type) { + return type.flags & 80896 && getSignaturesOfType(type, 0).length > 0; + } + function getTypeReferenceSerializationKind(node) { + var symbol = resolveEntityName(node.typeName, 107455, true); + var constructorType = symbol ? getTypeOfSymbol(symbol) : undefined; + if (constructorType && isConstructorType(constructorType)) { + return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; + } + var type = getTypeFromTypeNode(node); + if (type === unknownType) { + return ts.TypeReferenceSerializationKind.Unknown; + } + else if (type.flags & 1) { + return ts.TypeReferenceSerializationKind.ObjectType; + } + else if (allConstituentTypesHaveKind(type, 16)) { + return ts.TypeReferenceSerializationKind.VoidType; + } + else if (allConstituentTypesHaveKind(type, 8)) { + return ts.TypeReferenceSerializationKind.BooleanType; + } + else if (allConstituentTypesHaveKind(type, 132)) { + return ts.TypeReferenceSerializationKind.NumberLikeType; + } + else if (allConstituentTypesHaveKind(type, 258)) { + return ts.TypeReferenceSerializationKind.StringLikeType; + } + else if (allConstituentTypesHaveKind(type, 8192)) { + return ts.TypeReferenceSerializationKind.ArrayLikeType; + } + else if (allConstituentTypesHaveKind(type, 4194304)) { + return ts.TypeReferenceSerializationKind.ESSymbolType; + } + else if (isFunctionType(type)) { + return ts.TypeReferenceSerializationKind.TypeWithCallSignature; + } + else if (isArrayType(type)) { + return ts.TypeReferenceSerializationKind.ArrayLikeType; } else { - var left = serializeEntityName(node.left, fallbackPath); - var right = serializeEntityName(node.right, fallbackPath); - if (!fallbackPath) { - return left + "." + right; - } + return ts.TypeReferenceSerializationKind.ObjectType; } } - function serializeTypeReferenceNode(node) { - var type = getTypeFromTypeNode(node); - if (type.flags & 16) { - return "void 0"; - } - else if (type.flags & 8) { - return "Boolean"; - } - else if (type.flags & 132) { - return "Number"; - } - else if (type.flags & 258) { - return "String"; - } - else if (type.flags & 8192) { - return "Array"; - } - else if (type.flags & 2097152) { - return "Symbol"; - } - else if (type === unknownType) { - var fallbackPath = []; - serializeEntityName(node.typeName, fallbackPath); - return fallbackPath; - } - else if (type.symbol && type.symbol.valueDeclaration) { - return serializeEntityName(node.typeName); - } - else if (typeHasCallOrConstructSignatures(type)) { - return "Function"; - } - return "Object"; - } - function serializeTypeNode(node) { - if (node) { - switch (node.kind) { - case 99: - return "void 0"; - case 152: - return serializeTypeNode(node.type); - case 145: - case 146: - return "Function"; - case 149: - case 150: - return "Array"; - case 113: - return "Boolean"; - case 123: - case 8: - return "String"; - case 121: - return "Number"; - case 144: - return serializeTypeReferenceNode(node); - case 147: - case 148: - case 151: - case 112: - break; - default: - ts.Debug.fail("Cannot serialize unexpected type node."); - break; - } - } - return "Object"; - } - function serializeTypeOfNode(node) { - switch (node.kind) { - case 204: return "Function"; - case 134: return serializeTypeNode(node.type); - case 131: return serializeTypeNode(node.type); - case 138: return serializeTypeNode(node.type); - case 139: return serializeTypeNode(getSetAccessorTypeAnnotationNode(node)); - } - if (ts.isFunctionLike(node)) { - return "Function"; - } - return "void 0"; - } - function serializeParameterTypesOfNode(node) { - if (node) { - var valueDeclaration; - if (node.kind === 204) { - valueDeclaration = ts.getFirstConstructorWithBody(node); - } - else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { - valueDeclaration = node; - } - if (valueDeclaration) { - var result; - var parameters = valueDeclaration.parameters; - var parameterCount = parameters.length; - if (parameterCount > 0) { - result = new Array(parameterCount); - for (var i = 0; i < parameterCount; i++) { - if (parameters[i].dotDotDotToken) { - var parameterType = parameters[i].type; - if (parameterType.kind === 149) { - parameterType = parameterType.elementType; - } - else if (parameterType.kind === 144 && parameterType.typeArguments && parameterType.typeArguments.length === 1) { - parameterType = parameterType.typeArguments[0]; - } - else { - parameterType = undefined; - } - result[i] = serializeTypeNode(parameterType); - } - else { - result[i] = serializeTypeOfNode(parameters[i]); - } - } - return result; - } - } - } - return emptyArray; - } - function serializeReturnTypeOfNode(node) { - if (node && ts.isFunctionLike(node)) { - return serializeTypeNode(node.type); - } - return "void 0"; - } function writeTypeOfDeclaration(declaration, enclosingDeclaration, flags, writer) { var symbol = getSymbolOfNode(declaration); var type = symbol && !(symbol.flags & (2048 | 131072)) @@ -20044,13 +21229,13 @@ var ts; } function getBlockScopedVariableId(n) { ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 155 || (n.parent.kind === 201 && n.parent.name === n); + var isVariableDeclarationOrBindingElement = n.parent.kind === 160 || (n.parent.kind === 208 && 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 !== 226; + symbol.valueDeclaration.parent.kind !== 241; if (isLetOrConst) { getSymbolLinks(symbol); return symbol.id; @@ -20090,9 +21275,7 @@ var ts; collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, - serializeTypeOfNode: serializeTypeOfNode, - serializeParameterTypesOfNode: serializeParameterTypesOfNode, - serializeReturnTypeOfNode: serializeReturnTypeOfNode + getTypeReferenceSerializationKind: getTypeReferenceSerializationKind }; } function initializeTypeChecker() { @@ -20115,7 +21298,19 @@ var ts; globalNumberType = getGlobalType("Number"); globalBooleanType = getGlobalType("Boolean"); globalRegExpType = getGlobalType("RegExp"); + jsxElementType = getExportedTypeFromNamespace("JSX", JsxNames.Element); + getGlobalClassDecoratorType = ts.memoize(function () { return getGlobalType("ClassDecorator"); }); + getGlobalPropertyDecoratorType = ts.memoize(function () { return getGlobalType("PropertyDecorator"); }); + getGlobalMethodDecoratorType = ts.memoize(function () { return getGlobalType("MethodDecorator"); }); + getGlobalParameterDecoratorType = ts.memoize(function () { return getGlobalType("ParameterDecorator"); }); getGlobalTypedPropertyDescriptorType = ts.memoize(function () { return getGlobalType("TypedPropertyDescriptor", 1); }); + getGlobalPromiseType = ts.memoize(function () { return getGlobalType("Promise", 1); }); + tryGetGlobalPromiseType = ts.memoize(function () { return getGlobalSymbol("Promise", 793056, undefined) && getGlobalPromiseType(); }); + getGlobalPromiseLikeType = ts.memoize(function () { return getGlobalType("PromiseLike", 1); }); + getInstantiatedGlobalPromiseLikeType = ts.memoize(createInstantiatedPromiseLikeType); + getGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Promise"); }); + getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); + getGlobalThenableType = ts.memoize(createThenableType); if (languageVersion >= 2) { globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray"); globalESSymbolType = getGlobalType("Symbol"); @@ -20134,6 +21329,23 @@ var ts; } anyArrayType = createArrayType(anyType); } + function createInstantiatedPromiseLikeType() { + var promiseLikeType = getGlobalPromiseLikeType(); + if (promiseLikeType !== emptyObjectType) { + return createTypeReference(promiseLikeType, [anyType]); + } + return emptyObjectType; + } + function createThenableType() { + var thenPropertySymbol = createSymbol(67108864 | 4, "then"); + getSymbolLinks(thenPropertySymbol).type = globalFunctionType; + var thenableType = createObjectType(65536); + thenableType.properties = [thenPropertySymbol]; + thenableType.members = createSymbolTable(thenableType.properties); + thenableType.callSignatures = []; + thenableType.constructSignatures = []; + return thenableType; + } function checkGrammarDecorators(node) { if (!node.decorators) { return false; @@ -20144,7 +21356,7 @@ var ts; else if (languageVersion < 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); } - else if (node.kind === 138 || node.kind === 139) { + else if (node.kind === 142 || node.kind === 143) { 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); @@ -20154,33 +21366,38 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 138: - case 139: - case 137: - case 134: - case 133: - case 136: - case 135: case 142: - case 208: - case 212: - case 211: + case 143: + case 141: + case 138: + case 137: + case 140: + case 139: + case 146: + case 215: + case 219: case 218: - case 217: - case 131: + case 225: + case 224: + case 135: break; - case 204: - case 205: - case 183: - case 203: - case 206: - if (node.modifiers && node.parent.kind !== 209 && node.parent.kind !== 230) { + case 210: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 115) && + node.parent.kind !== 216 && node.parent.kind !== 245) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 207: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 70) && - node.parent.kind !== 209 && node.parent.kind !== 230) { + case 211: + case 212: + case 190: + case 213: + if (node.modifiers && node.parent.kind !== 216 && node.parent.kind !== 245) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + break; + case 214: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 71) && + node.parent.kind !== 216 && node.parent.kind !== 245) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -20190,19 +21407,19 @@ var ts; if (!node.modifiers) { return; } - var lastStatic, lastPrivate, lastProtected, lastDeclare; + var lastStatic, lastPrivate, lastProtected, lastDeclare, lastAsync; var flags = 0; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; switch (modifier.kind) { + case 109: case 108: case 107: - case 106: var text = void 0; - if (modifier.kind === 108) { + if (modifier.kind === 109) { text = "public"; } - else if (modifier.kind === 107) { + else if (modifier.kind === 108) { text = "protected"; lastProtected = modifier; } @@ -20216,74 +21433,159 @@ var ts; else if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (node.parent.kind === 209 || node.parent.kind === 230) { + else if (flags & 512) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); + } + else if (node.parent.kind === 216 || node.parent.kind === 245) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } + else if (flags & 256) { + if (modifier.kind === 107) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); + } + else { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract"); + } + } flags |= ts.modifierToFlag(modifier.kind); break; - case 109: + case 110: if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (node.parent.kind === 209 || node.parent.kind === 230) { + else if (flags & 512) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); + } + else if (node.parent.kind === 216 || node.parent.kind === 245) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 131) { + else if (node.kind === 135) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } + else if (flags & 256) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); + } flags |= 128; lastStatic = modifier; break; - case 78: + case 79: if (flags & 1) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } else if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (node.parent.kind === 204) { + else if (flags & 256) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); + } + else if (flags & 512) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); + } + else if (node.parent.kind === 211) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 131) { + else if (node.kind === 135) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; break; - case 115: + case 119: if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (node.parent.kind === 204) { + else if (flags & 512) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); + } + else if (node.parent.kind === 211) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 131) { + else if (node.kind === 135) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 209) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 216) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; lastDeclare = modifier; break; + case 112: + if (flags & 256) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); + } + if (node.kind !== 211) { + if (node.kind !== 140) { + return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); + } + if (!(node.parent.kind === 211 && node.parent.flags & 256)) { + return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); + } + if (flags & 128) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); + } + if (flags & 32) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); + } + } + flags |= 256; + break; + case 115: + 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 === 135) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); + } + flags |= 512; + lastAsync = modifier; + break; } } - if (node.kind === 137) { + if (node.kind === 141) { if (flags & 128) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } + if (flags & 256) { + return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); + } else if (flags & 64) { return grammarErrorOnNode(lastProtected, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected"); } else if (flags & 32) { return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } + else if (flags & 512) { + return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); + } + return; } - else if ((node.kind === 212 || node.kind === 211) && flags & 2) { - return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare"); + else if ((node.kind === 219 || node.kind === 218) && flags & 2) { + return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 131 && (flags & 112) && ts.isBindingPattern(node.name)) { + else if (node.kind === 135 && (flags & 112) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } + if (flags & 512) { + return checkGrammarAsyncModifier(node, lastAsync); + } + } + function checkGrammarAsyncModifier(node, asyncModifier) { + if (languageVersion < 2) { + return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); + } + switch (node.kind) { + case 140: + case 210: + case 170: + case 171: + if (!node.asteriskToken) { + return false; + } + break; + } + return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); } function checkGrammarForDisallowedTrailingComma(list) { if (list && list.hasTrailingComma) { @@ -20344,7 +21646,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 166) { + if (node.kind === 171) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -20367,7 +21669,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); } - if (parameter.flags & 499) { + if (parameter.flags & 2035) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); } if (parameter.questionToken) { @@ -20379,7 +21681,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 !== 123 && parameter.type.kind !== 121) { + if (parameter.type.kind !== 127 && parameter.type.kind !== 125) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -20387,7 +21689,7 @@ var ts; } } function checkGrammarForIndexSignatureModifier(node) { - if (node.flags & 499) { + if (node.flags & 2035) { grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_not_permitted_on_index_signature_members); } } @@ -20406,20 +21708,20 @@ var ts; return checkGrammarForDisallowedTrailingComma(typeArguments) || checkGrammarForAtLeastOneTypeArgument(node, typeArguments); } - function checkGrammarForOmittedArgument(node, arguments) { - if (arguments) { + function checkGrammarForOmittedArgument(node, args) { + if (args) { var sourceFile = ts.getSourceFileOfNode(node); - for (var _i = 0; _i < arguments.length; _i++) { - var arg = arguments[_i]; - if (arg.kind === 178) { + for (var _i = 0; _i < args.length; _i++) { + var arg = args[_i]; + if (arg.kind === 184) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } } } - function checkGrammarArguments(node, arguments) { - return checkGrammarForDisallowedTrailingComma(arguments) || - checkGrammarForOmittedArgument(node, arguments); + function checkGrammarArguments(node, args) { + return checkGrammarForDisallowedTrailingComma(args) || + checkGrammarForOmittedArgument(node, args); } function checkGrammarHeritageClause(node) { var types = node.types; @@ -20438,7 +21740,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 === 79) { + if (heritageClause.token === 80) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -20451,7 +21753,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 102); + ts.Debug.assert(heritageClause.token === 103); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -20466,14 +21768,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 79) { + if (heritageClause.token === 80) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 102); + ts.Debug.assert(heritageClause.token === 103); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } checkGrammarHeritageClause(heritageClause); @@ -20482,19 +21784,19 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 129) { + if (node.kind !== 133) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 172 && computedPropertyName.expression.operatorToken.kind === 23) { + if (computedPropertyName.expression.kind === 178 && computedPropertyName.expression.operatorToken.kind === 23) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 203 || - node.kind === 165 || - node.kind === 136); + ts.Debug.assert(node.kind === 210 || + node.kind === 170 || + node.kind === 140); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -20519,76 +21821,97 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccesor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var name_15 = prop.name; - if (prop.kind === 178 || - name_15.kind === 129) { - checkGrammarComputedPropertyName(name_15); + var name_17 = prop.name; + if (prop.kind === 184 || + name_17.kind === 133) { + checkGrammarComputedPropertyName(name_17); continue; } var currentKind = void 0; - if (prop.kind === 227 || prop.kind === 228) { + if (prop.kind === 242 || prop.kind === 243) { checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_15.kind === 7) { - checkGrammarNumericLiteral(name_15); + if (name_17.kind === 7) { + checkGrammarNumericLiteral(name_17); } currentKind = Property; } - else if (prop.kind === 136) { + else if (prop.kind === 140) { currentKind = Property; } - else if (prop.kind === 138) { + else if (prop.kind === 142) { currentKind = GetAccessor; } - else if (prop.kind === 139) { + else if (prop.kind === 143) { currentKind = SetAccesor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - if (!ts.hasProperty(seen, name_15.text)) { - seen[name_15.text] = currentKind; + if (!ts.hasProperty(seen, name_17.text)) { + seen[name_17.text] = currentKind; } else { - var existingKind = seen[name_15.text]; + var existingKind = seen[name_17.text]; if (currentKind === Property && existingKind === Property) { continue; } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[name_15.text] = currentKind | existingKind; + seen[name_17.text] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_15, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_17, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_15, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_17, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } } + function checkGrammarJsxElement(node) { + var seen = {}; + for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { + var attr = _a[_i]; + if (attr.kind === 236) { + continue; + } + var jsxAttr = attr; + var name_18 = jsxAttr.name; + if (!ts.hasProperty(seen, name_18.text)) { + seen[name_18.text] = true; + } + else { + return grammarErrorOnNode(name_18, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + } + var initializer = jsxAttr.initializer; + if (initializer && initializer.kind === 237 && !initializer.expression) { + return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); + } + } + } function checkGrammarForInOrForOfStatement(forInOrOfStatement) { if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 202) { + if (forInOrOfStatement.initializer.kind === 209) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 190 + var diagnostic = forInOrOfStatement.kind === 197 ? 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 === 190 + var diagnostic = forInOrOfStatement.kind === 197 ? 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 === 190 + var diagnostic = forInOrOfStatement.kind === 197 ? 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); @@ -20611,10 +21934,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 138 && accessor.parameters.length) { + else if (kind === 142 && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 139) { + else if (kind === 143) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -20626,7 +21949,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); } - else if (parameter.flags & 499) { + else if (parameter.flags & 2035) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } else if (parameter.questionToken) { @@ -20639,17 +21962,17 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 129 && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 133 && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } function checkGrammarMethod(node) { - if (checkGrammarDisallowedModifiersInBlockOrObjectLiteralExpression(node) || + if (checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) || checkGrammarFunctionLikeDeclaration(node) || checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 157) { + if (node.parent.kind === 162) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -20668,22 +21991,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 === 205) { + else if (node.parent.kind === 212) { 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 === 148) { + else if (node.parent.kind === 152) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 189: - case 190: - case 191: - case 187: - case 188: - return true; + case 196: case 197: + case 198: + case 194: + case 195: + return true; + case 204: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -20695,9 +22018,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 197: + case 204: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 192 + var isMisplacedContinueLabel = node.kind === 199 && !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); @@ -20705,8 +22028,8 @@ var ts; return false; } break; - case 196: - if (node.kind === 193 && !node.label) { + case 203: + if (node.kind === 200 && !node.label) { return false; } break; @@ -20719,13 +22042,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 193 + var message = node.kind === 200 ? 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 === 193 + var message = node.kind === 200 ? 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); @@ -20737,7 +22060,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 === 154 || node.name.kind === 153) { + if (node.name.kind === 159 || node.name.kind === 158) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -20746,7 +22069,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 190 && node.parent.parent.kind !== 191) { + if (node.parent.parent.kind !== 197 && node.parent.parent.kind !== 198) { if (ts.isInAmbientContext(node)) { if (node.initializer) { var equalsTokenLength = "=".length; @@ -20766,7 +22089,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 65) { + if (name.kind === 66) { if (name.text === "let") { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } @@ -20775,7 +22098,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 178) { + if (element.kind !== 184) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -20792,15 +22115,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 186: - case 187: - case 188: + case 193: + case 194: case 195: - case 189: - case 190: - case 191: - return false; + case 202: + case 196: case 197: + case 198: + return false; + case 204: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -20816,9 +22139,9 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 170) { + if (expression.kind === 176) { var unaryExpression = expression; - if (unaryExpression.operator === 33 || unaryExpression.operator === 34) { + if (unaryExpression.operator === 34 || unaryExpression.operator === 35) { expression = unaryExpression.operand; } } @@ -20828,14 +22151,14 @@ var ts; return false; } function checkGrammarEnumDeclaration(enumDecl) { - var enumIsConst = (enumDecl.flags & 8192) !== 0; + 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 === 129) { + if (node.name.kind === 133) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else if (inAmbientContext) { @@ -20877,6 +22200,10 @@ var ts; return true; } } + function isEvalOrArgumentsIdentifier(node) { + return node.kind === 66 && + (node.text === "eval" || node.text === "arguments"); + } function checkGrammarConstructorTypeParameters(node) { if (node.typeParameters) { return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); @@ -20894,12 +22221,12 @@ var ts; return true; } } - else if (node.parent.kind === 205) { + else if (node.parent.kind === 212) { 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 === 148) { + else if (node.parent.kind === 152) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -20909,13 +22236,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 205 || - node.kind === 212 || - node.kind === 211 || + if (node.kind === 212 || + node.kind === 219 || node.kind === 218 || - node.kind === 217 || + node.kind === 225 || + node.kind === 224 || (node.flags & 2) || - (node.flags & (1 | 256))) { + (node.flags & (1 | 1024))) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); @@ -20923,7 +22250,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 === 183) { + if (ts.isDeclaration(decl) || decl.kind === 190) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -20942,7 +22269,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 === 182 || node.parent.kind === 209 || node.parent.kind === 230) { + if (node.parent.kind === 189 || node.parent.kind === 216 || node.parent.kind === 245) { 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); @@ -20953,7 +22280,7 @@ var ts; } } function checkGrammarNumericLiteral(node) { - if (node.flags & 16384 && languageVersion >= 1) { + if (node.flags & 65536 && languageVersion >= 1) { return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); } } @@ -20981,7 +22308,6 @@ var ts; function emitDeclarations(host, resolver, diagnostics, jsFilePath, root) { var newLine = host.getNewLine(); var compilerOptions = host.getCompilerOptions(); - var languageVersion = compilerOptions.target || 0; var write; var writeLine; var increaseIndent; @@ -21001,7 +22327,7 @@ var ts; var addedGlobalFileReference = false; ts.forEach(root.referencedFiles, function (fileReference) { var referencedFile = ts.tryResolveScriptReference(host, root, fileReference); - if (referencedFile && ((referencedFile.flags & 2048) || + if (referencedFile && ((referencedFile.flags & 8192) || ts.shouldEmitToOwnFile(referencedFile, compilerOptions) || !addedGlobalFileReference)) { writeReferencePath(referencedFile); @@ -21016,7 +22342,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 212); + ts.Debug.assert(aliasEmitInfo.node.kind === 219); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -21089,10 +22415,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 201) { + if (declaration.kind === 208) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 215 || declaration.kind === 216 || declaration.kind === 213) { + else if (declaration.kind === 222 || declaration.kind === 223 || declaration.kind === 220) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -21103,7 +22429,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 212) { + if (moduleElementEmitInfo.node.kind === 219) { moduleElementEmitInfo.isVisible = true; } else { @@ -21111,12 +22437,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 208) { + if (nodeToCheck.kind === 215) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 208) { + if (nodeToCheck.kind === 215) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -21203,58 +22529,62 @@ var ts; } function emitType(type) { switch (type.kind) { - case 112: - case 123: - case 121: - case 113: - case 124: - case 99: + case 114: + case 127: + case 125: + case 117: + case 128: + case 100: case 8: return writeTextOfNode(currentSourceFile, type); - case 179: + case 185: return emitExpressionWithTypeArguments(type); - case 144: - return emitTypeReference(type); - case 147: - return emitTypeQuery(type); - case 149: - return emitArrayType(type); - case 150: - return emitTupleType(type); - case 151: - return emitUnionType(type); - case 152: - return emitParenType(type); - case 145: - case 146: - return emitSignatureDeclarationWithJsDocComments(type); case 148: + return emitTypeReference(type); + case 151: + return emitTypeQuery(type); + case 153: + return emitArrayType(type); + case 154: + return emitTupleType(type); + case 155: + return emitUnionType(type); + case 156: + return emitIntersectionType(type); + case 157: + return emitParenType(type); + case 149: + case 150: + return emitSignatureDeclarationWithJsDocComments(type); + case 152: return emitTypeLiteral(type); - case 65: + case 66: return emitEntityName(type); - case 128: + case 132: return emitEntityName(type); + case 147: + return emitTypePredicate(type); + } + function writeEntityName(entityName) { + if (entityName.kind === 66) { + writeTextOfNode(currentSourceFile, entityName); + } + else { + var left = entityName.kind === 132 ? entityName.left : entityName.expression; + var right = entityName.kind === 132 ? entityName.right : entityName.name; + writeEntityName(left); + write("."); + writeTextOfNode(currentSourceFile, right); + } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 211 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 218 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); - function writeEntityName(entityName) { - if (entityName.kind === 65) { - writeTextOfNode(currentSourceFile, entityName); - } - else { - var left = entityName.kind === 128 ? entityName.left : entityName.expression; - var right = entityName.kind === 128 ? entityName.right : entityName.name; - writeEntityName(left); - write("."); - writeTextOfNode(currentSourceFile, right); - } - } } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 65 || node.expression.kind === 158); + ts.Debug.assert(node.expression.kind === 66 || node.expression.kind === 163); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -21271,6 +22601,11 @@ var ts; write(">"); } } + function emitTypePredicate(type) { + writeTextOfNode(currentSourceFile, type.parameterName); + write(" is "); + emitType(type.type); + } function emitTypeQuery(type) { write("typeof "); emitEntityName(type.exprName); @@ -21287,6 +22622,9 @@ var ts; function emitUnionType(type) { emitSeparatedList(type.types, " | ", emitType); } + function emitIntersectionType(type) { + emitSeparatedList(type.types, " & ", emitType); + } function emitParenType(type) { write("("); emitType(type.type); @@ -21315,14 +22653,14 @@ var ts; } var count = 0; while (true) { - var name_16 = baseName + "_" + (++count); - if (!ts.hasProperty(currentSourceFile.identifiers, name_16)) { - return name_16; + var name_19 = baseName + "_" + (++count); + if (!ts.hasProperty(currentSourceFile.identifiers, name_19)) { + return name_19; } } } function emitExportAssignment(node) { - if (node.expression.kind === 65) { + if (node.expression.kind === 66) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentSourceFile, node.expression); } @@ -21340,7 +22678,7 @@ var ts; } write(";"); writeLine(); - if (node.expression.kind === 65) { + if (node.expression.kind === 66) { var nodes = resolver.collectLinkedAliases(node.expression); writeAsynchronousModuleElements(nodes); } @@ -21358,10 +22696,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 211 || - (node.parent.kind === 230 && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 218 || + (node.parent.kind === 245 && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 230) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 245) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -21370,7 +22708,7 @@ var ts; }); } else { - if (node.kind === 212) { + if (node.kind === 219) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -21388,23 +22726,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 203: + case 210: return writeFunctionDeclaration(node); - case 183: + case 190: return writeVariableStatement(node); - case 205: - return writeInterfaceDeclaration(node); - case 204: - return writeClassDeclaration(node); - case 206: - return writeTypeAliasDeclaration(node); - case 207: - return writeEnumDeclaration(node); - case 208: - return writeModuleDeclaration(node); - case 211: - return writeImportEqualsDeclaration(node); case 212: + return writeInterfaceDeclaration(node); + case 211: + return writeClassDeclaration(node); + case 213: + return writeTypeAliasDeclaration(node); + case 214: + return writeEnumDeclaration(node); + case 215: + return writeModuleDeclaration(node); + case 218: + return writeImportEqualsDeclaration(node); + case 219: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -21415,10 +22753,10 @@ var ts; if (node.flags & 1) { write("export "); } - if (node.flags & 256) { + if (node.flags & 1024) { write("default "); } - else if (node.kind !== 205) { + else if (node.kind !== 212) { write("declare "); } } @@ -21433,6 +22771,9 @@ var ts; if (node.flags & 128) { write("static "); } + if (node.flags & 256) { + write("abstract "); + } } function writeImportEqualsDeclaration(node) { emitJsDocComments(node); @@ -21462,7 +22803,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 214) { + if (namedBindings.kind === 221) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -21488,7 +22829,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 214) { + if (node.importClause.namedBindings.kind === 221) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -21537,14 +22878,14 @@ var ts; function writeModuleDeclaration(node) { emitJsDocComments(node); emitModuleElementDeclarationFlags(node); - if (node.flags & 32768) { + if (node.flags & 131072) { write("namespace "); } else { write("module "); } writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 209) { + while (node.body.kind !== 216) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -21605,7 +22946,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 136 && (node.parent.flags & 32); + return node.parent.kind === 140 && (node.parent.flags & 32); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -21615,15 +22956,15 @@ var ts; writeTextOfNode(currentSourceFile, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 145 || - node.parent.kind === 146 || - (node.parent.parent && node.parent.parent.kind === 148)) { - ts.Debug.assert(node.parent.kind === 136 || - node.parent.kind === 135 || - node.parent.kind === 145 || - node.parent.kind === 146 || - node.parent.kind === 140 || - node.parent.kind === 141); + if (node.parent.kind === 149 || + node.parent.kind === 150 || + (node.parent.parent && node.parent.parent.kind === 152)) { + ts.Debug.assert(node.parent.kind === 140 || + node.parent.kind === 139 || + node.parent.kind === 149 || + node.parent.kind === 150 || + node.parent.kind === 144 || + node.parent.kind === 145); emitType(node.constraint); } else { @@ -21633,31 +22974,31 @@ var ts; function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 204: + case 211: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 205: + case 212: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 141: + case 145: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 140: + case 144: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 136: - case 135: + case 140: + case 139: 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 === 204) { + else if (node.parent.parent.kind === 211) { 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 203: + case 210: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -21687,7 +23028,7 @@ var ts; } function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.parent.parent.kind === 204) { + if (node.parent.parent.kind === 211) { 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; @@ -21715,6 +23056,9 @@ var ts; } emitJsDocComments(node); emitModuleElementDeclarationFlags(node); + if (node.flags & 256) { + write("abstract "); + } write("class "); writeTextOfNode(currentSourceFile, node.name); var prevEnclosingDeclaration = enclosingDeclaration; @@ -21764,16 +23108,16 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 201 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 208 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentSourceFile, node.name); - if ((node.kind === 134 || node.kind === 133) && ts.hasQuestionToken(node)) { + if ((node.kind === 138 || node.kind === 137) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 134 || node.kind === 133) && node.parent.kind === 148) { + if ((node.kind === 138 || node.kind === 137) && node.parent.kind === 152) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32)) { @@ -21782,14 +23126,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 201) { + if (node.kind === 208) { 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 === 134 || node.kind === 133) { + else if (node.kind === 138 || node.kind === 137) { if (node.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -21797,7 +23141,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 === 204) { + else if (node.parent.kind === 211) { 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 : @@ -21823,7 +23167,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 178) { + if (element.kind !== 184) { elements.push(element); } } @@ -21889,7 +23233,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 138 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 142 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -21902,7 +23246,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 138 + return accessor.kind === 142 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -21911,7 +23255,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 139) { + if (accessorWithTypeAnnotation.kind === 143) { 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 : @@ -21957,17 +23301,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 203) { + if (node.kind === 210) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 136) { + else if (node.kind === 140) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 203) { + if (node.kind === 210) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 137) { + else if (node.kind === 141) { write("constructor"); } else { @@ -21984,11 +23328,11 @@ var ts; emitSignatureDeclaration(node); } function emitSignatureDeclaration(node) { - if (node.kind === 141 || node.kind === 146) { + if (node.kind === 145 || node.kind === 150) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 142) { + if (node.kind === 146) { write("["); } else { @@ -21997,20 +23341,20 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 142) { + if (node.kind === 146) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 145 || node.kind === 146; - if (isFunctionTypeOrConstructorType || node.parent.kind === 148) { + var isFunctionTypeOrConstructorType = node.kind === 149 || node.kind === 150; + if (isFunctionTypeOrConstructorType || node.parent.kind === 152) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 137 && !(node.flags & 32)) { + else if (node.kind !== 141 && !(node.flags & 32)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -22021,23 +23365,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 141: + case 145: 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 140: + case 144: 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 142: + case 146: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 136: - case 135: + case 140: + case 139: if (node.flags & 128) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -22045,7 +23389,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 === 204) { + else if (node.parent.kind === 211) { 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 : @@ -22058,7 +23402,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 203: + case 210: 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 : @@ -22090,9 +23434,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 145 || - node.parent.kind === 146 || - node.parent.parent.kind === 148) { + if (node.parent.kind === 149 || + node.parent.kind === 150 || + node.parent.parent.kind === 152) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32)) { @@ -22108,22 +23452,22 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 137: + case 141: 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 141: + case 145: 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 140: + case 144: return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 136: - case 135: + case 140: + case 139: if (node.parent.flags & 128) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 ? @@ -22131,7 +23475,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 === 204) { + else if (node.parent.parent.kind === 211) { 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 : @@ -22143,7 +23487,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 203: + case 210: 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 : @@ -22154,12 +23498,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 153) { + if (bindingPattern.kind === 158) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 154) { + else if (bindingPattern.kind === 159) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -22178,10 +23522,10 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 178) { + if (bindingElement.kind === 184) { write(" "); } - else if (bindingElement.kind === 155) { + else if (bindingElement.kind === 160) { if (bindingElement.propertyName) { writeTextOfNode(currentSourceFile, bindingElement.propertyName); write(": "); @@ -22192,7 +23536,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 65); + ts.Debug.assert(bindingElement.name.kind === 66); if (bindingElement.dotDotDotToken) { write("..."); } @@ -22204,44 +23548,44 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 203: - case 208: - case 211: - case 205: - case 204: - case 206: - case 207: - return emitModuleElement(node, isModuleElementVisible(node)); - case 183: - return emitModuleElement(node, isVariableStatementVisible(node)); - case 212: - return emitModuleElement(node, !node.importClause); + case 210: + case 215: case 218: + case 212: + case 211: + case 213: + case 214: + return emitModuleElement(node, isModuleElementVisible(node)); + case 190: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 219: + return emitModuleElement(node, !node.importClause); + case 225: return emitExportDeclaration(node); - case 137: - case 136: - case 135: - return writeFunctionDeclaration(node); case 141: case 140: - case 142: - return emitSignatureDeclarationWithJsDocComments(node); - case 138: case 139: + return writeFunctionDeclaration(node); + case 145: + case 144: + case 146: + return emitSignatureDeclarationWithJsDocComments(node); + case 142: + case 143: return emitAccessorDeclaration(node); - case 134: - case 133: + case 138: + case 137: return emitPropertyDeclaration(node); - case 229: + case 244: return emitEnumMemberDeclaration(node); - case 217: + case 224: return emitExportAssignment(node); - case 230: + case 245: return emitSourceFile(node); } } function writeReferencePath(referencedFile) { - var declFileName = referencedFile.flags & 2048 + var declFileName = referencedFile.flags & 8192 ? referencedFile.fileName : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") @@ -22286,15 +23630,18 @@ var ts; 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, ".js"); + var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js"); emitFile(jsFilePath, sourceFile); } }); @@ -22304,7 +23651,7 @@ var ts; } else { if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ts.forEach(host.getSourceFiles(), shouldEmitJsx) ? ".jsx" : ".js"); emitFile(jsFilePath, targetSourceFile); } else if (!ts.isDeclarationFile(targetSourceFile) && compilerOptions.out) { @@ -22350,6 +23697,7 @@ var ts; var extendsEmitted = false; var decorateEmitted = false; var paramEmitted = false; + var awaiterEmitted = false; var tempFlags = 0; var tempVariables; var tempParameters; @@ -22395,19 +23743,19 @@ var ts; } function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name = flags === 268435456 ? "_i" : "_n"; - if (isUniqueName(name)) { + var name_20 = flags === 268435456 ? "_i" : "_n"; + if (isUniqueName(name_20)) { tempFlags |= flags; - return name; + return name_20; } } while (true) { var count = tempFlags & 268435455; tempFlags++; if (count !== 8 && count !== 13) { - var name_17 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); - if (isUniqueName(name_17)) { - return name_17; + var name_21 = count < 26 ? "_" + String.fromCharCode(97 + count) : "_" + (count - 26); + if (isUniqueName(name_21)) { + return name_21; } } } @@ -22443,19 +23791,19 @@ var ts; } function generateNameForNode(node) { switch (node.kind) { - case 65: + case 66: return makeUniqueName(node.text); - case 208: - case 207: + case 215: + case 214: return generateNameForModuleOrEnum(node); - case 212: - case 218: + case 219: + case 225: return generateNameForImportOrExportDeclaration(node); - case 203: - case 204: - case 217: + case 210: + case 211: + case 224: return generateNameForExportDefault(); - case 177: + case 183: return generateNameForClassExpression(); } } @@ -22593,8 +23941,8 @@ var ts; if (scopeName) { var parentIndex = getSourceMapNameIndex(); if (parentIndex !== -1) { - var name_18 = node.name; - if (!name_18 || name_18.kind !== 129) { + var name_22 = node.name; + if (!name_22 || name_22.kind !== 133) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -22611,19 +23959,19 @@ var ts; if (scopeName) { recordScopeNameStart(scopeName); } - else if (node.kind === 203 || - node.kind === 165 || - node.kind === 136 || - node.kind === 135 || - node.kind === 138 || + else if (node.kind === 210 || + node.kind === 170 || + node.kind === 140 || node.kind === 139 || - node.kind === 208 || - node.kind === 204 || - node.kind === 207) { + node.kind === 142 || + node.kind === 143 || + node.kind === 215 || + node.kind === 211 || + node.kind === 214) { if (node.name) { - var name_19 = node.name; - scopeName = name_19.kind === 129 - ? ts.getTextOfNode(name_19) + var name_23 = node.name; + scopeName = name_23.kind === 133 + ? ts.getTextOfNode(name_23) : node.name.text; } recordScopeNameStart(scopeName); @@ -22643,7 +23991,7 @@ var ts; } function serializeSourceMapContents(version, file, sourceRoot, sources, names, mappings, sourcesContent) { if (typeof JSON !== "undefined") { - var map_1 = { + var map_2 = { version: version, file: file, sourceRoot: sourceRoot, @@ -22652,9 +24000,9 @@ var ts; mappings: mappings }; if (sourcesContent !== undefined) { - map_1.sourcesContent = sourcesContent; + map_2.sourcesContent = sourcesContent; } - return JSON.stringify(map_1); + return JSON.stringify(map_2); } 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) { @@ -22721,7 +24069,7 @@ var ts; if (ts.nodeIsSynthesized(node)) { return emitNodeWithoutSourceMap(node); } - if (node.kind !== 230) { + if (node.kind !== 245) { recordEmitNodeStartSpan(node); emitNodeWithoutSourceMap(node); recordEmitNodeEndSpan(node); @@ -22745,7 +24093,7 @@ var ts; ts.writeFile(host, diagnostics, jsFilePath, emitOutput, writeByteOrderMark); } function createTempVariable(flags) { - var result = ts.createSynthesizedNode(65); + var result = ts.createSynthesizedNode(66); result.text = makeTempVariableName(flags); return result; } @@ -22966,10 +24314,10 @@ var ts; emitParenthesizedIf(node.tag, needsParenthesisForPropertyAccessOrInvocation(node.tag)); write("("); emit(tempVariable); - if (node.template.kind === 174) { + if (node.template.kind === 180) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 172 + var needsParens = templateSpan.expression.kind === 178 && templateSpan.expression.operatorToken.kind === 23; emitParenthesizedIf(templateSpan.expression, needsParens); }); @@ -22993,7 +24341,7 @@ var ts; } for (var i = 0, n = node.templateSpans.length; i < n; i++) { var templateSpan = node.templateSpans[i]; - var needsParens = templateSpan.expression.kind !== 164 + var needsParens = templateSpan.expression.kind !== 169 && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1; if (i > 0 || headEmitted) { write(" + "); @@ -23026,11 +24374,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 160: - case 161: + case 165: + case 166: return parent.expression === template; - case 162: - case 164: + case 167: + case 169: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1; @@ -23038,20 +24386,20 @@ var ts; } function comparePrecedenceToBinaryPlus(expression) { switch (expression.kind) { - case 172: + case 178: switch (expression.operatorToken.kind) { - case 35: case 36: case 37: + case 38: return 1; - case 33: case 34: + case 35: return 0; default: return -1; } - case 175: - case 173: + case 181: + case 179: return -1; default: return 1; @@ -23062,12 +24410,189 @@ var ts; emit(span.expression); emit(span.literal); } + function jsxEmitReact(node) { + function emitTagName(name) { + if (name.kind === 66 && 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) { + emitLeadingComments(openingNode); + write("React.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 === 236; })) { + write("React.__spread("); + var haveOpenedObjectLiteral = false; + for (var i_2 = 0; i_2 < attrs.length; i_2++) { + if (attrs[i_2].kind === 236) { + if (i_2 === 0) { + write("{}, "); + } + if (haveOpenedObjectLiteral) { + write("}"); + haveOpenedObjectLiteral = false; + } + if (i_2 > 0) { + write(", "); + } + emit(attrs[i_2].expression); + } + else { + ts.Debug.assert(attrs[i_2].kind === 235); + if (haveOpenedObjectLiteral) { + write(", "); + } + else { + haveOpenedObjectLiteral = true; + if (i_2 > 0) { + write(", "); + } + write("{"); + } + emitJsxAttribute(attrs[i_2]); + } + } + 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 === 237 && !(children[i].expression)) { + continue; + } + if (children[i].kind === 233) { + var text = getTextToEmit(children[i]); + if (text !== undefined) { + write(', "'); + write(text); + write('"'); + } + } + else { + write(", "); + emit(children[i]); + } + } + } + write(")"); + emitTrailingComments(openingNode); + } + if (node.kind === 230) { + emitJsxElement(node.openingElement, node.children); + } + else { + ts.Debug.assert(node.kind === 231); + emitJsxElement(node); + } + } + function jsxEmitPreserve(node) { + function emitJsxAttribute(node) { + emit(node.name); + 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 === 236) { + emitJsxSpreadAttribute(attribs[i]); + } + else { + ts.Debug.assert(attribs[i].kind === 235); + emitJsxAttribute(attribs[i]); + } + } + } + function emitJsxOpeningOrSelfClosingElement(node) { + write("<"); + emit(node.tagName); + if (node.attributes.length > 0 || (node.kind === 231)) { + write(" "); + } + emitAttributes(node.attributes); + if (node.kind === 231) { + 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 === 230) { + emitJsxElement(node); + } + else { + ts.Debug.assert(node.kind === 231); + emitJsxOpeningOrSelfClosingElement(node); + } + } function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 155); + ts.Debug.assert(node.kind !== 160); if (node.kind === 8) { emitLiteral(node); } - else if (node.kind === 129) { + else if (node.kind === 133) { if (ts.nodeIsDecorated(node.parent)) { if (!computedPropertyNamesToGeneratedNames) { computedPropertyNamesToGeneratedNames = []; @@ -23098,64 +24623,70 @@ var ts; function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 156: + case 161: + case 178: + case 165: + case 238: + case 133: + case 179: + case 136: case 172: - case 160: - case 223: - case 129: - case 173: - case 132: + case 194: + case 164: + case 224: + case 192: + case 185: + case 196: + case 197: + case 198: + case 193: + case 231: + case 232: + case 166: + case 169: + case 177: + case 176: + case 201: + case 243: + case 182: + case 203: case 167: case 187: - case 159: - case 217: - case 185: - case 179: - case 189: - case 190: - case 191: - case 186: - case 161: - case 164: + case 205: + case 168: + case 173: + case 174: + case 195: + case 202: + case 181: + return true; + case 160: + case 244: + case 135: + case 242: + case 138: + case 208: + return parent.initializer === node; + case 163: + return parent.expression === node; case 171: case 170: - case 194: - case 228: - case 176: - case 196: - case 162: - case 180: - case 198: - case 163: - case 168: - case 169: - case 188: - case 195: - case 175: - return true; - case 155: - case 229: - case 131: - case 227: - case 134: - case 201: - return parent.initializer === node; - case 158: - return parent.expression === node; - case 166: - case 165: return parent.body === node; - case 211: + case 218: return parent.moduleReference === node; - case 128: + case 132: 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 === 230) { + if (container.kind === 245) { if (languageVersion < 2 && compilerOptions.module !== 4) { write("exports."); } @@ -23168,12 +24699,12 @@ var ts; else if (languageVersion < 2) { var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { - if (declaration.kind === 213) { + if (declaration.kind === 220) { write(getGeneratedNameForNode(declaration.parent)); write(languageVersion === 0 ? '["default"]' : ".default"); return; } - else if (declaration.kind === 216) { + else if (declaration.kind === 223) { write(getGeneratedNameForNode(declaration.parent.parent.parent)); write("."); writeTextOfNode(currentSourceFile, declaration.propertyName || declaration.name); @@ -23192,10 +24723,10 @@ var ts; if (languageVersion < 2) { var parent_7 = node.parent; switch (parent_7.kind) { - case 155: - case 204: - case 207: - case 201: + case 160: + case 211: + case 214: + case 208: return parent_7.name === node && resolver.isNestedRedeclaration(parent_7); } } @@ -23229,7 +24760,7 @@ var ts; } else { var flags = resolver.getNodeCheckFlags(node); - if (flags & 16) { + if (flags & 256) { write("_super.prototype"); } else { @@ -23270,7 +24801,7 @@ var ts; emit(node.expression); } function emitYieldExpression(node) { - write(ts.tokenToString(110)); + write(ts.tokenToString(111)); if (node.asteriskToken) { write("*"); } @@ -23279,14 +24810,35 @@ var ts; emit(node.expression); } } + function emitAwaitExpression(node) { + var needsParenthesis = needsParenthesisForAwaitExpressionAsYield(node); + if (needsParenthesis) { + write("("); + } + write(ts.tokenToString(111)); + write(" "); + emit(node.expression); + if (needsParenthesis) { + write(")"); + } + } + function needsParenthesisForAwaitExpressionAsYield(node) { + if (node.parent.kind === 178 && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + return true; + } + else if (node.parent.kind === 179 && node.parent.condition === node) { + return true; + } + return false; + } function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { - case 65: - case 156: - case 158: - case 159: - case 160: + case 66: + case 161: + case 163: case 164: + case 165: + case 169: return false; } return true; @@ -23303,17 +24855,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 176) { + if (e.kind === 182) { e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 156) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 161) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 176) { + while (i < length && elements[i].kind !== 182) { i++; } write("["); @@ -23336,7 +24888,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 176; + return node.kind === 182; } function emitArrayLiteral(node) { var elements = node.elements; @@ -23349,7 +24901,7 @@ var ts; write("]"); } else { - emitListWithSpread(elements, true, (node.flags & 512) !== 0, elements.hasTrailingComma, true); + emitListWithSpread(elements, true, (node.flags & 2048) !== 0, elements.hasTrailingComma, true); } } function emitObjectLiteralBody(node, numElements) { @@ -23364,7 +24916,7 @@ var ts; emitLinePreservingList(node, properties, languageVersion >= 1, true); } else { - var multiLine = (node.flags & 512) !== 0; + var multiLine = (node.flags & 2048) !== 0; if (!multiLine) { write(" "); } @@ -23383,7 +24935,7 @@ var ts; write("}"); } function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { - var multiLine = (node.flags & 512) !== 0; + var multiLine = (node.flags & 2048) !== 0; var properties = node.properties; write("("); if (multiLine) { @@ -23397,7 +24949,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 138 || property.kind === 139) { + if (property.kind === 142 || property.kind === 143) { var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { continue; @@ -23448,13 +25000,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 227) { + if (property.kind === 242) { emit(property.initializer); } - else if (property.kind === 228) { + else if (property.kind === 243) { emitExpressionIdentifier(property.name); } - else if (property.kind === 136) { + else if (property.kind === 140) { emitFunctionDeclaration(property); } else { @@ -23486,7 +25038,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 === 129) { + if (properties[i].name.kind === 133) { numInitialNonComputedProperties = i; break; } @@ -23500,35 +25052,35 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(172, startsOnNewLine); + var result = ts.createSynthesizedNode(178, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(158); + var result = ts.createSynthesizedNode(163); result.expression = parenthesizeForAccess(expression); result.dotToken = ts.createSynthesizedNode(20); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(159); + var result = ts.createSynthesizedNode(164); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; } function parenthesizeForAccess(expr) { - while (expr.kind === 163) { + while (expr.kind === 168 || expr.kind === 186) { expr = expr.expression; } if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 161 && + expr.kind !== 166 && expr.kind !== 7) { return expr; } - var node = ts.createSynthesizedNode(164); + var node = ts.createSynthesizedNode(169); node.expression = expr; return node; } @@ -23554,7 +25106,7 @@ var ts; } function isNamespaceExportReference(node) { var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 230; + return container && container.kind !== 245; } function emitShorthandPropertyAssignment(node) { writeTextOfNode(currentSourceFile, node.name); @@ -23571,7 +25123,7 @@ var ts; if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 158 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 163 ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; @@ -23599,7 +25151,17 @@ var ts; } emit(node.expression); var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); - write("."); + var shouldEmitSpace; + if (!indentedBeforeDot && node.expression.kind === 7) { + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); + shouldEmitSpace = text.indexOf(ts.tokenToString(20)) < 0; + } + if (shouldEmitSpace) { + write(" ."); + } + else { + write("."); + } var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); emit(node.name); decreaseIndentIf(indentedBeforeDot, indentedAfterDot); @@ -23609,6 +25171,40 @@ var ts; write("."); emit(node.right); } + function emitQualifiedNameAsExpression(node, useFallback) { + if (node.left.kind === 66) { + 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("."); + emitNodeWithoutSourceMap(node.right); + } + function emitEntityNameAsExpression(node, useFallback) { + switch (node.kind) { + case 66: + if (useFallback) { + write("typeof "); + emitExpressionIdentifier(node); + write(" !== 'undefined' && "); + } + emitExpressionIdentifier(node); + break; + case 132: + emitQualifiedNameAsExpression(node, useFallback); + break; + } + } function emitIndexedAccess(node) { if (tryEmitConstantValue(node)) { return; @@ -23619,16 +25215,16 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 176; }); + return ts.forEach(elements, function (e) { return e.kind === 182; }); } function skipParentheses(node) { - while (node.kind === 164 || node.kind === 163) { + while (node.kind === 169 || node.kind === 168 || node.kind === 186) { node = node.expression; } return node; } function emitCallTarget(node) { - if (node.kind === 65 || node.kind === 93 || node.kind === 91) { + if (node.kind === 66 || node.kind === 94 || node.kind === 92) { emit(node); return node; } @@ -23643,18 +25239,18 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 158) { + if (expr.kind === 163) { target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 159) { + else if (expr.kind === 164) { target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); write("]"); } - else if (expr.kind === 91) { + else if (expr.kind === 92) { target = expr; write("_super"); } @@ -23663,7 +25259,7 @@ var ts; } write(".apply("); if (target) { - if (target.kind === 91) { + if (target.kind === 92) { emitThis(target); } else { @@ -23683,13 +25279,13 @@ var ts; return; } var superCall = false; - if (node.expression.kind === 91) { + if (node.expression.kind === 92) { emitSuper(node.expression); superCall = true; } else { emit(node.expression); - superCall = node.expression.kind === 158 && node.expression.expression.kind === 91; + superCall = node.expression.kind === 163 && node.expression.expression.kind === 92; } if (superCall && languageVersion < 2) { write(".call("); @@ -23740,20 +25336,20 @@ var ts; } } function emitParenExpression(node) { - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 166) { - if (node.expression.kind === 163) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 171) { + if (node.expression.kind === 168 || node.expression.kind === 186) { var operand = node.expression.expression; - while (operand.kind === 163) { + while (operand.kind === 168 || operand.kind === 186) { operand = operand.expression; } - if (operand.kind !== 170 && - operand.kind !== 169 && - operand.kind !== 168 && - operand.kind !== 167 && - operand.kind !== 171 && - operand.kind !== 161 && - !(operand.kind === 160 && node.parent.kind === 161) && - !(operand.kind === 165 && node.parent.kind === 160)) { + if (operand.kind !== 176 && + operand.kind !== 174 && + operand.kind !== 173 && + operand.kind !== 172 && + operand.kind !== 177 && + operand.kind !== 166 && + !(operand.kind === 165 && node.parent.kind === 166) && + !(operand.kind === 170 && node.parent.kind === 165)) { emit(operand); return; } @@ -23764,25 +25360,25 @@ var ts; write(")"); } function emitDeleteExpression(node) { - write(ts.tokenToString(74)); + write(ts.tokenToString(75)); write(" "); emit(node.expression); } function emitVoidExpression(node) { - write(ts.tokenToString(99)); + write(ts.tokenToString(100)); write(" "); emit(node.expression); } function emitTypeOfExpression(node) { - write(ts.tokenToString(97)); + write(ts.tokenToString(98)); write(" "); emit(node.expression); } function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { - if (!isCurrentFileSystemExternalModule() || node.kind !== 65 || ts.nodeIsSynthesized(node)) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 66 || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 201 || node.parent.kind === 155); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 208 || node.parent.kind === 160); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); @@ -23796,12 +25392,12 @@ var ts; write("\", "); } write(ts.tokenToString(node.operator)); - if (node.operand.kind === 170) { + if (node.operand.kind === 176) { var operand = node.operand; - if (node.operator === 33 && (operand.operator === 33 || operand.operator === 38)) { + if (node.operator === 34 && (operand.operator === 34 || operand.operator === 39)) { write(" "); } - else if (node.operator === 34 && (operand.operator === 34 || operand.operator === 39)) { + else if (node.operator === 35 && (operand.operator === 35 || operand.operator === 40)) { write(" "); } } @@ -23818,7 +25414,7 @@ var ts; write("\", "); write(ts.tokenToString(node.operator)); emit(node.operand); - if (node.operator === 38) { + if (node.operator === 39) { write(") - 1)"); } else { @@ -23839,10 +25435,10 @@ var ts; } var current = node; while (current) { - if (current.kind === 230) { + if (current.kind === 245) { return !isExported || ((ts.getCombinedNodeFlags(node) & 1) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 209) { + else if (ts.isFunctionLike(current) || current.kind === 216) { return false; } else { @@ -23851,13 +25447,13 @@ var ts; } } function emitBinaryExpression(node) { - if (languageVersion < 2 && node.operatorToken.kind === 53 && - (node.left.kind === 157 || node.left.kind === 156)) { - emitDestructuring(node, node.parent.kind === 185); + if (languageVersion < 2 && node.operatorToken.kind === 54 && + (node.left.kind === 162 || node.left.kind === 161)) { + emitDestructuring(node, node.parent.kind === 192); } else { - var exportChanged = node.operatorToken.kind >= 53 && - node.operatorToken.kind <= 64 && + var exportChanged = node.operatorToken.kind >= 54 && + node.operatorToken.kind <= 65 && isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); if (exportChanged) { write(exportFunctionForFile + "(\""); @@ -23900,7 +25496,7 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 182) { + if (node && node.kind === 189) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } @@ -23915,12 +25511,12 @@ var ts; emitToken(14, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 209) { - ts.Debug.assert(node.parent.kind === 208); + if (node.kind === 216) { + ts.Debug.assert(node.parent.kind === 215); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 209) { + if (node.kind === 216) { emitTempDeclarations(true); } decreaseIndent(); @@ -23929,7 +25525,7 @@ var ts; scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 182) { + if (node.kind === 189) { write(" "); emit(node); } @@ -23941,11 +25537,11 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 166); + emitParenthesizedIf(node.expression, node.expression.kind === 171); write(";"); } function emitIfStatement(node) { - var endPos = emitToken(84, node.pos); + var endPos = emitToken(85, node.pos); write(" "); endPos = emitToken(16, endPos); emit(node.expression); @@ -23953,8 +25549,8 @@ var ts; emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - emitToken(76, node.thenStatement.end); - if (node.elseStatement.kind === 186) { + emitToken(77, node.thenStatement.end); + if (node.elseStatement.kind === 193) { write(" "); emit(node.elseStatement); } @@ -23966,7 +25562,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 182) { + if (node.statement.kind === 189) { write(" "); } else { @@ -23986,13 +25582,13 @@ var ts; if (shouldHoistVariable(decl, true)) { return false; } - var tokenKind = 98; + var tokenKind = 99; if (decl && languageVersion >= 2) { if (ts.isLet(decl)) { - tokenKind = 104; + tokenKind = 105; } else if (ts.isConst(decl)) { - tokenKind = 70; + tokenKind = 71; } } if (startPos !== undefined) { @@ -24001,13 +25597,13 @@ var ts; } else { switch (tokenKind) { - case 98: + case 99: write("var "); break; - case 104: + case 105: write("let "); break; - case 70: + case 71: write("const "); break; } @@ -24032,10 +25628,10 @@ var ts; return started; } function emitForStatement(node) { - var endPos = emitToken(82, node.pos); + var endPos = emitToken(83, node.pos); write(" "); endPos = emitToken(16, endPos); - if (node.initializer && node.initializer.kind === 202) { + if (node.initializer && node.initializer.kind === 209) { var variableDeclarationList = node.initializer; var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); if (startIsEmitted) { @@ -24056,13 +25652,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 && node.kind === 191) { + if (languageVersion < 2 && node.kind === 198) { return emitDownLevelForOfStatement(node); } - var endPos = emitToken(82, node.pos); + var endPos = emitToken(83, node.pos); write(" "); endPos = emitToken(16, endPos); - if (node.initializer.kind === 202) { + if (node.initializer.kind === 209) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); @@ -24072,7 +25668,7 @@ var ts; else { emit(node.initializer); } - if (node.kind === 190) { + if (node.kind === 197) { write(" in "); } else { @@ -24103,10 +25699,10 @@ var ts; // 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(82, node.pos); + var endPos = emitToken(83, node.pos); write(" "); endPos = emitToken(16, endPos); - var rhsIsIdentifier = node.expression.kind === 65; + var rhsIsIdentifier = node.expression.kind === 66; var counter = createTempVariable(268435456); var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0); emitStart(node.expression); @@ -24140,7 +25736,7 @@ var ts; increaseIndent(); var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 202) { + if (node.initializer.kind === 209) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -24161,8 +25757,8 @@ var ts; } } else { - var assignmentExpression = createBinaryExpression(node.initializer, 53, rhsIterationValue, false); - if (node.initializer.kind === 156 || node.initializer.kind === 157) { + var assignmentExpression = createBinaryExpression(node.initializer, 54, rhsIterationValue, false); + if (node.initializer.kind === 161 || node.initializer.kind === 162) { emitDestructuring(assignmentExpression, true, undefined); } else { @@ -24171,7 +25767,7 @@ var ts; } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 182) { + if (node.statement.kind === 189) { emitLines(node.statement.statements); } else { @@ -24183,12 +25779,12 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 193 ? 66 : 71, node.pos); + emitToken(node.kind === 200 ? 67 : 72, node.pos); emitOptional(" ", node.label); write(";"); } function emitReturnStatement(node) { - emitToken(90, node.pos); + emitToken(91, node.pos); emitOptional(" ", node.expression); write(";"); } @@ -24199,7 +25795,7 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var endPos = emitToken(92, node.pos); + var endPos = emitToken(93, node.pos); write(" "); emitToken(16, endPos); emit(node.expression); @@ -24228,7 +25824,7 @@ var ts; ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 223) { + if (node.kind === 238) { write("case "); emit(node.expression); write(":"); @@ -24263,7 +25859,7 @@ var ts; } function emitCatchClause(node) { writeLine(); - var endPos = emitToken(68, node.pos); + var endPos = emitToken(69, node.pos); write(" "); emitToken(16, endPos); emit(node.variableDeclaration); @@ -24272,7 +25868,7 @@ var ts; emitBlock(node.block); } function emitDebuggerStatement(node) { - emitToken(72, node.pos); + emitToken(73, node.pos); write(";"); } function emitLabelledStatement(node) { @@ -24283,7 +25879,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 208); + } while (node && node.kind !== 215); return node; } function emitContainingModuleName(node) { @@ -24308,7 +25904,7 @@ var ts; function createVoidZero() { var zero = ts.createSynthesizedNode(7); zero.text = "0"; - var result = ts.createSynthesizedNode(169); + var result = ts.createSynthesizedNode(174); result.expression = zero; return result; } @@ -24318,7 +25914,7 @@ var ts; emitStart(node); if (compilerOptions.module === 4 && node.parent === currentSourceFile) { write(exportFunctionForFile + "(\""); - if (node.flags & 256) { + if (node.flags & 1024) { write("default"); } else { @@ -24329,7 +25925,7 @@ var ts; write(")"); } else { - if (node.flags & 256) { + if (node.flags & 1024) { if (languageVersion === 0) { write("exports[\"default\"]"); } @@ -24377,15 +25973,15 @@ var ts; function emitDestructuring(root, isAssignmentExpressionStatement, value) { var emitCount = 0; var canDefineTempVariablesInPlace = false; - if (root.kind === 201) { + if (root.kind === 208) { var isExported = ts.getCombinedNodeFlags(root) & 1; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 131) { + else if (root.kind === 135) { canDefineTempVariablesInPlace = true; } - if (root.kind === 172) { + if (root.kind === 178) { emitAssignmentExpression(root); } else { @@ -24396,7 +25992,7 @@ var ts; if (emitCount++) { write(", "); } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 201 || name.parent.kind === 155); + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 208 || name.parent.kind === 160); var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); if (exportChanged) { write(exportFunctionForFile + "(\""); @@ -24416,7 +26012,7 @@ var ts; } } function ensureIdentifier(expr) { - if (expr.kind !== 65) { + if (expr.kind !== 66) { var identifier = createTempVariable(0); if (!canDefineTempVariablesInPlace) { recordTempDeclaration(identifier); @@ -24428,18 +26024,18 @@ var ts; } function createDefaultValueCheck(value, defaultValue) { value = ensureIdentifier(value); - var equals = ts.createSynthesizedNode(172); + var equals = ts.createSynthesizedNode(178); equals.left = value; - equals.operatorToken = ts.createSynthesizedNode(30); + equals.operatorToken = ts.createSynthesizedNode(31); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(173); + var cond = ts.createSynthesizedNode(179); cond.condition = condition; - cond.questionToken = ts.createSynthesizedNode(50); + cond.questionToken = ts.createSynthesizedNode(51); cond.whenTrue = whenTrue; - cond.colonToken = ts.createSynthesizedNode(51); + cond.colonToken = ts.createSynthesizedNode(52); cond.whenFalse = whenFalse; return cond; } @@ -24451,14 +26047,14 @@ var ts; function createPropertyAccessForDestructuringProperty(object, propName) { var syntheticName = ts.createSynthesizedNode(propName.kind); syntheticName.text = propName.text; - if (syntheticName.kind !== 65) { + if (syntheticName.kind !== 66) { return createElementAccessExpression(object, syntheticName); } return createPropertyAccessExpression(object, syntheticName); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(160); - var sliceIdentifier = ts.createSynthesizedNode(65); + var call = ts.createSynthesizedNode(165); + var sliceIdentifier = ts.createSynthesizedNode(66); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); call.arguments = ts.createSynthesizedNodeArray(); @@ -24472,7 +26068,7 @@ var ts; } for (var _a = 0; _a < properties.length; _a++) { var p = properties[_a]; - if (p.kind === 227 || p.kind === 228) { + if (p.kind === 242 || p.kind === 243) { var propName = p.name; emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); } @@ -24485,8 +26081,8 @@ var ts; } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 178) { - if (e.kind !== 176) { + if (e.kind !== 184) { + if (e.kind !== 182) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); } else if (i === elements.length - 1) { @@ -24496,14 +26092,14 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 172 && target.operatorToken.kind === 53) { + if (target.kind === 178 && target.operatorToken.kind === 54) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 157) { + if (target.kind === 162) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 156) { + else if (target.kind === 161) { emitArrayLiteralAssignment(target, value); } else { @@ -24517,14 +26113,14 @@ var ts; emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 164) { + if (root.parent.kind !== 169) { write("("); } value = ensureIdentifier(value); emitDestructuringAssignment(target, value); write(", "); emit(value); - if (root.parent.kind !== 164) { + if (root.parent.kind !== 169) { write(")"); } } @@ -24544,11 +26140,11 @@ var ts; } for (var i = 0; i < elements.length; i++) { var element = elements[i]; - if (pattern.kind === 153) { + if (pattern.kind === 158) { var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } - else if (element.kind !== 178) { + else if (element.kind !== 184) { if (!element.dotDotDotToken) { emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); } @@ -24576,11 +26172,11 @@ var ts; else { var initializer = node.initializer; if (!initializer && languageVersion < 2) { - var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 256) && - (getCombinedFlagsForIdentifier(node.name) & 4096); + var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 16384) && + (getCombinedFlagsForIdentifier(node.name) & 16384); if (isUninitializedLet && - node.parent.parent.kind !== 190 && - node.parent.parent.kind !== 191) { + node.parent.parent.kind !== 197 && + node.parent.parent.kind !== 198) { initializer = createVoidZero(); } } @@ -24598,11 +26194,11 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 178) { + if (node.kind === 184) { return; } var name = node.name; - if (name.kind === 65) { + if (name.kind === 66) { emitExportMemberAssignments(name); } else if (ts.isBindingPattern(name)) { @@ -24610,7 +26206,7 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 201 && node.parent.kind !== 155)) { + if (!node.parent || (node.parent.kind !== 208 && node.parent.kind !== 160)) { return 0; } return ts.getCombinedNodeFlags(node.parent); @@ -24618,7 +26214,7 @@ var ts; function isES6ExportedDeclaration(node) { return !!(node.flags & 1) && languageVersion >= 2 && - node.parent.kind === 230; + node.parent.kind === 245; } function emitVariableStatement(node) { var startIsEmitted = false; @@ -24663,12 +26259,12 @@ var ts; function emitParameter(node) { if (languageVersion < 2) { if (ts.isBindingPattern(node.name)) { - var name_20 = createTempVariable(0); + var name_24 = createTempVariable(0); if (!tempParameters) { tempParameters = []; } - tempParameters.push(name_20); - emit(name_20); + tempParameters.push(name_24); + emit(name_24); } else { emit(node.name); @@ -24685,30 +26281,41 @@ var ts; function emitDefaultValueAssignments(node) { if (languageVersion < 2) { var tempIndex = 0; - ts.forEach(node.parameters, function (p) { - if (p.dotDotDotToken) { + ts.forEach(node.parameters, function (parameter) { + if (parameter.dotDotDotToken) { return; } - if (ts.isBindingPattern(p.name)) { - writeLine(); - write("var "); - emitDestructuring(p, false, tempParameters[tempIndex]); - write(";"); - tempIndex++; + 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 (p.initializer) { + else if (initializer) { writeLine(); - emitStart(p); + emitStart(parameter); write("if ("); - emitNodeWithoutSourceMap(p.name); + emitNodeWithoutSourceMap(paramName); write(" === void 0)"); - emitEnd(p); + emitEnd(parameter); write(" { "); - emitStart(p); - emitNodeWithoutSourceMap(p.name); + emitStart(parameter); + emitNodeWithoutSourceMap(paramName); write(" = "); - emitNodeWithoutSourceMap(p.initializer); - emitEnd(p); + emitNodeWithoutSourceMap(initializer); + emitEnd(parameter); write("; }"); } }); @@ -24756,12 +26363,12 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 138 ? "get " : "set "); + write(node.kind === 142 ? "get " : "set "); emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 166 && languageVersion >= 2; + return node.kind === 171 && languageVersion >= 2; } function emitDeclarationName(node) { if (node.name) { @@ -24772,10 +26379,10 @@ var ts; } } function shouldEmitFunctionName(node) { - if (node.kind === 165) { + if (node.kind === 170) { return !!node.name; } - if (node.kind === 203) { + if (node.kind === 210) { return !!node.name || languageVersion < 2; } } @@ -24783,13 +26390,13 @@ var ts; if (ts.nodeIsMissing(node.body)) { return emitOnlyPinnedOrTripleSlashComments(node); } - if (node.kind !== 136 && node.kind !== 135) { + if (node.kind !== 140 && node.kind !== 139) { emitLeadingComments(node); } if (!shouldEmitAsArrowFunction(node)) { if (isES6ExportedDeclaration(node)) { write("export "); - if (node.flags & 256) { + if (node.flags & 1024) { write("default "); } } @@ -24803,10 +26410,10 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 && node.kind === 203 && node.parent === currentSourceFile && node.name) { + if (languageVersion < 2 && node.kind === 210 && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - if (node.kind !== 136 && node.kind !== 135) { + if (node.kind !== 140 && node.kind !== 139) { emitTrailingComments(node); } } @@ -24836,6 +26443,59 @@ var ts; } emitSignatureParameters(node); } + function emitAsyncFunctionBodyForES6(node) { + var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); + var isArrowFunction = node.kind === 171; + 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 === 189) { + emitBlockFunctionBody(node, node.body); + } + else { + emitExpressionFunctionBody(node, node.body); + } + } + } function emitSignatureAndBody(node) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; @@ -24850,14 +26510,12 @@ var ts; else { emitSignatureParameters(node); } - if (!node.body) { - write(" { }"); - } - else if (node.body.kind === 182) { - emitBlockFunctionBody(node, node.body); + var isAsync = ts.isAsyncFunctionLike(node); + if (isAsync && languageVersion === 2) { + emitAsyncFunctionBodyForES6(node); } else { - emitExpressionFunctionBody(node, node.body); + emitFunctionBody(node); } if (!isES6ExportedDeclaration(node)) { emitExportMemberAssignment(node); @@ -24872,16 +26530,16 @@ var ts; emitRestParameter(node); } function emitExpressionFunctionBody(node, body) { - if (languageVersion < 2) { + if (languageVersion < 2 || node.flags & 512) { emitDownLevelExpressionFunctionBody(node, body); return; } write(" "); var current = body; - while (current.kind === 163) { + while (current.kind === 168) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 157); + emitParenthesizedIf(body, current.kind === 162); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -24953,11 +26611,11 @@ var ts; function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 185) { + if (statement && statement.kind === 192) { var expr = statement.expression; - if (expr && expr.kind === 160) { + if (expr && expr.kind === 165) { var func = expr.expression; - if (func && func.kind === 91) { + if (func && func.kind === 92) { return statement; } } @@ -24986,7 +26644,7 @@ var ts; emitNodeWithoutSourceMap(memberName); write("]"); } - else if (memberName.kind === 129) { + else if (memberName.kind === 133) { emitComputedPropertyName(memberName); } else { @@ -24998,7 +26656,7 @@ var ts; var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 134 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { + if (member.kind === 138 && isStatic === ((member.flags & 128) !== 0) && member.initializer) { properties.push(member); } } @@ -25038,11 +26696,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 181) { + if (member.kind === 188) { writeLine(); write(";"); } - else if (member.kind === 136 || node.kind === 135) { + else if (member.kind === 140 || node.kind === 139) { if (!member.body) { return emitOnlyPinnedOrTripleSlashComments(member); } @@ -25061,7 +26719,7 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 138 || member.kind === 139) { + else if (member.kind === 142 || member.kind === 143) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -25111,22 +26769,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 136 || node.kind === 135) && !member.body) { + if ((member.kind === 140 || node.kind === 139) && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - else if (member.kind === 136 || - member.kind === 138 || - member.kind === 139) { + else if (member.kind === 140 || + member.kind === 142 || + member.kind === 143) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 128) { write("static "); } - if (member.kind === 138) { + if (member.kind === 142) { write("get "); } - else if (member.kind === 139) { + else if (member.kind === 143) { write("set "); } if (member.asteriskToken) { @@ -25137,7 +26795,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 181) { + else if (member.kind === 188) { writeLine(); write(";"); } @@ -25158,10 +26816,10 @@ var ts; function emitConstructorWorker(node, baseTypeElement) { var hasInstancePropertyWithInitializer = false; ts.forEach(node.members, function (member) { - if (member.kind === 137 && !member.body) { + if (member.kind === 141 && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - if (member.kind === 134 && member.initializer && (member.flags & 128) === 0) { + if (member.kind === 138 && member.initializer && (member.flags & 128) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -25261,9 +26919,9 @@ var ts; } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 204) { + if (node.kind === 211) { if (thisNodeIsDecorated) { - if (isES6ExportedDeclaration(node) && !(node.flags & 256)) { + if (isES6ExportedDeclaration(node) && !(node.flags & 1024)) { write("export "); } write("let "); @@ -25272,13 +26930,13 @@ var ts; } else if (isES6ExportedDeclaration(node)) { write("export "); - if (node.flags & 256) { + if (node.flags & 1024) { write("default "); } } } var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 177; + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 183; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0); @@ -25288,7 +26946,7 @@ var ts; write(" = "); } write("class"); - if ((node.name || !(node.flags & 256)) && !thisNodeIsDecorated) { + if ((node.name || !(node.flags & 1024)) && !thisNodeIsDecorated) { write(" "); emitDeclarationName(node); } @@ -25337,7 +26995,7 @@ var ts; emitEnd(node); write(";"); } - else if (isES6ExportedDeclaration(node) && (node.flags & 256) && thisNodeIsDecorated) { + else if (isES6ExportedDeclaration(node) && (node.flags & 1024) && thisNodeIsDecorated) { writeLine(); write("export default "); emitDeclarationName(node); @@ -25345,7 +27003,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 204) { + if (node.kind === 211) { if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); } @@ -25403,11 +27061,11 @@ var ts; emit(baseTypeNode.expression); } write(")"); - if (node.kind === 204) { + if (node.kind === 211) { write(";"); } emitEnd(node); - if (node.kind === 204) { + if (node.kind === 211) { emitExportMemberAssignment(node); } if (languageVersion < 2 && node.parent === currentSourceFile && node.name) { @@ -25481,13 +27139,13 @@ var ts; } else { decorators = member.decorators; - if (member.kind === 136) { + if (member.kind === 140) { functionLikeMember = member; } } writeLine(); emitStart(member); - if (member.kind !== 134) { + if (member.kind !== 138) { write("Object.defineProperty("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -25517,7 +27175,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); - if (member.kind !== 134) { + if (member.kind !== 138) { write(", Object.getOwnPropertyDescriptor("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -25556,101 +27214,228 @@ var ts; } function shouldEmitTypeMetadata(node) { switch (node.kind) { - case 136: + case 140: + case 142: + case 143: case 138: - case 139: - case 134: return true; } return false; } function shouldEmitReturnTypeMetadata(node) { switch (node.kind) { - case 136: + case 140: return true; } return false; } function shouldEmitParamTypesMetadata(node) { switch (node.kind) { - case 204: - case 136: - case 139: + case 211: + case 140: + case 143: return true; } return false; } + function emitSerializedTypeOfNode(node) { + switch (node.kind) { + case 211: + write("Function"); + return; + case 138: + emitSerializedTypeNode(node.type); + return; + case 135: + emitSerializedTypeNode(node.type); + return; + case 142: + emitSerializedTypeNode(node.type); + return; + case 143: + emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); + return; + } + if (ts.isFunctionLike(node)) { + write("Function"); + return; + } + write("void 0"); + } + function emitSerializedTypeNode(node) { + switch (node.kind) { + case 100: + write("void 0"); + return; + case 157: + emitSerializedTypeNode(node.type); + return; + case 149: + case 150: + write("Function"); + return; + case 153: + case 154: + write("Array"); + return; + case 147: + case 117: + write("Boolean"); + return; + case 127: + case 8: + write("String"); + return; + case 125: + write("Number"); + return; + case 128: + write("Symbol"); + return; + case 148: + emitSerializedTypeReferenceNode(node); + return; + case 151: + case 152: + case 155: + case 156: + case 114: + break; + default: + ts.Debug.fail("Cannot serialize unexpected type node."); + break; + } + write("Object"); + } + function emitSerializedTypeReferenceNode(node) { + var typeName = node.typeName; + var result = resolver.getTypeReferenceSerializationKind(node); + 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 === 211) { + 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 === 153) { + parameterType = parameterType.elementType; + } + else if (parameterType.kind === 148 && 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)) { + emitSerializedTypeNode(node.type); + return; + } + write("void 0"); + } function emitSerializedTypeMetadata(node, writeComma) { var argumentsWritten = 0; if (compilerOptions.emitDecoratorMetadata) { if (shouldEmitTypeMetadata(node)) { - var serializedType = resolver.serializeTypeOfNode(node); - if (serializedType) { - if (writeComma) { - write(", "); - } - writeLine(); - write("__metadata('design:type', "); - emitSerializedType(node, serializedType); - write(")"); - argumentsWritten++; + if (writeComma) { + write(", "); } + writeLine(); + write("__metadata('design:type', "); + emitSerializedTypeOfNode(node); + write(")"); + argumentsWritten++; } if (shouldEmitParamTypesMetadata(node)) { - var serializedTypes = resolver.serializeParameterTypesOfNode(node); - if (serializedTypes) { - if (writeComma || argumentsWritten) { - write(", "); - } - writeLine(); - write("__metadata('design:paramtypes', ["); - for (var i = 0; i < serializedTypes.length; ++i) { - if (i > 0) { - write(", "); - } - emitSerializedType(node, serializedTypes[i]); - } - write("])"); - argumentsWritten++; + if (writeComma || argumentsWritten) { + write(", "); } + writeLine(); + write("__metadata('design:paramtypes', ["); + emitSerializedParameterTypesOfNode(node); + write("])"); + argumentsWritten++; } if (shouldEmitReturnTypeMetadata(node)) { - var serializedType = resolver.serializeReturnTypeOfNode(node); - if (serializedType) { - if (writeComma || argumentsWritten) { - write(", "); - } - writeLine(); - write("__metadata('design:returntype', "); - emitSerializedType(node, serializedType); - write(")"); - argumentsWritten++; + if (writeComma || argumentsWritten) { + write(", "); } + writeLine(); + write("__metadata('design:returntype', "); + emitSerializedReturnTypeOfNode(node); + write(")"); + argumentsWritten++; } } return argumentsWritten; } - function serializeTypeNameSegment(location, path, index) { - switch (index) { - case 0: - return "typeof " + path[index] + " !== 'undefined' && " + path[index]; - case 1: - return serializeTypeNameSegment(location, path, index - 1) + "." + path[index]; - default: - var temp = createAndRecordTempVariable(0).text; - return "(" + temp + " = " + serializeTypeNameSegment(location, path, index - 1) + ") && " + temp + "." + path[index]; - } - } - function emitSerializedType(location, name) { - if (typeof name === "string") { - write(name); - return; - } - else { - ts.Debug.assert(name.length > 0, "Invalid serialized type name"); - write("(" + serializeTypeNameSegment(location, name, name.length - 1) + ") || Object"); - } - } function emitInterfaceDeclaration(node) { emitOnlyPinnedOrTripleSlashComments(node); } @@ -25745,7 +27530,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 208) { + if (moduleDeclaration.body.kind === 215) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -25754,7 +27539,7 @@ var ts; return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); } function isModuleMergedWithES6Class(node) { - return languageVersion === 2 && !!(resolver.getNodeCheckFlags(node) & 2048); + return languageVersion === 2 && !!(resolver.getNodeCheckFlags(node) & 32768); } function emitModuleDeclaration(node) { var shouldEmit = shouldEmitModuleDeclaration(node); @@ -25780,7 +27565,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 209) { + if (node.body.kind === 216) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; tempFlags = 0; @@ -25812,7 +27597,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.name.kind === 65 && node.parent === currentSourceFile) { + if (!isES6ExportedDeclaration(node) && node.name.kind === 66 && node.parent === currentSourceFile) { if (compilerOptions.module === 4 && (node.flags & 1)) { writeLine(); write(exportFunctionForFile + "(\""); @@ -25837,16 +27622,16 @@ var ts; } } function getNamespaceDeclarationNode(node) { - if (node.kind === 211) { + if (node.kind === 218) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 214) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 221) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 212 && node.importClause && !!node.importClause.name; + return node.kind === 219 && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -25873,7 +27658,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 214) { + if (node.importClause.namedBindings.kind === 221) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -25899,7 +27684,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 211 && (node.flags & 1) !== 0; + var isExportedImport = node.kind === 218 && (node.flags & 1) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (compilerOptions.module !== 2) { emitLeadingComments(node); @@ -25911,7 +27696,7 @@ var ts; write(" = "); } else { - var isNakedImport = 212 && !node.importClause; + var isNakedImport = 219 && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -26067,8 +27852,8 @@ var ts; write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 203 && - expression.kind !== 204) { + if (expression.kind !== 210 && + expression.kind !== 211) { write(";"); } emitEnd(node); @@ -26104,18 +27889,18 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 212: + case 219: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, true)) { externalImports.push(node); } break; - case 211: - if (node.moduleReference.kind === 222 && resolver.isReferencedAliasDeclaration(node)) { + case 218: + if (node.moduleReference.kind === 229 && resolver.isReferencedAliasDeclaration(node)) { externalImports.push(node); } break; - case 218: + case 225: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -26128,12 +27913,12 @@ var ts; else { for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { var specifier = _d[_c]; - var name_21 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_21] || (exportSpecifiers[name_21] = [])).push(specifier); + var name_25 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_25] || (exportSpecifiers[name_25] = [])).push(specifier); } } break; - case 217: + case 224: if (node.isExportEquals && !exportEquals) { exportEquals = node; } @@ -26158,10 +27943,10 @@ var ts; if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); } - if (node.kind === 212 && node.importClause) { + if (node.kind === 219 && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 218 && node.moduleSpecifier) { + if (node.kind === 225 && node.moduleSpecifier) { return getGeneratedNameForNode(node); } } @@ -26180,8 +27965,8 @@ var ts; var started = false; for (var _a = 0; _a < externalImports.length; _a++) { var importNode = externalImports[_a]; - var skipNode = importNode.kind === 218 || - (importNode.kind === 212 && !importNode.importClause); + var skipNode = importNode.kind === 225 || + (importNode.kind === 219 && !importNode.importClause); if (skipNode) { continue; } @@ -26206,7 +27991,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0; _a < externalImports.length; _a++) { var externalImport = externalImports[_a]; - if (externalImport.kind === 218 && externalImport.exportClause) { + if (externalImport.kind === 225 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -26235,7 +28020,7 @@ var ts; } for (var _d = 0; _d < externalImports.length; _d++) { var externalImport = externalImports[_d]; - if (externalImport.kind !== 218) { + if (externalImport.kind !== 225) { continue; } var exportDecl = externalImport; @@ -26274,7 +28059,7 @@ var ts; return exportStarFunction; } function writeExportedName(node) { - if (node.kind !== 65 && node.flags & 256) { + if (node.kind !== 66 && node.flags & 1024) { return; } if (started) { @@ -26285,7 +28070,7 @@ var ts; } writeLine(); write("'"); - if (node.kind === 65) { + if (node.kind === 66) { emitNodeWithoutSourceMap(node); } else { @@ -26305,11 +28090,11 @@ var ts; var seen = {}; for (var i = 0; i < hoistedVars.length; ++i) { var local = hoistedVars[i]; - var name_22 = local.kind === 65 + var name_26 = local.kind === 66 ? local : local.name; - if (name_22) { - var text = ts.unescapeIdentifier(name_22.text); + if (name_26) { + var text = ts.unescapeIdentifier(name_26.text); if (ts.hasProperty(seen, text)) { continue; } @@ -26320,13 +28105,13 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 204 || local.kind === 208 || local.kind === 207) { + if (local.kind === 211 || local.kind === 215 || local.kind === 214) { emitDeclarationName(local); } else { emit(local); } - var flags = ts.getCombinedNodeFlags(local.kind === 65 ? local.parent : local); + var flags = ts.getCombinedNodeFlags(local.kind === 66 ? local.parent : local); if (flags & 1) { if (!exportedDeclarations) { exportedDeclarations = []; @@ -26354,21 +28139,21 @@ var ts; if (node.flags & 2) { return; } - if (node.kind === 203) { + if (node.kind === 210) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 204) { + if (node.kind === 211) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 207) { + if (node.kind === 214) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -26377,7 +28162,7 @@ var ts; } return; } - if (node.kind === 208) { + if (node.kind === 215) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -26386,17 +28171,17 @@ var ts; } return; } - if (node.kind === 201 || node.kind === 155) { + if (node.kind === 208 || node.kind === 160) { if (shouldHoistVariable(node, false)) { - var name_23 = node.name; - if (name_23.kind === 65) { + var name_27 = node.name; + if (name_27.kind === 66) { if (!hoistedVars) { hoistedVars = []; } - hoistedVars.push(name_23); + hoistedVars.push(name_27); } else { - ts.forEachChild(name_23, visit); + ts.forEachChild(name_27, visit); } } return; @@ -26414,8 +28199,8 @@ var ts; if (checkIfSourceFileLevelDecl && !shouldHoistDeclarationInSystemJsModule(node)) { return false; } - return (ts.getCombinedNodeFlags(node) & 12288) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 230; + return (ts.getCombinedNodeFlags(node) & 49152) === 0 || + ts.getEnclosingBlockScopeContainer(node).kind === 245; } function isCurrentFileSystemExternalModule() { return compilerOptions.module === 4 && ts.isExternalModule(currentSourceFile); @@ -26450,27 +28235,27 @@ var ts; var parameterName = "_" + importVariableName; write("function (" + parameterName + ") {"); switch (importNode.kind) { - case 212: + case 219: if (!importNode.importClause) { break; } - case 211: + case 218: ts.Debug.assert(importVariableName !== ""); increaseIndent(); writeLine(); write(importVariableName + " = " + parameterName + ";"); writeLine(); - var defaultName = importNode.kind === 212 + var defaultName = importNode.kind === 219 ? importNode.importClause.name : importNode.name; if (defaultName) { emitExportMemberAssignments(defaultName); writeLine(); } - if (importNode.kind === 212 && + if (importNode.kind === 219 && importNode.importClause.namedBindings) { var namedBindings = importNode.importClause.namedBindings; - if (namedBindings.kind === 214) { + if (namedBindings.kind === 221) { emitExportMemberAssignments(namedBindings.name); writeLine(); } @@ -26484,7 +28269,7 @@ var ts; } decreaseIndent(); break; - case 218: + case 225: ts.Debug.assert(importVariableName !== ""); increaseIndent(); if (importNode.exportClause) { @@ -26518,10 +28303,10 @@ var ts; for (var i = startIndex; i < node.statements.length; ++i) { var statement = node.statements[i]; switch (statement.kind) { + case 225: + case 219: case 218: - case 212: - case 211: - case 203: + case 210: continue; } writeLine(); @@ -26535,6 +28320,7 @@ var ts; collectExternalModuleInfo(node); ts.Debug.assert(!exportFunctionForFile); exportFunctionForFile = makeUniqueName("exports"); + writeLine(); write("System.register("); if (node.moduleName) { write("\"" + node.moduleName + "\", "); @@ -26669,6 +28455,87 @@ var ts; emitEnd(exportEquals); } } + function emitJsxElement(node) { + switch (compilerOptions.jsx) { + case 2: + jsxEmitReact(node); + break; + case 1: + default: + jsxEmitPreserve(node); + break; + } + } + function trimReactWhitespace(node) { + var result = undefined; + var text = ts.getTextOfNode(node); + 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; + } + return result; + } + function getTextToEmit(node) { + switch (compilerOptions.jsx) { + case 2: + var text = trimReactWhitespace(node); + if (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(trimReactWhitespace(node)); + write('"'); + break; + case 1: + default: + write(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])) { @@ -26702,17 +28569,21 @@ var ts; writeLines(extendsHelper); extendsEmitted = true; } - if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 512) { + if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 16) { writeLines(decorateHelper); if (compilerOptions.emitDecoratorMetadata) { writeLines(metadataHelper); } decorateEmitted = true; } - if (!paramEmitted && resolver.getNodeCheckFlags(node) & 1024) { + if (!paramEmitted && resolver.getNodeCheckFlags(node) & 32) { writeLines(paramHelper); paramEmitted = true; } + if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & 64) { + writeLines(awaiterHelper); + awaiterEmitted = true; + } } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { if (languageVersion >= 2) { @@ -26760,23 +28631,23 @@ var ts; } function shouldEmitLeadingAndTrailingComments(node) { switch (node.kind) { - case 205: - case 203: case 212: - case 211: - case 206: - case 217: + case 210: + case 219: + case 218: + case 213: + case 224: return false; - case 183: + case 190: return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 208: + case 215: return shouldEmitModuleDeclaration(node); - case 207: + case 214: return shouldEmitEnumDeclaration(node); } - if (node.kind !== 182 && + if (node.kind !== 189 && node.parent && - node.parent.kind === 166 && + node.parent.kind === 171 && node.parent.body === node && compilerOptions.target <= 1) { return false; @@ -26785,25 +28656,25 @@ var ts; } function emitJavaScriptWorker(node) { switch (node.kind) { - case 65: + case 66: return emitIdentifier(node); - case 131: - return emitParameter(node); - case 136: case 135: - return emitMethod(node); - case 138: + return emitParameter(node); + case 140: case 139: + return emitMethod(node); + case 142: + case 143: return emitAccessor(node); - case 93: + case 94: return emitThis(node); - case 91: + case 92: return emitSuper(node); - case 89: + case 90: return write("null"); - case 95: + case 96: return write("true"); - case 80: + case 81: return write("false"); case 7: case 8: @@ -26813,131 +28684,142 @@ var ts; case 12: case 13: return emitLiteral(node); - case 174: - return emitTemplateExpression(node); case 180: - return emitTemplateSpan(node); - case 128: - return emitQualifiedName(node); - case 153: - return emitObjectBindingPattern(node); - case 154: - return emitArrayBindingPattern(node); - case 155: - return emitBindingElement(node); - case 156: - return emitArrayLiteral(node); - case 157: - return emitObjectLiteral(node); - case 227: - return emitPropertyAssignment(node); - case 228: - return emitShorthandPropertyAssignment(node); - case 129: - return emitComputedPropertyName(node); - case 158: - return emitPropertyAccess(node); - case 159: - return emitIndexedAccess(node); - case 160: - return emitCallExpression(node); - case 161: - return emitNewExpression(node); - case 162: - return emitTaggedTemplateExpression(node); - case 163: - return emit(node.expression); - case 164: - return emitParenExpression(node); - case 203: - case 165: - case 166: - return emitFunctionDeclaration(node); - case 167: - return emitDeleteExpression(node); - case 168: - return emitTypeOfExpression(node); - case 169: - return emitVoidExpression(node); - case 170: - return emitPrefixUnaryExpression(node); - case 171: - return emitPostfixUnaryExpression(node); - case 172: - return emitBinaryExpression(node); - case 173: - return emitConditionalExpression(node); - case 176: - return emitSpreadElementExpression(node); - case 175: - return emitYieldExpression(node); - case 178: - return; - case 182: - case 209: - return emitBlock(node); - case 183: - return emitVariableStatement(node); - case 184: - return write(";"); - case 185: - return emitExpressionStatement(node); - case 186: - return emitIfStatement(node); + return emitTemplateExpression(node); case 187: - return emitDoStatement(node); - case 188: - return emitWhileStatement(node); - case 189: - return emitForStatement(node); - case 191: - case 190: - return emitForInOrForOfStatement(node); - case 192: - case 193: - return emitBreakOrContinueStatement(node); - case 194: - return emitReturnStatement(node); - case 195: - return emitWithStatement(node); - case 196: - return emitSwitchStatement(node); - case 223: - case 224: - return emitCaseOrDefaultClause(node); - case 197: - return emitLabelledStatement(node); - case 198: - return emitThrowStatement(node); - case 199: - return emitTryStatement(node); - case 226: - return emitCatchClause(node); - case 200: - return emitDebuggerStatement(node); - case 201: - return emitVariableDeclaration(node); - case 177: - return emitClassExpression(node); - case 204: - return emitClassDeclaration(node); - case 205: - return emitInterfaceDeclaration(node); - case 207: - return emitEnumDeclaration(node); - case 229: - return emitEnumMember(node); - case 208: - return emitModuleDeclaration(node); - case 212: - return emitImportDeclaration(node); - case 211: - return emitImportEqualsDeclaration(node); - case 218: - return emitExportDeclaration(node); - case 217: - return emitExportAssignment(node); + return emitTemplateSpan(node); case 230: + case 231: + return emitJsxElement(node); + case 233: + return emitJsxText(node); + case 237: + return emitJsxExpression(node); + case 132: + return emitQualifiedName(node); + case 158: + return emitObjectBindingPattern(node); + case 159: + return emitArrayBindingPattern(node); + case 160: + return emitBindingElement(node); + case 161: + return emitArrayLiteral(node); + case 162: + return emitObjectLiteral(node); + case 242: + return emitPropertyAssignment(node); + case 243: + return emitShorthandPropertyAssignment(node); + case 133: + return emitComputedPropertyName(node); + case 163: + return emitPropertyAccess(node); + case 164: + return emitIndexedAccess(node); + case 165: + return emitCallExpression(node); + case 166: + return emitNewExpression(node); + case 167: + return emitTaggedTemplateExpression(node); + case 168: + return emit(node.expression); + case 186: + return emit(node.expression); + case 169: + return emitParenExpression(node); + case 210: + case 170: + case 171: + return emitFunctionDeclaration(node); + case 172: + return emitDeleteExpression(node); + case 173: + return emitTypeOfExpression(node); + case 174: + return emitVoidExpression(node); + case 175: + return emitAwaitExpression(node); + case 176: + return emitPrefixUnaryExpression(node); + case 177: + return emitPostfixUnaryExpression(node); + case 178: + return emitBinaryExpression(node); + case 179: + return emitConditionalExpression(node); + case 182: + return emitSpreadElementExpression(node); + case 181: + return emitYieldExpression(node); + case 184: + return; + case 189: + case 216: + return emitBlock(node); + case 190: + return emitVariableStatement(node); + case 191: + return write(";"); + case 192: + return emitExpressionStatement(node); + case 193: + return emitIfStatement(node); + case 194: + return emitDoStatement(node); + case 195: + return emitWhileStatement(node); + case 196: + return emitForStatement(node); + case 198: + case 197: + return emitForInOrForOfStatement(node); + case 199: + case 200: + return emitBreakOrContinueStatement(node); + case 201: + return emitReturnStatement(node); + case 202: + return emitWithStatement(node); + case 203: + return emitSwitchStatement(node); + case 238: + case 239: + return emitCaseOrDefaultClause(node); + case 204: + return emitLabelledStatement(node); + case 205: + return emitThrowStatement(node); + case 206: + return emitTryStatement(node); + case 241: + return emitCatchClause(node); + case 207: + return emitDebuggerStatement(node); + case 208: + return emitVariableDeclaration(node); + case 183: + return emitClassExpression(node); + case 211: + return emitClassDeclaration(node); + case 212: + return emitInterfaceDeclaration(node); + case 214: + return emitEnumDeclaration(node); + case 244: + return emitEnumMember(node); + case 215: + return emitModuleDeclaration(node); + case 219: + return emitImportDeclaration(node); + case 218: + return emitImportEqualsDeclaration(node); + case 225: + return emitExportDeclaration(node); + case 224: + return emitExportAssignment(node); + case 245: return emitSourceFileNode(node); } } @@ -26965,7 +28847,7 @@ var ts; } function getLeadingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 230 || node.pos !== node.parent.pos) { + if (node.parent.kind === 245 || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { return getLeadingCommentsWithoutDetachedComments(); } @@ -26977,7 +28859,7 @@ var ts; } function getTrailingCommentsToEmit(node) { if (node.parent) { - if (node.parent.kind === 230 || node.end !== node.parent.end) { + if (node.parent.kind === 245 || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } @@ -27154,10 +29036,10 @@ var ts; }; } ts.createCompilerHost = createCompilerHost; - function getPreEmitDiagnostics(program, sourceFile) { - var diagnostics = program.getOptionsDiagnostics().concat(program.getSyntacticDiagnostics(sourceFile), program.getGlobalDiagnostics(), program.getSemanticDiagnostics(sourceFile)); + function getPreEmitDiagnostics(program, sourceFile, cancellationToken) { + var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (program.getCompilerOptions().declaration) { - diagnostics.concat(program.getDeclarationDiagnostics(sourceFile)); + diagnostics.concat(program.getDeclarationDiagnostics(sourceFile, cancellationToken)); } return ts.sortAndDeduplicateDiagnostics(diagnostics); } @@ -27253,8 +29135,12 @@ var ts; function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false)); } - function emit(sourceFile, writeFileCallback) { - if (options.noEmitOnError && getPreEmitDiagnostics(this).length > 0) { + function emit(sourceFile, writeFileCallback, cancellationToken) { + var _this = this; + return runWithCancellationToken(function () { return emitWorker(_this, sourceFile, writeFileCallback, cancellationToken); }); + } + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken) { + if (options.noEmitOnError && getPreEmitDiagnostics(program, undefined, cancellationToken).length > 0) { return { diagnostics: [], sourceMaps: undefined, emitSkipped: true }; } var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(options.out ? undefined : sourceFile); @@ -27266,42 +29152,61 @@ var ts; function getSourceFile(fileName) { return filesByName.get(fileName); } - function getDiagnosticsHelper(sourceFile, getDiagnostics) { + function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) { if (sourceFile) { - return getDiagnostics(sourceFile); + return getDiagnostics(sourceFile, cancellationToken); } var allDiagnostics = []; ts.forEach(program.getSourceFiles(), function (sourceFile) { - ts.addRange(allDiagnostics, getDiagnostics(sourceFile)); + if (cancellationToken) { + cancellationToken.throwIfCancellationRequested(); + } + ts.addRange(allDiagnostics, getDiagnostics(sourceFile, cancellationToken)); }); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } - function getSyntacticDiagnostics(sourceFile) { - return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile); + function getSyntacticDiagnostics(sourceFile, cancellationToken) { + return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile, cancellationToken); } - function getSemanticDiagnostics(sourceFile) { - return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile); + function getSemanticDiagnostics(sourceFile, cancellationToken) { + return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile, cancellationToken); } - function getDeclarationDiagnostics(sourceFile) { - return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile); + function getDeclarationDiagnostics(sourceFile, cancellationToken) { + return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken); } - function getSyntacticDiagnosticsForFile(sourceFile) { + function getSyntacticDiagnosticsForFile(sourceFile, cancellationToken) { return sourceFile.parseDiagnostics; } - function getSemanticDiagnosticsForFile(sourceFile) { - var typeChecker = getDiagnosticsProducingTypeChecker(); - ts.Debug.assert(!!sourceFile.bindDiagnostics); - var bindDiagnostics = sourceFile.bindDiagnostics; - var checkDiagnostics = typeChecker.getDiagnostics(sourceFile); - var programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName); - return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics); - } - function getDeclarationDiagnosticsForFile(sourceFile) { - if (!ts.isDeclarationFile(sourceFile)) { - var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile); - var writeFile = function () { }; - return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); + function runWithCancellationToken(func) { + try { + return func(); } + catch (e) { + if (e instanceof ts.OperationCanceledException) { + noDiagnosticsTypeChecker = undefined; + diagnosticsProducingTypeChecker = undefined; + } + throw e; + } + } + function getSemanticDiagnosticsForFile(sourceFile, cancellationToken) { + return runWithCancellationToken(function () { + var typeChecker = getDiagnosticsProducingTypeChecker(); + ts.Debug.assert(!!sourceFile.bindDiagnostics); + var bindDiagnostics = sourceFile.bindDiagnostics; + var checkDiagnostics = typeChecker.getDiagnostics(sourceFile, cancellationToken); + var programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName); + return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics); + }); + } + function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) { + return runWithCancellationToken(function () { + if (!ts.isDeclarationFile(sourceFile)) { + var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); + var writeFile_1 = function () { }; + return ts.getDeclarationDiagnostics(getEmitHost(writeFile_1), resolver, sourceFile); + } + }); } function getOptionsDiagnostics() { var allDiagnostics = []; @@ -27322,7 +29227,6 @@ var ts; function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var start; var length; - var extensions; var diagnosticArgument; if (refEnd !== undefined && refPos !== undefined) { start = refPos; @@ -27423,7 +29327,7 @@ var ts; } function processImportedModules(file, basePath) { ts.forEach(file.statements, function (node) { - if (node.kind === 212 || node.kind === 211 || node.kind === 218) { + if (node.kind === 219 || node.kind === 218 || node.kind === 225) { var moduleNameExpr = ts.getExternalModuleName(node); if (moduleNameExpr && moduleNameExpr.kind === 8) { var moduleNameText = moduleNameExpr.text; @@ -27444,7 +29348,7 @@ var ts; } } } - else if (node.kind === 208 && node.name.kind === 8 && (node.flags & 2 || ts.isDeclarationFile(file))) { + else if (node.kind === 215 && node.name.kind === 8 && (node.flags & 2 || ts.isDeclarationFile(file))) { ts.forEachChild(node.body, function (node) { if (ts.isExternalModuleImportEqualsDeclaration(node) && ts.getExternalModuleImportEqualsDeclarationExpression(node).kind === 8) { @@ -27594,6 +29498,10 @@ var ts; !options.experimentalDecorators) { diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified)); } + if (options.experimentalAsyncFunctions && + options.target !== 2) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower)); + } } } ts.createProgram = createProgram; @@ -27606,7 +29514,7 @@ var ts; var BreakpointResolver; (function (BreakpointResolver) { function spanInSourceFileAtLocation(sourceFile, position) { - if (sourceFile.flags & 2048) { + if (sourceFile.flags & 8192) { return undefined; } var tokenAtLocation = ts.getTokenAtPosition(sourceFile, position); @@ -27639,98 +29547,98 @@ var ts; function spanInNode(node) { if (node) { if (ts.isExpression(node)) { - if (node.parent.kind === 187) { + if (node.parent.kind === 194) { return spanInPreviousNode(node); } - if (node.parent.kind === 189) { + if (node.parent.kind === 196) { return textSpan(node); } - if (node.parent.kind === 172 && node.parent.operatorToken.kind === 23) { + if (node.parent.kind === 178 && node.parent.operatorToken.kind === 23) { return textSpan(node); } - if (node.parent.kind === 166 && node.parent.body === node) { + if (node.parent.kind === 171 && node.parent.body === node) { return textSpan(node); } } switch (node.kind) { - case 183: + case 190: return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 201: - case 134: - case 133: - return spanInVariableDeclaration(node); - case 131: - return spanInParameterDeclaration(node); - case 203: - case 136: - case 135: + case 208: case 138: - case 139: case 137: - case 165: - case 166: + return spanInVariableDeclaration(node); + case 135: + return spanInParameterDeclaration(node); + case 210: + case 140: + case 139: + case 142: + case 143: + case 141: + case 170: + case 171: return spanInFunctionDeclaration(node); - case 182: + case 189: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - case 209: + case 216: return spanInBlock(node); - case 226: + case 241: return spanInBlock(node.block); - case 185: + case 192: return textSpan(node.expression); - case 194: + case 201: return textSpan(node.getChildAt(0), node.expression); - case 188: + case 195: return textSpan(node, ts.findNextToken(node.expression, node)); - case 187: + case 194: + return spanInNode(node.statement); + case 207: + return textSpan(node.getChildAt(0)); + case 193: + return textSpan(node, ts.findNextToken(node.expression, node)); + case 204: return spanInNode(node.statement); case 200: - return textSpan(node.getChildAt(0)); - case 186: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 197: - return spanInNode(node.statement); - case 193: - case 192: - return textSpan(node.getChildAt(0), node.label); - case 189: - return spanInForStatement(node); - case 190: - case 191: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 196: - return textSpan(node, ts.findNextToken(node.expression, node)); - case 223: - case 224: - return spanInNode(node.statements[0]); case 199: - return spanInBlock(node.tryBlock); + return textSpan(node.getChildAt(0), node.label); + case 196: + return spanInForStatement(node); + case 197: case 198: + return textSpan(node, ts.findNextToken(node.expression, node)); + case 203: + return textSpan(node, ts.findNextToken(node.expression, node)); + case 238: + case 239: + return spanInNode(node.statements[0]); + case 206: + return spanInBlock(node.tryBlock); + case 205: return textSpan(node, node.expression); - case 217: + case 224: return textSpan(node, node.expression); - case 211: - return textSpan(node, node.moduleReference); - case 212: - return textSpan(node, node.moduleSpecifier); case 218: + return textSpan(node, node.moduleReference); + case 219: return textSpan(node, node.moduleSpecifier); - case 208: + case 225: + return textSpan(node, node.moduleSpecifier); + case 215: if (ts.getModuleInstanceState(node) !== 1) { return undefined; } - case 204: - case 207: - case 229: - case 160: - case 161: + case 211: + case 214: + case 244: + case 165: + case 166: return textSpan(node); - case 195: + case 202: return spanInNode(node.statement); - case 205: - case 206: + case 212: + case 213: return undefined; case 22: case 1: @@ -27745,22 +29653,22 @@ var ts; return spanInOpenParenToken(node); case 17: return spanInCloseParenToken(node); - case 51: + case 52: return spanInColonToken(node); - case 25: + case 26: case 24: return spanInGreaterThanOrLessThanToken(node); - case 100: + case 101: return spanInWhileKeyword(node); - case 76: - case 68: - case 81: + case 77: + case 69: + case 82: return spanInNextNode(node); default: - if (node.parent.kind === 227 && node.parent.name === node) { + if (node.parent.kind === 242 && node.parent.name === node) { return spanInNode(node.parent.initializer); } - if (node.parent.kind === 163 && node.parent.type === node) { + if (node.parent.kind === 168 && node.parent.type === node) { return spanInNode(node.parent.expression); } if (ts.isFunctionLike(node.parent) && node.parent.type === node) { @@ -27770,12 +29678,12 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 190 || - variableDeclaration.parent.parent.kind === 191) { + if (variableDeclaration.parent.parent.kind === 197 || + variableDeclaration.parent.parent.kind === 198) { return spanInNode(variableDeclaration.parent.parent); } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 183; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 189 && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); + var isParentVariableStatement = variableDeclaration.parent.parent.kind === 190; + var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 196 && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); var declarations = isParentVariableStatement ? variableDeclaration.parent.parent.declarationList.declarations : isDeclarationOfForStatement @@ -27821,7 +29729,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return !!(functionDeclaration.flags & 1) || - (functionDeclaration.parent.kind === 204 && functionDeclaration.kind !== 137); + (functionDeclaration.parent.kind === 211 && functionDeclaration.kind !== 141); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -27841,23 +29749,23 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 208: + case 215: if (ts.getModuleInstanceState(block.parent) !== 1) { return undefined; } - case 188: - case 186: - case 190: - case 191: + case 195: + case 193: + case 197: + case 198: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); - case 189: + case 196: 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 === 202) { + if (forStatement.initializer.kind === 209) { var variableDeclarationList = forStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -27876,34 +29784,34 @@ var ts; } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 207: + case 214: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 204: + case 211: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 210: + case 217: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 209: + case 216: if (ts.getModuleInstanceState(node.parent.parent) !== 1) { return undefined; } - case 207: - case 204: + case 214: + case 211: return textSpan(node); - case 182: + case 189: if (ts.isFunctionBlock(node.parent)) { return textSpan(node); } - case 226: + case 241: return spanInNode(ts.lastOrUndefined(node.parent.statements)); ; - case 210: + case 217: var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); if (lastClause) { @@ -27915,24 +29823,24 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 187) { + if (node.parent.kind === 194) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInCloseParenToken(node) { switch (node.parent.kind) { - case 165: - case 203: - case 166: - case 136: - case 135: - case 138: + case 170: + case 210: + case 171: + case 140: case 139: - case 137: - case 188: - case 187: - case 189: + case 142: + case 143: + case 141: + case 195: + case 194: + case 196: return spanInPreviousNode(node); default: return spanInNode(node.parent); @@ -27940,19 +29848,19 @@ var ts; return spanInNode(node.parent); } function spanInColonToken(node) { - if (ts.isFunctionLike(node.parent) || node.parent.kind === 227) { + if (ts.isFunctionLike(node.parent) || node.parent.kind === 242) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 163) { + if (node.parent.kind === 168) { return spanInNode(node.parent.expression); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 187) { + if (node.parent.kind === 194) { return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); } return spanInNode(node.parent); @@ -28030,7 +29938,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 166; + return ts.isFunctionBlock(node) && node.parent.kind !== 171; } var depth = 0; var maxDepth = 20; @@ -28042,30 +29950,30 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 182: + case 189: if (!ts.isFunctionBlock(n)) { var parent_8 = n.parent; var openBrace = ts.findChildOfKind(n, 14, sourceFile); var closeBrace = ts.findChildOfKind(n, 15, sourceFile); - if (parent_8.kind === 187 || - parent_8.kind === 190 || - parent_8.kind === 191 || - parent_8.kind === 189 || - parent_8.kind === 186 || - parent_8.kind === 188 || + if (parent_8.kind === 194 || + parent_8.kind === 197 || + parent_8.kind === 198 || + parent_8.kind === 196 || + parent_8.kind === 193 || parent_8.kind === 195 || - parent_8.kind === 226) { + parent_8.kind === 202 || + parent_8.kind === 241) { addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_8.kind === 199) { + if (parent_8.kind === 206) { var tryStatement = parent_8; if (tryStatement.tryBlock === n) { addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 81, sourceFile); + var finallyKeyword = ts.findChildOfKind(tryStatement, 82, sourceFile); if (finallyKeyword) { addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); break; @@ -28081,23 +29989,23 @@ var ts; }); break; } - case 209: { + case 216: { var openBrace = ts.findChildOfKind(n, 14, sourceFile); var closeBrace = ts.findChildOfKind(n, 15, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 204: - case 205: - case 207: - case 157: - case 210: { + case 211: + case 212: + case 214: + case 162: + case 217: { var openBrace = ts.findChildOfKind(n, 14, sourceFile); var closeBrace = ts.findChildOfKind(n, 15, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 156: + case 161: var openBracket = ts.findChildOfKind(n, 18, sourceFile); var closeBracket = ts.findChildOfKind(n, 19, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -28123,10 +30031,10 @@ var ts; ts.forEach(program.getSourceFiles(), function (sourceFile) { cancellationToken.throwIfCancellationRequested(); var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_24 in nameToDeclarations) { - var declarations = ts.getProperty(nameToDeclarations, name_24); + for (var name_28 in nameToDeclarations) { + var declarations = ts.getProperty(nameToDeclarations, name_28); if (declarations) { - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_24); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_28); if (!matches) { continue; } @@ -28137,14 +30045,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_24); + matches = patternMatcher.getMatches(containers, name_28); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_24, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_28, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -28167,7 +30075,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 65 || + if (node.kind === 66 || node.kind === 8 || node.kind === 7) { return node.text; @@ -28181,7 +30089,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 129) { + else if (declaration.name.kind === 133) { return tryAddComputedPropertyName(declaration.name.expression, containers, true); } else { @@ -28198,7 +30106,7 @@ var ts; } return true; } - if (expression.kind === 158) { + if (expression.kind === 163) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -28209,7 +30117,7 @@ var ts; } function getContainers(declaration) { var containers = []; - if (declaration.name.kind === 129) { + if (declaration.name.kind === 133) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { return undefined; } @@ -28273,14 +30181,14 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 208: + case 215: do { current = current.parent; - } while (current.kind === 208); - case 204: - case 207: - case 205: - case 203: + } while (current.kind === 215); + case 211: + case 214: + case 212: + case 210: indent++; } current = current.parent; @@ -28291,26 +30199,26 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 183: + case 190: ts.forEach(node.declarationList.declarations, visit); break; - case 153: - case 154: + case 158: + case 159: ts.forEach(node.elements, visit); break; - case 218: + case 225: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 212: + case 219: var importClause = node.importClause; if (importClause) { if (importClause.name) { childNodes.push(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 214) { + if (importClause.namedBindings.kind === 221) { childNodes.push(importClause.namedBindings); } else { @@ -28319,20 +30227,20 @@ var ts; } } break; - case 155: - case 201: + case 160: + case 208: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } - case 204: - case 207: - case 205: - case 208: - case 203: case 211: - case 216: - case 220: + case 214: + case 212: + case 215: + case 210: + case 218: + case 223: + case 227: childNodes.push(node); break; } @@ -28367,17 +30275,17 @@ var ts; for (var _i = 0; _i < nodes.length; _i++) { var node = nodes[_i]; switch (node.kind) { - case 204: - case 207: - case 205: + case 211: + case 214: + case 212: topLevelNodes.push(node); break; - case 208: + case 215: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 203: + case 210: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -28388,9 +30296,9 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 203) { - if (functionDeclaration.body && functionDeclaration.body.kind === 182) { - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 203 && !isEmpty(s.name.text); })) { + if (functionDeclaration.kind === 210) { + if (functionDeclaration.body && functionDeclaration.body.kind === 189) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 210 && !isEmpty(s.name.text); })) { return true; } if (!ts.isFunctionBlock(functionDeclaration.parent)) { @@ -28423,7 +30331,7 @@ var ts; return items; } function merge(target, source) { - target.spans.push.apply(target.spans, source.spans); + ts.addRange(target.spans, source.spans); if (source.childItems) { if (!target.childItems) { target.childItems = []; @@ -28443,42 +30351,42 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 131: + case 135: if (ts.isBindingPattern(node.name)) { break; } - if ((node.flags & 499) === 0) { + if ((node.flags & 2035) === 0) { return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 136: - case 135: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 138: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); - case 139: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 142: - return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 229: - return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); case 140: - return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 141: - return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 134: - case 133: + case 139: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); + case 142: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); + case 143: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); + case 146: + return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); + case 244: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 203: + case 144: + return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); + case 145: + return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); + case 138: + case 137: + return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); + case 210: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 201: - case 155: + case 208: + case 160: var variableDeclarationNode; - var name_25; - if (node.kind === 155) { - name_25 = node.name; + var name_29; + if (node.kind === 160) { + name_29 = node.name; variableDeclarationNode = node; - while (variableDeclarationNode && variableDeclarationNode.kind !== 201) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 208) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -28486,24 +30394,24 @@ var ts; else { ts.Debug.assert(!ts.isBindingPattern(node.name)); variableDeclarationNode = node; - name_25 = node.name; + name_29 = node.name; } if (ts.isConst(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_25), ts.ScriptElementKind.constElement); + return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.constElement); } else if (ts.isLet(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_25), ts.ScriptElementKind.letElement); + return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.letElement); } else { - return createItem(node, getTextOfNode(name_25), ts.ScriptElementKind.variableElement); + return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.variableElement); } - case 137: + case 141: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); + case 227: + case 223: + case 218: case 220: - case 216: - case 211: - case 213: - case 214: + case 221: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -28533,17 +30441,17 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 230: + case 245: return createSourceFileItem(node); - case 204: + case 211: return createClassItem(node); - case 207: + case 214: return createEnumItem(node); - case 205: + case 212: return createIterfaceItem(node); - case 208: + case 215: return createModuleItem(node); - case 203: + case 210: return createFunctionItem(node); } return undefined; @@ -28553,7 +30461,7 @@ var ts; } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 208) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 215) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -28565,7 +30473,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 === 182) { + if (node.body && node.body.kind === 189) { 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)); } @@ -28586,11 +30494,11 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 137 && member; + return member.kind === 141 && member; }); var nodes = removeDynamicallyNamedProperties(node); if (constructor) { - nodes.push.apply(nodes, ts.filter(constructor.parameters, function (p) { return !ts.isBindingPattern(p.name); })); + ts.addRange(nodes, ts.filter(constructor.parameters, function (p) { return !ts.isBindingPattern(p.name); })); } childItems = getItemsWorker(sortNodes(nodes), createChildItem); } @@ -28607,19 +30515,19 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 129; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 133; }); } function removeDynamicallyNamedProperties(node) { return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 208) { + while (node.body.kind === 215) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 230 + return node.kind === 245 ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -29110,14 +31018,14 @@ var ts; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 160) { + if (argumentInfo.invocation.kind !== 165) { return undefined; } var callExpression = argumentInfo.invocation; var expression = callExpression.expression; - var name = expression.kind === 65 + var name = expression.kind === 66 ? expression - : expression.kind === 158 + : expression.kind === 163 ? expression.name : undefined; if (!name || !name.text) { @@ -29146,7 +31054,7 @@ var ts; } } function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 160 || node.parent.kind === 161) { + if (node.parent.kind === 165 || node.parent.kind === 166) { var callExpression = node.parent; if (node.kind === 24 || node.kind === 16) { @@ -29177,23 +31085,23 @@ var ts; }; } } - else if (node.kind === 10 && node.parent.kind === 162) { + else if (node.kind === 10 && node.parent.kind === 167) { if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, 0); } } - else if (node.kind === 11 && node.parent.parent.kind === 162) { + else if (node.kind === 11 && node.parent.parent.kind === 167) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 174); + ts.Debug.assert(templateExpression.kind === 180); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 180 && node.parent.parent.parent.kind === 162) { + else if (node.parent.kind === 187 && node.parent.parent.parent.kind === 167) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 174); + ts.Debug.assert(templateExpression.kind === 180); if (node.kind === 13 && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } @@ -29257,7 +31165,7 @@ var ts; var template = taggedTemplate.template; var applicableSpanStart = template.getStart(); var applicableSpanEnd = template.getEnd(); - if (template.kind === 174) { + if (template.kind === 180) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -29266,7 +31174,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 230; n = n.parent) { + for (var n = node; n.kind !== 245; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -29313,23 +31221,23 @@ var ts; var prefixDisplayParts = []; var suffixDisplayParts = []; if (callTargetDisplayParts) { - prefixDisplayParts.push.apply(prefixDisplayParts, callTargetDisplayParts); + ts.addRange(prefixDisplayParts, callTargetDisplayParts); } if (isTypeParameterList) { prefixDisplayParts.push(ts.punctuationPart(24)); var typeParameters = candidateSignature.typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(25)); + suffixDisplayParts.push(ts.punctuationPart(26)); var parameterParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation); }); - suffixDisplayParts.push.apply(suffixDisplayParts, parameterParts); + ts.addRange(suffixDisplayParts, parameterParts); } else { var typeParameterParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); }); - prefixDisplayParts.push.apply(prefixDisplayParts, typeParameterParts); + ts.addRange(prefixDisplayParts, typeParameterParts); prefixDisplayParts.push(ts.punctuationPart(16)); var parameters = candidateSignature.parameters; signatureHelpParameters = parameters.length > 0 ? ts.map(parameters, createSignatureHelpParameterForParameter) : emptyArray; @@ -29338,7 +31246,7 @@ var ts; var returnTypeParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation); }); - suffixDisplayParts.push.apply(suffixDisplayParts, returnTypeParts); + ts.addRange(suffixDisplayParts, returnTypeParts); return { isVariadic: candidateSignature.hasRestParameter, prefixDisplayParts: prefixDisplayParts, @@ -29447,39 +31355,39 @@ var ts; return false; } switch (n.kind) { - case 204: - case 205: - case 207: - case 157: - case 153: - case 148: - case 182: - case 209: - case 210: + case 211: + case 212: + case 214: + case 162: + case 158: + case 152: + case 189: + case 216: + case 217: return nodeEndsWith(n, 15, sourceFile); - case 226: + case 241: return isCompletedNode(n.block, sourceFile); - case 161: + case 166: if (!n.arguments) { return true; } - case 160: - case 164: - case 152: - return nodeEndsWith(n, 17, sourceFile); - case 145: - case 146: - return isCompletedNode(n.type, sourceFile); - case 137: - case 138: - case 139: - case 203: case 165: - case 136: - case 135: + case 169: + case 157: + return nodeEndsWith(n, 17, sourceFile); + case 149: + case 150: + return isCompletedNode(n.type, sourceFile); case 141: + case 142: + case 143: + case 210: + case 170: case 140: - case 166: + case 139: + case 145: + case 144: + case 171: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -29487,61 +31395,61 @@ var ts; return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 17, sourceFile); - case 208: + case 215: return n.body && isCompletedNode(n.body, sourceFile); - case 186: + case 193: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 185: + case 192: return isCompletedNode(n.expression, sourceFile); - case 156: - case 154: + case 161: case 159: - case 129: - case 150: + case 164: + case 133: + case 154: return nodeEndsWith(n, 19, sourceFile); - case 142: + case 146: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 19, sourceFile); - case 223: - case 224: + case 238: + case 239: return false; - case 189: - case 190: - case 191: - case 188: + case 196: + case 197: + case 198: + case 195: return isCompletedNode(n.statement, sourceFile); - case 187: - var hasWhileKeyword = findChildOfKind(n, 100, sourceFile); + case 194: + var hasWhileKeyword = findChildOfKind(n, 101, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 17, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 147: + case 151: return isCompletedNode(n.exprName, sourceFile); - case 168: - case 167: - case 169: - case 175: - case 176: + case 173: + case 172: + case 174: + case 181: + case 182: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 162: + case 167: return isCompletedNode(n.template, sourceFile); - case 174: + case 180: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 180: + case 187: return ts.nodeIsPresent(n.literal); - case 170: + case 176: return isCompletedNode(n.operand, sourceFile); - case 172: + case 178: return isCompletedNode(n.right, sourceFile); - case 173: + case 179: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -29584,7 +31492,7 @@ var ts; ts.findChildOfKind = findChildOfKind; function findContainingList(node) { var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { - if (c.kind === 253 && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 268 && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -29690,7 +31598,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 230); + ts.Debug.assert(startNode !== undefined || n.kind === 245); if (children.length) { var candidate = findRightmostChildNodeWithTokens(children, children.length); return candidate && findRightmostToken(candidate); @@ -29719,6 +31627,8 @@ var ts; result.push(ts.ScriptElementKindModifier.publicMemberModifier); if (flags & 128) result.push(ts.ScriptElementKindModifier.staticModifier); + if (flags & 256) + result.push(ts.ScriptElementKindModifier.abstractModifier); if (flags & 1) result.push(ts.ScriptElementKindModifier.exportedModifier); if (ts.isInAmbientContext(node)) @@ -29727,21 +31637,21 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 144 || node.kind === 160) { + if (node.kind === 148 || node.kind === 165) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 204 || node.kind === 205) { + if (ts.isFunctionLike(node) || node.kind === 211 || node.kind === 212) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 && n.kind <= 127; + return n.kind >= 0 && n.kind <= 131; } ts.isToken = isToken; function isWord(kind) { - return kind === 65 || ts.isKeyword(kind); + return kind === 66 || ts.isKeyword(kind); } ts.isWord = isWord; function isPropertyName(kind) { @@ -29752,7 +31662,7 @@ var ts; } ts.isComment = isComment; function isPunctuation(kind) { - return 14 <= kind && kind <= 64; + return 14 <= kind && kind <= 65; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { @@ -29762,9 +31672,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 108: - case 106: + case 109: case 107: + case 108: return true; } return false; @@ -29790,7 +31700,7 @@ var ts; var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 131; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 135; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -29954,6 +31864,32 @@ var ts; }); } ts.signatureToDisplayParts = signatureToDisplayParts; + function getDeclaredName(typeChecker, symbol, location) { + if (isImportOrExportSpecifierName(location)) { + return location.getText(); + } + var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); + var name = typeChecker.symbolToString(localExportDefaultSymbol || symbol); + return name; + } + ts.getDeclaredName = getDeclaredName; + function isImportOrExportSpecifierName(location) { + return location.parent && + (location.parent.kind === 223 || location.parent.kind === 227) && + location.parent.propertyName === location; + } + ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; + function stripQuotes(name) { + var length = name.length; + if (length >= 2 && + name.charCodeAt(0) === name.charCodeAt(length - 1) && + (name.charCodeAt(0) === 34 || name.charCodeAt(0) === 39)) { + return name.substring(1, length - 1); + } + ; + return name; + } + ts.stripQuotes = stripQuotes; })(ts || (ts = {})); /// /// @@ -30022,11 +31958,11 @@ var ts; function shouldRescanGreaterThanToken(node) { if (node) { switch (node.kind) { - case 27: - case 60: + case 28: case 61: + case 62: + case 43: case 42: - case 41: return true; } } @@ -30040,7 +31976,7 @@ var ts; container.kind === 13; } function startsWithSlashToken(t) { - return t === 36 || t === 57; + return t === 37 || t === 58; } function readTokenInfo(n) { if (!isOnToken()) { @@ -30066,7 +32002,7 @@ var ts; scanner.scan(); } var currentToken = scanner.getToken(); - if (expectedScanAction === 1 && currentToken === 25) { + if (expectedScanAction === 1 && currentToken === 26) { currentToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === currentToken); lastScanAction = 1; @@ -30342,15 +32278,15 @@ var ts; 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, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 51), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 50), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(51, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2)); - this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(50, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); - this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(50, 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, 52), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 51), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(52, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2)); + this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(51, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); + this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(51, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(22, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); - this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(15, 76), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(15, 100), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(15, 77), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(15, 101), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15, formatting.Shared.TokenRange.FromTokens([17, 19, 23, 22])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(20, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); @@ -30360,9 +32296,9 @@ var ts; this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(19, 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, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([65, 3]); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([66, 3]); this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([17, 3, 75, 96, 81, 76]); + this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([17, 3, 76, 97, 82, 77]); this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(14, 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, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2)); @@ -30370,50 +32306,50 @@ var ts; this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(14, 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, 15), 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(38, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(39, 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, 38), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 39), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(38, 33), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(33, 33), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(33, 38), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(39, 34), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(34, 34), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(34, 39), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(39, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(40, 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, 39), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 40), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(39, 34), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(34, 34), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(34, 39), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(40, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(35, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(35, 40), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([98, 94, 88, 74, 90, 97]), 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([104, 70]), 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([99, 95, 89, 75, 91, 98]), 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([105, 71]), 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, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8)); - this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(83, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(84, 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, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(99, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(90, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([17, 75, 76, 67]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2)); - this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([96, 81]), 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([116, 122]), 65), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(100, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(91, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([17, 76, 77, 68]), 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([97, 82]), 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([120, 126]), 66), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(114, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([118, 120]), 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([69, 115, 77, 78, 79, 116, 102, 85, 103, 118, 119, 106, 108, 122, 109]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([79, 102])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(118, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([122, 124]), 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112, 70, 119, 74, 78, 79, 80, 120, 103, 86, 104, 122, 123, 107, 109, 108, 126, 110]), 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([80, 103])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(8, 14), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); - this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(32, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(21, 65), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(50, formatting.Shared.TokenRange.FromTokens([17, 23])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(33, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(21, 66), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(51, formatting.Shared.TokenRange.FromTokens([17, 23])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8)); this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(17, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8)); this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.TypeNames), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8)); - this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8)); - this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.FromTokens([16, 18, 25, 23])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8)); + this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 26), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8)); + this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(26, formatting.Shared.TokenRange.FromTokens([16, 18, 26, 23])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8)); this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(14, 15), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8)); - this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(52, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([65, 78, 73, 69, 109, 108, 106, 107, 116, 122, 18, 35])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); - this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(83, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); - this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(35, formatting.Shared.TokenRange.FromTokens([65, 16])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); - this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(110, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); - this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([110, 35]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(53, 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([112, 66, 79, 74, 70, 110, 109, 107, 108, 120, 126, 18, 36])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); + this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(84, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); + this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(36, formatting.Shared.TokenRange.FromTokens([66, 16])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(111, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([111, 36]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2)); this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, @@ -30484,43 +32420,44 @@ var ts; this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(16, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8)); - this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(83, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); - this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(83, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(84, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(84, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8)); } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_26 in o) { - if (o[name_26] === rule) { - return name_26; + for (var name_30 in o) { + if (o[name_30] === rule) { + return name_30; } } throw new Error("Unknown rule"); }; Rules.IsForContext = function (context) { - return context.contextNode.kind === 189; + return context.contextNode.kind === 196; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 172: - case 173: - case 143: + case 178: + case 179: + case 186: + case 147: return true; - case 155: - case 206: - case 211: - case 201: - case 131: - case 229: - case 134: - case 133: - return context.currentTokenSpan.kind === 53 || context.nextTokenSpan.kind === 53; - case 190: - return context.currentTokenSpan.kind === 86 || context.nextTokenSpan.kind === 86; - case 191: - return context.currentTokenSpan.kind === 127 || context.nextTokenSpan.kind === 127; + case 160: + case 213: + case 218: + case 208: + case 135: + case 244: + case 138: + case 137: + return context.currentTokenSpan.kind === 54 || context.nextTokenSpan.kind === 54; + case 197: + return context.currentTokenSpan.kind === 87 || context.nextTokenSpan.kind === 87; + case 198: + return context.currentTokenSpan.kind === 131 || context.nextTokenSpan.kind === 131; } return false; }; @@ -30528,7 +32465,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 173; + return context.contextNode.kind === 179; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -30569,85 +32506,85 @@ var ts; return true; } switch (node.kind) { - case 182: - case 210: - case 157: - case 209: + case 189: + case 217: + case 162: + case 216: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 203: - case 136: - case 135: - case 138: - case 139: + case 210: case 140: - case 165: - case 137: - case 166: - case 205: + case 139: + case 142: + case 143: + case 144: + case 170: + case 141: + case 171: + case 212: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 203 || context.contextNode.kind === 165; + return context.contextNode.kind === 210 || context.contextNode.kind === 170; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 204: - case 205: - case 207: - case 148: - case 208: + case 211: + case 212: + case 214: + case 152: + case 215: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 204: - case 208: - case 207: - case 182: - case 226: - case 209: - case 196: + case 211: + case 215: + case 214: + case 189: + case 241: + case 216: + case 203: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 186: + case 193: + case 203: case 196: - case 189: - case 190: - case 191: - case 188: - case 199: - case 187: + case 197: + case 198: case 195: - case 226: + case 206: + case 194: + case 202: + case 241: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 157; + return context.contextNode.kind === 162; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 160; + return context.contextNode.kind === 165; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 161; + return context.contextNode.kind === 166; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -30671,38 +32608,38 @@ var ts; while (ts.isExpression(node)) { node = node.parent; } - return node.kind === 132; + return node.kind === 136; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 202 && + return context.currentTokenParent.kind === 209 && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 208; + return context.contextNode.kind === 215; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 148; + return context.contextNode.kind === 152; }; Rules.IsTypeArgumentOrParameter = function (token, parent) { - if (token.kind !== 24 && token.kind !== 25) { + if (token.kind !== 24 && token.kind !== 26) { return false; } switch (parent.kind) { + case 148: + case 211: + case 212: + case 210: + case 170: + case 171: + case 140: + case 139: case 144: - case 204: - case 205: - case 203: + case 145: case 165: case 166: - case 136: - case 135: - case 140: - case 141: - case 160: - case 161: return true; default: return false; @@ -30713,10 +32650,10 @@ var ts; Rules.IsTypeArgumentOrParameter(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 99 && context.currentTokenParent.kind === 169; + return context.currentTokenSpan.kind === 100 && context.currentTokenParent.kind === 174; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 175 && context.contextNode.expression !== undefined; + return context.contextNode.kind === 181 && context.contextNode.expression !== undefined; }; return Rules; })(); @@ -30739,7 +32676,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 127 + 1; + this.mapRowLength = 131 + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); var rulesBucketConstructionStateList = new Array(this.map.length); this.FillRules(rules, rulesBucketConstructionStateList); @@ -30916,7 +32853,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0; token <= 127; token++) { + for (var token = 0; token <= 131; token++) { result.push(token); } return result; @@ -30958,17 +32895,17 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3])); - TokenRange.Keywords = TokenRange.FromRange(66, 127); - TokenRange.BinaryOperators = TokenRange.FromRange(24, 64); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([86, 87, 127, 117]); - TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([38, 39, 47, 46]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([7, 65, 16, 18, 14, 93, 88]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([65, 16, 93, 88]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([65, 17, 19, 88]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([65, 16, 93, 88]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([65, 17, 19, 88]); + TokenRange.Keywords = TokenRange.FromRange(67, 131); + TokenRange.BinaryOperators = TokenRange.FromRange(24, 65); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([87, 88, 131, 113, 121]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([39, 40, 48, 47]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([7, 66, 16, 18, 14, 94, 89]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([66, 16, 94, 89]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([66, 17, 19, 89]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([66, 16, 94, 89]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([66, 17, 19, 89]); TokenRange.Comments = TokenRange.FromTokens([2, 3]); - TokenRange.TypeNames = TokenRange.FromTokens([65, 121, 123, 113, 124, 99, 112]); + TokenRange.TypeNames = TokenRange.FromTokens([66, 125, 127, 117, 128, 100, 114]); return TokenRange; })(); Shared.TokenRange = TokenRange; @@ -31146,17 +33083,17 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 204: - case 205: + case 211: + case 212: return ts.rangeContainsRange(parent.members, node); - case 208: + case 215: var body = parent.body; - return body && body.kind === 182 && ts.rangeContainsRange(body.statements, node); - case 230: - case 182: - case 209: + return body && body.kind === 189 && ts.rangeContainsRange(body.statements, node); + case 245: + case 189: + case 216: return ts.rangeContainsRange(parent.statements, node); - case 226: + case 241: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -31281,9 +33218,9 @@ var ts; if (indentation === -1) { if (isSomeBlock(node.kind)) { if (isSomeBlock(parent.kind) || - parent.kind === 230 || - parent.kind === 223 || - parent.kind === 224) { + parent.kind === 245 || + parent.kind === 238 || + parent.kind === 239) { indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } else { @@ -31316,18 +33253,18 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 204: return 69; - case 205: return 103; - case 203: return 83; - case 207: return 207; - case 138: return 116; - case 139: return 122; - case 136: + case 211: return 70; + case 212: return 104; + case 210: return 84; + case 214: return 214; + case 142: return 120; + case 143: return 126; + case 140: if (node.asteriskToken) { - return 35; + return 36; } - case 134: - case 131: + case 138: + case 135: return node.name.kind; } } @@ -31352,9 +33289,9 @@ var ts; case 15: case 18: case 19: - case 76: - case 100: - case 52: + case 77: + case 101: + case 53: return indentation; default: return nodeStartLine !== line ? indentation + delta : indentation; @@ -31434,7 +33371,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 132 ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 136 ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; @@ -31724,20 +33661,20 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 182: - case 209: + case 189: + case 216: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 137: - case 203: - case 165: - case 136: - case 135: - case 166: + case 141: + case 210: + case 170: + case 140: + case 139: + case 171: if (node.typeParameters === list) { return 24; } @@ -31745,8 +33682,8 @@ var ts; return 16; } break; - case 160: - case 161: + case 165: + case 166: if (node.typeArguments === list) { return 24; } @@ -31754,7 +33691,7 @@ var ts; return 16; } break; - case 144: + case 148: if (node.typeArguments === list) { return 24; } @@ -31766,7 +33703,7 @@ var ts; case 16: return 17; case 24: - return 25; + return 26; } return 0; } @@ -31846,7 +33783,7 @@ var ts; return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (precedingToken.kind === 23 && precedingToken.parent.kind !== 172) { + if (precedingToken.kind === 23 && precedingToken.parent.kind !== 178) { var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1) { return actualIndentation; @@ -31944,7 +33881,7 @@ var ts; } function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && - (parent.kind === 230 || !parentAndChildShareLine); + (parent.kind === 245 || !parentAndChildShareLine); if (!useActualIndentation) { return -1; } @@ -31968,8 +33905,8 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 186 && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 76, sourceFile); + if (parent.kind === 193 && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 77, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -31980,23 +33917,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 144: + case 148: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 157: + case 162: return node.parent.properties; - case 156: + case 161: return node.parent.elements; - case 203: - case 165: - case 166: - case 136: - case 135: + case 210: + case 170: + case 171: case 140: - case 141: { + case 139: + case 144: + case 145: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -32007,8 +33944,8 @@ var ts; } break; } - case 161: - case 160: { + case 166: + case 165: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -32036,8 +33973,8 @@ var ts; if (node.kind === 17) { return -1; } - if (node.parent && (node.parent.kind === 160 || - node.parent.kind === 161) && + if (node.parent && (node.parent.kind === 165 || + node.parent.kind === 166) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -32055,10 +33992,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 160: - case 161: - case 158: - case 159: + case 165: + case 166: + case 163: + case 164: node = node.expression; break; default: @@ -32113,28 +34050,28 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 204: - case 205: - case 207: - case 156: - case 182: - case 209: - case 157: - case 148: - case 150: - case 210: - case 224: - case 223: - case 164: - case 160: + case 211: + case 212: + case 214: case 161: - case 183: - case 201: - case 217: - case 194: - case 173: + case 189: + case 216: + case 162: + case 152: case 154: - case 153: + case 217: + case 239: + case 238: + case 169: + case 165: + case 166: + case 190: + case 208: + case 224: + case 201: + case 179: + case 159: + case 158: return true; } return false; @@ -32144,22 +34081,22 @@ var ts; return true; } switch (parent) { - case 187: - case 188: - case 190: - case 191: - case 189: - case 186: - case 203: - case 165: - case 136: - case 135: + case 194: + case 195: + case 197: + case 198: + case 196: + case 193: + case 210: + case 170: case 140: - case 166: - case 137: - case 138: case 139: - return child !== 182; + case 144: + case 171: + case 141: + case 142: + case 143: + return child !== 189; default: return false; } @@ -32191,7 +34128,6 @@ var ts; var StringScriptSnapshot = (function () { function StringScriptSnapshot(text) { this.text = text; - this._lineStartPositions = undefined; } StringScriptSnapshot.prototype.getText = function (start, end) { return this.text.substring(start, end); @@ -32254,13 +34190,13 @@ var ts; while (pos < end) { var token = scanner.scan(); var textPos = scanner.getTextPos(); - nodes.push(createNode(token, pos, textPos, 1024, this)); + nodes.push(createNode(token, pos, textPos, 4096, this)); pos = textPos; } return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(253, nodes.pos, nodes.end, 1024, this); + var list = createNode(268, nodes.pos, nodes.end, 4096, this); list._children = []; var pos = nodes.pos; for (var _i = 0; _i < nodes.length; _i++) { @@ -32279,7 +34215,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 128) { + if (this.kind >= 132) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos = this.pos; @@ -32324,7 +34260,7 @@ var ts; var children = this.getChildren(); for (var _i = 0; _i < children.length; _i++) { var child = children[_i]; - if (child.kind < 128) { + if (child.kind < 132) { return child; } return child.getFirstToken(sourceFile); @@ -32334,7 +34270,7 @@ var ts; var children = this.getChildren(sourceFile); for (var i = children.length - 1; i >= 0; i--) { var child = children[i]; - if (child.kind < 128) { + if (child.kind < 132) { return child; } return child.getLastToken(sourceFile); @@ -32380,24 +34316,24 @@ var ts; ts.forEach(declarations, function (declaration, indexOfDeclaration) { if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); - if (canUseParsedParamTagComments && declaration.kind === 131) { + if (canUseParsedParamTagComments && declaration.kind === 135) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { - jsDocCommentParts.push.apply(jsDocCommentParts, cleanedParamJsDocComment); + ts.addRange(jsDocCommentParts, cleanedParamJsDocComment); } }); } - if (declaration.kind === 208 && declaration.body.kind === 208) { + if (declaration.kind === 215 && declaration.body.kind === 215) { return; } - while (declaration.kind === 208 && declaration.parent.kind === 208) { + while (declaration.kind === 215 && declaration.parent.kind === 215) { declaration = declaration.parent; } - ts.forEach(getJsDocCommentTextRange(declaration.kind === 201 ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 208 ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { - jsDocCommentParts.push.apply(jsDocCommentParts, cleanedJsDocComment); + ts.addRange(jsDocCommentParts, cleanedJsDocComment); } }); } @@ -32699,9 +34635,9 @@ var ts; if (result_2 !== undefined) { return result_2; } - if (declaration.name.kind === 129) { + if (declaration.name.kind === 133) { var expr = declaration.name.expression; - if (expr.kind === 158) { + if (expr.kind === 163) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -32711,7 +34647,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 65 || + if (node.kind === 66 || node.kind === 8 || node.kind === 7) { return node.text; @@ -32721,9 +34657,9 @@ var ts; } function visit(node) { switch (node.kind) { - case 203: - case 136: - case 135: + case 210: + case 140: + case 139: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -32740,62 +34676,62 @@ var ts; ts.forEachChild(node, visit); } break; - case 204: - case 205: - case 206: - case 207: - case 208: - case 211: - case 220: - case 216: case 211: + case 212: case 213: case 214: - case 138: - case 139: - case 148: + case 215: + case 218: + case 227: + case 223: + case 218: + case 220: + case 221: + case 142: + case 143: + case 152: addDeclaration(node); - case 137: - case 183: - case 202: - case 153: - case 154: + case 141: + case 190: case 209: + case 158: + case 159: + case 216: ts.forEachChild(node, visit); break; - case 182: + case 189: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 131: + case 135: if (!(node.flags & 112)) { break; } - case 201: - case 155: + case 208: + case 160: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 229: - case 134: - case 133: + case 244: + case 138: + case 137: addDeclaration(node); break; - case 218: + case 225: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 212: + case 219: var importClause = node.importClause; if (importClause) { if (importClause.name) { addDeclaration(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 214) { + if (importClause.namedBindings.kind === 221) { addDeclaration(importClause.namedBindings); } else { @@ -32867,6 +34803,7 @@ var ts; ScriptElementKind.scriptElement = "script"; ScriptElementKind.moduleElement = "module"; ScriptElementKind.classElement = "class"; + ScriptElementKind.localClassElement = "local class"; ScriptElementKind.interfaceElement = "interface"; ScriptElementKind.typeElement = "type"; ScriptElementKind.enumElement = "enum"; @@ -32899,6 +34836,7 @@ var ts; ScriptElementKindModifier.exportedModifier = "export"; ScriptElementKindModifier.ambientModifier = "declare"; ScriptElementKindModifier.staticModifier = "static"; + ScriptElementKindModifier.abstractModifier = "abstract"; })(ScriptElementKindModifier = ts.ScriptElementKindModifier || (ts.ScriptElementKindModifier = {})); var ClassificationTypeNames = (function () { function ClassificationTypeNames() { @@ -32935,14 +34873,14 @@ var ts; return false; } return ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 165) { + if (declaration.kind === 170) { return true; } - if (declaration.kind !== 201 && declaration.kind !== 203) { + if (declaration.kind !== 208 && declaration.kind !== 210) { return false; } for (var parent_9 = declaration.parent; !ts.isFunctionBlock(parent_9); parent_9 = parent_9.parent) { - if (parent_9.kind === 230 || parent_9.kind === 209) { + if (parent_9.kind === 245 || parent_9.kind === 216) { return false; } } @@ -32952,32 +34890,11 @@ var ts; function getDefaultCompilerOptions() { return { target: 1, - module: 0 + module: 0, + jsx: 1 }; } ts.getDefaultCompilerOptions = getDefaultCompilerOptions; - var OperationCanceledException = (function () { - function OperationCanceledException() { - } - return OperationCanceledException; - })(); - ts.OperationCanceledException = OperationCanceledException; - var CancellationTokenObject = (function () { - function CancellationTokenObject(cancellationToken) { - this.cancellationToken = cancellationToken; - } - CancellationTokenObject.prototype.isCancellationRequested = function () { - return this.cancellationToken && this.cancellationToken.isCancellationRequested(); - }; - CancellationTokenObject.prototype.throwIfCancellationRequested = function () { - if (this.isCancellationRequested()) { - throw new OperationCanceledException(); - } - }; - CancellationTokenObject.None = new CancellationTokenObject(null); - return CancellationTokenObject; - })(); - ts.CancellationTokenObject = CancellationTokenObject; var HostCache = (function () { function HostCache(host, getCanonicalFileName) { this.host = host; @@ -33260,25 +35177,25 @@ var ts; scanner.setText(sourceText); var token = scanner.scan(); while (token !== 1) { - if (token === 85) { + if (token === 86) { token = scanner.scan(); if (token === 8) { recordModuleName(); continue; } else { - if (token === 65) { + if (token === 66) { token = scanner.scan(); - if (token === 126) { + if (token === 130) { token = scanner.scan(); if (token === 8) { recordModuleName(); continue; } } - else if (token === 53) { + else if (token === 54) { token = scanner.scan(); - if (token === 120) { + if (token === 124) { token = scanner.scan(); if (token === 16) { token = scanner.scan(); @@ -33303,7 +35220,7 @@ var ts; } if (token === 15) { token = scanner.scan(); - if (token === 126) { + if (token === 130) { token = scanner.scan(); if (token === 8) { recordModuleName(); @@ -33311,13 +35228,13 @@ var ts; } } } - else if (token === 35) { + else if (token === 36) { token = scanner.scan(); - if (token === 111) { + if (token === 113) { token = scanner.scan(); - if (token === 65) { + if (token === 66) { token = scanner.scan(); - if (token === 126) { + if (token === 130) { token = scanner.scan(); if (token === 8) { recordModuleName(); @@ -33328,7 +35245,7 @@ var ts; } } } - else if (token === 78) { + else if (token === 79) { token = scanner.scan(); if (token === 14) { token = scanner.scan(); @@ -33337,7 +35254,7 @@ var ts; } if (token === 15) { token = scanner.scan(); - if (token === 126) { + if (token === 130) { token = scanner.scan(); if (token === 8) { recordModuleName(); @@ -33345,9 +35262,9 @@ var ts; } } } - else if (token === 35) { + else if (token === 36) { token = scanner.scan(); - if (token === 126) { + if (token === 130) { token = scanner.scan(); if (token === 8) { recordModuleName(); @@ -33368,7 +35285,7 @@ var ts; ts.preProcessFile = preProcessFile; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 197 && referenceNode.label.text === labelName) { + if (referenceNode.kind === 204 && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -33376,17 +35293,17 @@ var ts; return undefined; } function isJumpStatementTarget(node) { - return node.kind === 65 && - (node.parent.kind === 193 || node.parent.kind === 192) && + return node.kind === 66 && + (node.parent.kind === 200 || node.parent.kind === 199) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { - return node.kind === 65 && - node.parent.kind === 197 && + return node.kind === 66 && + node.parent.kind === 204 && node.parent.label === node; } function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 197; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 204; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -33397,48 +35314,48 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 128 && node.parent.right === node; + return node.parent.kind === 132 && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 158 && node.parent.name === node; + return node && node.parent && node.parent.kind === 163 && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 160 && node.parent.expression === node; + return node && node.parent && node.parent.kind === 165 && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 161 && node.parent.expression === node; + return node && node.parent && node.parent.kind === 166 && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 208 && node.parent.name === node; + return node.parent.kind === 215 && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { - return node.kind === 65 && + return node.kind === 66 && ts.isFunctionLike(node.parent) && node.parent.name === node; } function isNameOfPropertyAssignment(node) { - return (node.kind === 65 || node.kind === 8 || node.kind === 7) && - (node.parent.kind === 227 || node.parent.kind === 228) && node.parent.name === node; + return (node.kind === 66 || node.kind === 8 || node.kind === 7) && + (node.parent.kind === 242 || node.parent.kind === 243) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 8 || node.kind === 7) { switch (node.parent.kind) { - case 134: - case 133: - case 227: - case 229: - case 136: - case 135: case 138: + case 137: + case 242: + case 244: + case 140: case 139: - case 208: + case 142: + case 143: + case 215: return node.parent.name === node; - case 159: + case 164: return node.parent.argumentExpression === node; } } @@ -33476,7 +35393,7 @@ var ts; } } var keywordCompletions = []; - for (var i = 66; i <= 127; i++) { + for (var i = 67; i <= 131; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -33491,17 +35408,17 @@ var ts; return undefined; } switch (node.kind) { - case 230: - case 136: - case 135: - case 203: - case 165: - case 138: + case 245: + case 140: case 139: - case 204: - case 205: - case 207: - case 208: + case 210: + case 170: + case 142: + case 143: + case 211: + case 212: + case 214: + case 215: return node; } } @@ -33509,43 +35426,57 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 208: return ScriptElementKind.moduleElement; - case 204: return ScriptElementKind.classElement; - case 205: return ScriptElementKind.interfaceElement; - case 206: return ScriptElementKind.typeElement; - case 207: return ScriptElementKind.enumElement; - case 201: + case 215: return ScriptElementKind.moduleElement; + case 211: return ScriptElementKind.classElement; + case 212: return ScriptElementKind.interfaceElement; + case 213: return ScriptElementKind.typeElement; + case 214: return ScriptElementKind.enumElement; + case 208: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 203: return ScriptElementKind.functionElement; - case 138: return ScriptElementKind.memberGetAccessorElement; - case 139: return ScriptElementKind.memberSetAccessorElement; - case 136: - case 135: + case 210: return ScriptElementKind.functionElement; + case 142: return ScriptElementKind.memberGetAccessorElement; + case 143: return ScriptElementKind.memberSetAccessorElement; + case 140: + case 139: return ScriptElementKind.memberFunctionElement; - case 134: - case 133: + case 138: + case 137: return ScriptElementKind.memberVariableElement; - case 142: return ScriptElementKind.indexSignatureElement; - case 141: return ScriptElementKind.constructSignatureElement; - case 140: return ScriptElementKind.callSignatureElement; - case 137: return ScriptElementKind.constructorImplementationElement; - case 130: return ScriptElementKind.typeParameterElement; - case 229: return ScriptElementKind.variableElement; - case 131: return (node.flags & 112) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 211: - case 216: - case 213: + case 146: return ScriptElementKind.indexSignatureElement; + case 145: return ScriptElementKind.constructSignatureElement; + case 144: return ScriptElementKind.callSignatureElement; + case 141: return ScriptElementKind.constructorImplementationElement; + case 134: return ScriptElementKind.typeParameterElement; + case 244: return ScriptElementKind.variableElement; + case 135: return (node.flags & 112) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 218: + case 223: case 220: - case 214: + case 227: + case 221: return ScriptElementKind.alias; } return ScriptElementKind.unknown; } ts.getNodeKind = getNodeKind; + var CancellationTokenObject = (function () { + function CancellationTokenObject(cancellationToken) { + this.cancellationToken = cancellationToken; + } + CancellationTokenObject.prototype.isCancellationRequested = function () { + return this.cancellationToken && this.cancellationToken.isCancellationRequested(); + }; + CancellationTokenObject.prototype.throwIfCancellationRequested = function () { + if (this.isCancellationRequested()) { + throw new ts.OperationCanceledException(); + } + }; + return CancellationTokenObject; + })(); function createLanguageService(host, documentRegistry) { if (documentRegistry === void 0) { documentRegistry = createDocumentRegistry(); } var syntaxTreeCache = new SyntaxTreeCache(host); @@ -33668,7 +35599,7 @@ var ts; } function getSyntacticDiagnostics(fileName) { synchronizeHostData(); - return program.getSyntacticDiagnostics(getValidSourceFile(fileName)); + return program.getSyntacticDiagnostics(getValidSourceFile(fileName), cancellationToken); } function getSemanticDiagnostics(fileName) { synchronizeHostData(); @@ -33676,11 +35607,11 @@ var ts; if (ts.isJavaScript(fileName)) { return getJavaScriptSemanticDiagnostics(targetSourceFile); } - var semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile); + var semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile, cancellationToken); if (!program.getCompilerOptions().declaration) { return semanticDiagnostics; } - var declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile); + var declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile, cancellationToken); return ts.concatenate(semanticDiagnostics, declarationDiagnostics); } function getJavaScriptSemanticDiagnostics(sourceFile) { @@ -33692,44 +35623,44 @@ var ts; return false; } switch (node.kind) { - case 211: + case 218: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 217: + case 224: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; - case 204: + case 211: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 225: + case 240: var heritageClause = node; - if (heritageClause.token === 102) { + if (heritageClause.token === 103) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 205: + case 212: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 208: + case 215: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 206: + case 213: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 136: - case 135: - case 137: - case 138: + case 140: case 139: - case 165: - case 203: - case 166: - case 203: + case 141: + case 142: + case 143: + case 170: + case 210: + case 171: + case 210: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -33737,20 +35668,20 @@ var ts; return true; } break; - case 183: + case 190: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 201: + case 208: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 160: - case 161: + case 165: + case 166: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -33758,7 +35689,7 @@ var ts; return true; } break; - case 131: + case 135: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -33774,17 +35705,17 @@ var ts; return true; } break; - case 134: + case 138: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 207: + case 214: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 163: + case 168: 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 132: + case 136: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); return true; } @@ -33810,16 +35741,17 @@ var ts; for (var _i = 0; _i < modifiers.length; _i++) { var modifier = modifiers[_i]; switch (modifier.kind) { - case 108: - case 106: + case 109: case 107: - case 115: + case 108: + case 119: diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; - case 109: - case 78: - case 70: - case 73: + case 110: + case 79: + case 71: + case 74: + case 112: } } } @@ -33828,17 +35760,11 @@ var ts; } function getCompilerOptionsDiagnostics() { synchronizeHostData(); - return program.getOptionsDiagnostics().concat(program.getGlobalDiagnostics()); + return program.getOptionsDiagnostics(cancellationToken).concat(program.getGlobalDiagnostics(cancellationToken)); } - function getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks) { - var displayName = symbol.getName(); + function getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks, location) { + var displayName = ts.getDeclaredName(program.getTypeChecker(), symbol, location); if (displayName) { - if (displayName === "default") { - var localSymbol = ts.getLocalSymbolForExportDefault(symbol); - if (localSymbol && localSymbol.name) { - displayName = symbol.valueDeclaration.localSymbol.name; - } - } var firstCharCode = displayName.charCodeAt(0); if ((symbol.flags & 1536) && (firstCharCode === 39 || firstCharCode === 34)) { return undefined; @@ -33846,30 +35772,25 @@ var ts; } return getCompletionEntryDisplayName(displayName, target, performCharacterChecks); } - function getCompletionEntryDisplayName(displayName, target, performCharacterChecks) { - if (!displayName) { + function getCompletionEntryDisplayName(name, target, performCharacterChecks) { + if (!name) { return undefined; } - var firstCharCode = displayName.charCodeAt(0); - if (displayName.length >= 2 && - firstCharCode === displayName.charCodeAt(displayName.length - 1) && - (firstCharCode === 39 || firstCharCode === 34)) { - displayName = displayName.substring(1, displayName.length - 1); - } - if (!displayName) { + name = ts.stripQuotes(name); + if (!name) { return undefined; } if (performCharacterChecks) { - if (!ts.isIdentifierStart(displayName.charCodeAt(0), target)) { + if (!ts.isIdentifierStart(name.charCodeAt(0), target)) { return undefined; } - for (var i = 1, n = displayName.length; i < n; i++) { - if (!ts.isIdentifierPart(displayName.charCodeAt(i), target)) { + for (var i = 1, n = name.length; i < n; i++) { + if (!ts.isIdentifierPart(name.charCodeAt(i), target)) { return undefined; } } } - return ts.unescapeIdentifier(displayName); + return name; } function getCompletionData(fileName, position) { var typeChecker = program.getTypeChecker(); @@ -33895,22 +35816,34 @@ var ts; contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile); log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start_2)); } - if (contextToken && isCompletionListBlocker(contextToken)) { - log("Returning an empty list because completion was requested in an invalid position."); - return undefined; - } var node = currentToken; var isRightOfDot = false; - if (contextToken && contextToken.kind === 20 && contextToken.parent.kind === 158) { - node = contextToken.parent.expression; - isRightOfDot = true; - } - else if (contextToken && contextToken.kind === 20 && contextToken.parent.kind === 128) { - node = contextToken.parent.left; - isRightOfDot = true; - } + var isRightOfOpenTag = false; var location = ts.getTouchingPropertyName(sourceFile, position); - var target = program.getCompilerOptions().target; + if (contextToken) { + if (isCompletionListBlocker(contextToken)) { + log("Returning an empty list because completion was requested in an invalid position."); + return undefined; + } + var parent_10 = contextToken.parent, kind = contextToken.kind; + if (kind === 20) { + if (parent_10.kind === 163) { + node = contextToken.parent.expression; + isRightOfDot = true; + } + else if (parent_10.kind === 132) { + node = contextToken.parent.left; + isRightOfDot = true; + } + else { + return undefined; + } + } + else if (kind === 24 && sourceFile.languageVariant === 1) { + isRightOfOpenTag = true; + location = contextToken; + } + } var semanticStart = new Date().getTime(); var isMemberCompletion; var isNewIdentifierLocation; @@ -33918,17 +35851,28 @@ var ts; if (isRightOfDot) { getTypeScriptMemberSymbols(); } + else if (isRightOfOpenTag) { + var tagSymbols = typeChecker.getJsxIntrinsicTagNames(); + if (tryGetGlobalSymbols()) { + symbols = tagSymbols.concat(symbols.filter(function (s) { return !!(s.flags & 107455); })); + } + else { + symbols = tagSymbols; + } + isMemberCompletion = true; + isNewIdentifierLocation = false; + } else { if (!tryGetGlobalSymbols()) { return undefined; } } log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart)); - return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: isRightOfDot }; + return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag) }; function getTypeScriptMemberSymbols() { isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 65 || node.kind === 128 || node.kind === 158) { + if (node.kind === 66 || node.kind === 132 || node.kind === 163) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol && symbol.flags & 8388608) { symbol = typeChecker.getAliasedSymbol(symbol); @@ -33963,48 +35907,38 @@ var ts; } } function tryGetGlobalSymbols() { - var containingObjectLiteral = getContainingObjectLiteralApplicableForCompletion(contextToken); - if (containingObjectLiteral) { - isMemberCompletion = true; - isNewIdentifierLocation = true; - var contextualType = typeChecker.getContextualType(containingObjectLiteral); - if (!contextualType) { - return false; - } - var contextualTypeMembers = typeChecker.getPropertiesOfType(contextualType); - if (contextualTypeMembers && contextualTypeMembers.length > 0) { - symbols = filterContextualMembersList(contextualTypeMembers, containingObjectLiteral.properties); - } + var objectLikeContainer; + var importClause; + var jsxContainer; + if (objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken)) { + return tryGetObjectLikeCompletionSymbols(objectLikeContainer); } - else if (ts.getAncestor(contextToken, 213)) { - isMemberCompletion = true; - isNewIdentifierLocation = true; - if (showCompletionsInImportsClause(contextToken)) { - var importDeclaration = ts.getAncestor(contextToken, 212); - ts.Debug.assert(importDeclaration !== undefined); - var exports_2; - if (importDeclaration.moduleSpecifier) { - var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importDeclaration.moduleSpecifier); - if (moduleSpecifierSymbol) { - exports_2 = typeChecker.getExportsOfModule(moduleSpecifierSymbol); - } + if (importClause = ts.getAncestor(contextToken, 220)) { + return tryGetImportClauseCompletionSymbols(importClause); + } + if (jsxContainer = tryGetContainingJsxElement(contextToken)) { + var attrsType; + if ((jsxContainer.kind === 231) || (jsxContainer.kind === 232)) { + attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); + if (attrsType) { + symbols = filterJsxAttributes(jsxContainer.attributes, typeChecker.getPropertiesOfType(attrsType)); + isMemberCompletion = true; + isNewIdentifierLocation = false; + return true; } - symbols = exports_2 ? filterModuleExports(exports_2, importDeclaration) : emptyArray; } } - else { - isMemberCompletion = false; - isNewIdentifierLocation = isNewIdentifierDefinitionLocation(contextToken); - if (previousToken !== contextToken) { - ts.Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); - } - var adjustedPosition = previousToken !== contextToken ? - previousToken.getStart() : - position; - var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; - var symbolMeanings = 793056 | 107455 | 1536 | 8388608; - symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); + isMemberCompletion = false; + isNewIdentifierLocation = isNewIdentifierDefinitionLocation(contextToken); + if (previousToken !== contextToken) { + ts.Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); } + var adjustedPosition = previousToken !== contextToken ? + previousToken.getStart() : + position; + var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; + var symbolMeanings = 793056 | 107455 | 1536 | 8388608; + symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); return true; } function getScopeNode(initialToken, position, sourceFile) { @@ -34014,18 +35948,18 @@ var ts; } return scope; } - function isCompletionListBlocker(previousToken) { + function isCompletionListBlocker(contextToken) { var start = new Date().getTime(); - var result = isInStringOrRegularExpressionOrTemplateLiteral(previousToken) || - isIdentifierDefinitionLocation(previousToken) || - isRightOfIllegalDot(previousToken); + var result = isInStringOrRegularExpressionOrTemplateLiteral(contextToken) || + isIdentifierDefinitionLocation(contextToken) || + isDotOfNumericLiteral(contextToken); log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - start)); return result; } - function showCompletionsInImportsClause(node) { + function shouldShowCompletionsInImportsClause(node) { if (node) { if (node.kind === 14 || node.kind === 23) { - return node.parent.kind === 215; + return node.parent.kind === 222; } } return false; @@ -34035,38 +35969,40 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 23: - return containingNodeKind === 160 - || containingNodeKind === 137 + return containingNodeKind === 165 + || containingNodeKind === 141 + || containingNodeKind === 166 || containingNodeKind === 161 - || containingNodeKind === 156 - || containingNodeKind === 172 - || containingNodeKind === 145; + || containingNodeKind === 178 + || containingNodeKind === 149; case 16: - return containingNodeKind === 160 - || containingNodeKind === 137 - || containingNodeKind === 161 - || containingNodeKind === 164 - || containingNodeKind === 152; + return containingNodeKind === 165 + || containingNodeKind === 141 + || containingNodeKind === 166 + || containingNodeKind === 169 + || containingNodeKind === 157; case 18: - return containingNodeKind === 156; - case 118: - case 119: + return containingNodeKind === 161 + || containingNodeKind === 146 + || containingNodeKind === 133; + case 122: + case 123: return true; case 20: - return containingNodeKind === 208; + return containingNodeKind === 215; case 14: - return containingNodeKind === 204; - case 53: - return containingNodeKind === 201 - || containingNodeKind === 172; + return containingNodeKind === 211; + case 54: + return containingNodeKind === 208 + || containingNodeKind === 178; case 11: - return containingNodeKind === 174; - case 12: return containingNodeKind === 180; - case 108: - case 106: + case 12: + return containingNodeKind === 187; + case 109: case 107: - return containingNodeKind === 134; + case 108: + return containingNodeKind === 138; } switch (previousToken.getText()) { case "public": @@ -34077,31 +36013,98 @@ var ts; } return false; } - function isInStringOrRegularExpressionOrTemplateLiteral(previousToken) { - if (previousToken.kind === 8 - || previousToken.kind === 9 - || ts.isTemplateLiteralKind(previousToken.kind)) { - var start_3 = previousToken.getStart(); - var end = previousToken.getEnd(); + function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { + if (contextToken.kind === 8 + || contextToken.kind === 9 + || ts.isTemplateLiteralKind(contextToken.kind)) { + var start_3 = contextToken.getStart(); + var end = contextToken.getEnd(); if (start_3 < position && position < end) { return true; } if (position === end) { - return !!previousToken.isUnterminated || - previousToken.kind === 9; + return !!contextToken.isUnterminated + || contextToken.kind === 9; } } return false; } - function getContainingObjectLiteralApplicableForCompletion(previousToken) { - // The locations in an object literal expression that are applicable for completion are property name definition locations. - if (previousToken) { - var parent_10 = previousToken.parent; - switch (previousToken.kind) { + function tryGetObjectLikeCompletionSymbols(objectLikeContainer) { + isMemberCompletion = true; + var typeForObject; + var existingMembers; + if (objectLikeContainer.kind === 162) { + isNewIdentifierLocation = true; + typeForObject = typeChecker.getContextualType(objectLikeContainer); + existingMembers = objectLikeContainer.properties; + } + else if (objectLikeContainer.kind === 158) { + isNewIdentifierLocation = false; + typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); + existingMembers = objectLikeContainer.elements; + } + else { + ts.Debug.fail("Expected object literal or binding pattern, got " + objectLikeContainer.kind); + } + if (!typeForObject) { + return false; + } + var typeMembers = typeChecker.getPropertiesOfType(typeForObject); + if (typeMembers && typeMembers.length > 0) { + symbols = filterObjectMembersList(typeMembers, existingMembers); + } + return true; + } + function tryGetImportClauseCompletionSymbols(importClause) { + if (shouldShowCompletionsInImportsClause(contextToken)) { + isMemberCompletion = true; + isNewIdentifierLocation = false; + var importDeclaration = importClause.parent; + ts.Debug.assert(importDeclaration !== undefined && importDeclaration.kind === 219); + var exports_2; + var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importDeclaration.moduleSpecifier); + if (moduleSpecifierSymbol) { + exports_2 = typeChecker.getExportsOfModule(moduleSpecifierSymbol); + } + symbols = exports_2 ? filterModuleExports(exports_2, importDeclaration) : emptyArray; + } + else { + isMemberCompletion = false; + isNewIdentifierLocation = true; + } + return true; + } + function tryGetObjectLikeCompletionContainer(contextToken) { + if (contextToken) { + switch (contextToken.kind) { case 14: case 23: - if (parent_10 && parent_10.kind === 157) { - return parent_10; + var parent_11 = contextToken.parent; + if (parent_11 && (parent_11.kind === 162 || parent_11.kind === 158)) { + return parent_11; + } + break; + } + } + return undefined; + } + function tryGetContainingJsxElement(contextToken) { + if (contextToken) { + var parent_12 = contextToken.parent; + switch (contextToken.kind) { + case 25: + case 37: + case 66: + if (parent_12 && (parent_12.kind === 231 || parent_12.kind === 232)) { + return parent_12; + } + break; + case 15: + if (parent_12 && + parent_12.kind === 237 && + parent_12.parent && + parent_12.parent.kind === 235) { + return parent_12.parent.parent; } break; } @@ -34110,102 +36113,97 @@ var ts; } function isFunction(kind) { switch (kind) { - case 165: - case 166: - case 203: - case 136: - case 135: - case 138: - case 139: + case 170: + case 171: + case 210: case 140: - case 141: + case 139: case 142: + case 143: + case 144: + case 145: + case 146: return true; } return false; } - function isIdentifierDefinitionLocation(previousToken) { - if (previousToken) { - var containingNodeKind = previousToken.parent.kind; - switch (previousToken.kind) { - case 23: - return containingNodeKind === 201 || - containingNodeKind === 202 || - containingNodeKind === 183 || - containingNodeKind === 207 || - isFunction(containingNodeKind) || - containingNodeKind === 204 || - containingNodeKind === 203 || - containingNodeKind === 205 || - containingNodeKind === 154 || - containingNodeKind === 153; - case 20: - return containingNodeKind === 154; - case 51: - return containingNodeKind === 155; - case 18: - return containingNodeKind === 154; - case 16: - return containingNodeKind === 226 || - isFunction(containingNodeKind); - case 14: - return containingNodeKind === 207 || - containingNodeKind === 205 || - containingNodeKind === 148 || - containingNodeKind === 153; - case 22: - return containingNodeKind === 133 && - previousToken.parent && previousToken.parent.parent && - (previousToken.parent.parent.kind === 205 || - previousToken.parent.parent.kind === 148); - case 24: - return containingNodeKind === 204 || - containingNodeKind === 203 || - containingNodeKind === 205 || - isFunction(containingNodeKind); - case 109: - return containingNodeKind === 134; - case 21: - return containingNodeKind === 131 || - containingNodeKind === 137 || - (previousToken.parent && previousToken.parent.parent && - previousToken.parent.parent.kind === 154); - case 108: - case 106: - case 107: - return containingNodeKind === 131; - case 69: - case 77: - case 103: - case 83: - case 98: - case 116: - case 122: - case 85: - case 104: - case 70: - case 110: - case 125: - return true; - } - switch (previousToken.getText()) { - case "class": - case "interface": - case "enum": - case "function": - case "var": - case "static": - case "let": - case "const": - case "yield": - return true; - } + function isIdentifierDefinitionLocation(contextToken) { + var containingNodeKind = contextToken.parent.kind; + switch (contextToken.kind) { + case 23: + return containingNodeKind === 208 || + containingNodeKind === 209 || + containingNodeKind === 190 || + containingNodeKind === 214 || + isFunction(containingNodeKind) || + containingNodeKind === 211 || + containingNodeKind === 210 || + containingNodeKind === 212 || + containingNodeKind === 159; + case 20: + return containingNodeKind === 159; + case 52: + return containingNodeKind === 160; + case 18: + return containingNodeKind === 159; + case 16: + return containingNodeKind === 241 || + isFunction(containingNodeKind); + case 14: + return containingNodeKind === 214 || + containingNodeKind === 212 || + containingNodeKind === 152; + case 22: + return containingNodeKind === 137 && + contextToken.parent && contextToken.parent.parent && + (contextToken.parent.parent.kind === 212 || + contextToken.parent.parent.kind === 152); + case 24: + return containingNodeKind === 211 || + containingNodeKind === 210 || + containingNodeKind === 212 || + isFunction(containingNodeKind); + case 110: + return containingNodeKind === 138; + case 21: + return containingNodeKind === 135 || + (contextToken.parent && contextToken.parent.parent && + contextToken.parent.parent.kind === 159); + case 109: + case 107: + case 108: + return containingNodeKind === 135; + case 70: + case 78: + case 104: + case 84: + case 99: + case 120: + case 126: + case 86: + case 105: + case 71: + case 111: + case 129: + return true; + } + switch (contextToken.getText()) { + case "class": + case "interface": + case "enum": + case "function": + case "var": + case "static": + case "let": + case "const": + case "yield": + return true; } return false; } - function isRightOfIllegalDot(previousToken) { - if (previousToken && previousToken.kind === 7) { - var text = previousToken.getFullText(); + function isDotOfNumericLiteral(contextToken) { + if (contextToken.kind === 7) { + var text = contextToken.getFullText(); return text.charAt(text.length - 1) === "."; } return false; @@ -34216,8 +36214,11 @@ var ts; return exports; } if (importDeclaration.importClause.namedBindings && - importDeclaration.importClause.namedBindings.kind === 215) { + importDeclaration.importClause.namedBindings.kind === 222) { ts.forEach(importDeclaration.importClause.namedBindings.elements, function (el) { + if (el.getStart() <= position && position <= el.getEnd()) { + return; + } var name = el.propertyName || el.name; exisingImports[name.text] = true; }); @@ -34227,20 +36228,30 @@ var ts; } return ts.filter(exports, function (e) { return !ts.lookUp(exisingImports, e.name); }); } - function filterContextualMembersList(contextualMemberSymbols, existingMembers) { + function filterObjectMembersList(contextualMemberSymbols, existingMembers) { if (!existingMembers || existingMembers.length === 0) { return contextualMemberSymbols; } var existingMemberNames = {}; - ts.forEach(existingMembers, function (m) { - if (m.kind !== 227 && m.kind !== 228) { - return; + for (var _i = 0; _i < existingMembers.length; _i++) { + var m = existingMembers[_i]; + if (m.kind !== 242 && + m.kind !== 243 && + m.kind !== 160) { + continue; } if (m.getStart() <= position && position <= m.getEnd()) { - return; + continue; } - existingMemberNames[m.name.text] = true; - }); + var existingName = void 0; + if (m.kind === 160 && m.propertyName) { + existingName = m.propertyName.text; + } + else { + existingName = m.name.text; + } + existingMemberNames[existingName] = true; + } var filteredMembers = []; ts.forEach(contextualMemberSymbols, function (s) { if (!existingMemberNames[s.name]) { @@ -34249,6 +36260,26 @@ var ts; }); return filteredMembers; } + function filterJsxAttributes(attributes, symbols) { + var seenNames = {}; + for (var _i = 0; _i < attributes.length; _i++) { + var attr = attributes[_i]; + if (attr.getStart() <= position && position <= attr.getEnd()) { + continue; + } + if (attr.kind === 235) { + seenNames[attr.name.text] = true; + } + } + var result = []; + for (var _a = 0; _a < symbols.length; _a++) { + var sym = symbols[_a]; + if (!seenNames[sym.name]) { + result.push(sym); + } + } + return result; + } } function getCompletionsAtPosition(fileName, position) { synchronizeHostData(); @@ -34279,10 +36310,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_27 in nameTable) { - if (!allNames[name_27]) { - allNames[name_27] = name_27; - var displayName = getCompletionEntryDisplayName(name_27, target, true); + for (var name_31 in nameTable) { + if (!allNames[name_31]) { + allNames[name_31] = name_31; + var displayName = getCompletionEntryDisplayName(name_31, target, true); if (displayName) { var entry = { name: displayName, @@ -34298,7 +36329,7 @@ var ts; return entries; } function createCompletionEntry(symbol, location) { - var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, true); + var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, true, location); if (!displayName) { return undefined; } @@ -34336,15 +36367,15 @@ var ts; if (completionData) { var symbols = completionData.symbols, location_2 = completionData.location; var target = program.getCompilerOptions().target; - var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target, false) === entryName ? s : undefined; }); + var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target, false, location_2) === entryName ? s : undefined; }); if (symbol) { - var displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location_2, location_2, 7); + var _a = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location_2, location_2, 7), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; return { name: entryName, - kind: displayPartsDocumentationsAndSymbolKind.symbolKind, kindModifiers: getSymbolModifiers(symbol), - displayParts: displayPartsDocumentationsAndSymbolKind.displayParts, - documentation: displayPartsDocumentationsAndSymbolKind.documentation + kind: symbolKind, + displayParts: displayParts, + documentation: documentation }; } } @@ -34363,7 +36394,8 @@ var ts; function getSymbolKind(symbol, location) { var flags = symbol.getFlags(); if (flags & 32) - return ScriptElementKind.classElement; + return ts.getDeclarationOfKind(symbol, 183) ? + ScriptElementKind.localClassElement : ScriptElementKind.classElement; if (flags & 384) return ScriptElementKind.enumElement; if (flags & 524288) @@ -34458,14 +36490,14 @@ var ts; var signature; type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 158) { + if (location.parent && location.parent.kind === 163) { var right = location.parent.name; if (right === location || (right && right.getFullWidth() === 0)) { location = location.parent; } } var callExpression; - if (location.kind === 160 || location.kind === 161) { + if (location.kind === 165 || location.kind === 166) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -34477,7 +36509,7 @@ var ts; if (!signature && candidateSignatures.length) { signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 161 || callExpression.expression.kind === 91; + var useConstructSignatures = callExpression.kind === 166 || callExpression.expression.kind === 92; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target || signature)) { signature = allSignatures.length ? allSignatures[0] : undefined; @@ -34492,7 +36524,7 @@ var ts; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(88)); + displayParts.push(ts.keywordPart(89)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -34507,14 +36539,14 @@ var ts; case ScriptElementKind.letElement: case ScriptElementKind.parameterElement: case ScriptElementKind.localVariableElement: - displayParts.push(ts.punctuationPart(51)); + displayParts.push(ts.punctuationPart(52)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(88)); + displayParts.push(ts.keywordPart(89)); displayParts.push(ts.spacePart()); } - if (!(type.flags & 32768)) { - displayParts.push.apply(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, undefined, 1)); + if (!(type.flags & 65536)) { + ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, undefined, 1)); } addSignatureDisplayParts(signature, allSignatures, 8); break; @@ -34525,21 +36557,21 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304)) || - (location.kind === 114 && location.parent.kind === 137)) { + (location.kind === 118 && location.parent.kind === 141)) { var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 137 ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 141 ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 137) { + if (functionDeclaration.kind === 141) { symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 140 && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 144 && !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -34548,43 +36580,48 @@ var ts; } } if (symbolFlags & 32 && !hasAddedSymbolInfo) { - displayParts.push(ts.keywordPart(69)); + if (ts.getDeclarationOfKind(symbol, 183)) { + pushTypePart(ScriptElementKind.localClassElement); + } + else { + displayParts.push(ts.keywordPart(70)); + } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if ((symbolFlags & 64) && (semanticMeaning & 2)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(103)); + displayParts.push(ts.keywordPart(104)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & 524288) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(125)); + displayParts.push(ts.keywordPart(129)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(53)); + displayParts.push(ts.operatorPart(54)); displayParts.push(ts.spacePart()); - displayParts.push.apply(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); + 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(70)); + displayParts.push(ts.keywordPart(71)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(77)); + displayParts.push(ts.keywordPart(78)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 208); - var isNamespace = declaration && declaration.name && declaration.name.kind === 65; - displayParts.push(ts.keywordPart(isNamespace ? 119 : 118)); + var declaration = ts.getDeclarationOfKind(symbol, 215); + var isNamespace = declaration && declaration.name && declaration.name.kind === 66; + displayParts.push(ts.keywordPart(isNamespace ? 123 : 122)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -34596,33 +36633,33 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(86)); + displayParts.push(ts.keywordPart(87)); displayParts.push(ts.spacePart()); if (symbol.parent) { addFullSymbolName(symbol.parent, enclosingDeclaration); writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); } else { - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 130).parent; + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 134).parent; var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 141) { - displayParts.push(ts.keywordPart(88)); + if (signatureDeclaration.kind === 145) { + displayParts.push(ts.keywordPart(89)); displayParts.push(ts.spacePart()); } - else if (signatureDeclaration.kind !== 140 && signatureDeclaration.name) { + else if (signatureDeclaration.kind !== 144 && signatureDeclaration.name) { addFullSymbolName(signatureDeclaration.symbol); } - displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); } } if (symbolFlags & 8) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 229) { + if (declaration.kind === 244) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(53)); + displayParts.push(ts.operatorPart(54)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(constantValue.toString(), SymbolDisplayPartKind.numericLiteral)); } @@ -34630,17 +36667,17 @@ var ts; } if (symbolFlags & 8388608) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(85)); + displayParts.push(ts.keywordPart(86)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 211) { + if (declaration.kind === 218) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(53)); + displayParts.push(ts.operatorPart(54)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(120)); + displayParts.push(ts.keywordPart(124)); displayParts.push(ts.punctuationPart(16)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(17)); @@ -34649,7 +36686,7 @@ var ts; var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(53)); + displayParts.push(ts.operatorPart(54)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -34665,16 +36702,16 @@ var ts; if (symbolKind === ScriptElementKind.memberVariableElement || symbolFlags & 3 || symbolKind === ScriptElementKind.localVariableElement) { - displayParts.push(ts.punctuationPart(51)); + displayParts.push(ts.punctuationPart(52)); displayParts.push(ts.spacePart()); if (type.symbol && type.symbol.flags & 262144) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplay(type, writer, enclosingDeclaration); }); - displayParts.push.apply(displayParts, typeParameterParts); + ts.addRange(displayParts, typeParameterParts); } else { - displayParts.push.apply(displayParts, ts.typeToDisplayParts(typeChecker, type, enclosingDeclaration)); + ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, type, enclosingDeclaration)); } } else if (symbolFlags & 16 || @@ -34703,7 +36740,7 @@ var ts; } function addFullSymbolName(symbol, enclosingDeclaration) { var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, undefined, 1 | 2); - displayParts.push.apply(displayParts, fullSymbolDisplayParts); + ts.addRange(displayParts, fullSymbolDisplayParts); } function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { addNewLineIfDisplayPartsExist(); @@ -34730,11 +36767,11 @@ var ts; } } function addSignatureDisplayParts(signature, allSignatures, flags) { - displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32)); + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); displayParts.push(ts.punctuationPart(16)); - displayParts.push(ts.operatorPart(33)); + displayParts.push(ts.operatorPart(34)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); @@ -34746,7 +36783,7 @@ var ts; var typeParameterParts = ts.mapToDisplayParts(function (writer) { typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration); }); - displayParts.push.apply(displayParts, typeParameterParts); + ts.addRange(displayParts, typeParameterParts); } } function getQuickInfoAtPosition(fileName, position) { @@ -34763,11 +36800,11 @@ var ts; var symbol = typeChecker.getSymbolAtLocation(node); if (!symbol) { switch (node.kind) { - case 65: - case 158: - case 128: - case 93: - case 91: + case 66: + case 163: + case 132: + case 94: + case 92: var type = typeChecker.getTypeAtLocation(node); if (type) { return { @@ -34816,10 +36853,10 @@ var ts; } return result; function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { - if (isNewExpressionTarget(location) || location.kind === 114) { + if (isNewExpressionTarget(location) || location.kind === 118) { if (symbol.flags & 32) { var classDeclaration = symbol.getDeclarations()[0]; - ts.Debug.assert(classDeclaration && classDeclaration.kind === 204); + ts.Debug.assert(classDeclaration && classDeclaration.kind === 211); return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result); } } @@ -34835,8 +36872,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 137) || - (!selectConstructors && (d.kind === 203 || d.kind === 136 || d.kind === 135))) { + if ((selectConstructors && d.kind === 141) || + (!selectConstructors && (d.kind === 210 || d.kind === 140 || d.kind === 139))) { declarations.push(d); if (d.body) definition = d; @@ -34887,11 +36924,11 @@ var ts; } if (symbol.flags & 8388608) { var declaration = symbol.declarations[0]; - if (node.kind === 65 && node.parent === declaration) { + if (node.kind === 66 && node.parent === declaration) { symbol = typeChecker.getAliasedSymbol(symbol); } } - if (node.parent.kind === 228) { + if (node.parent.kind === 243) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -34962,12 +36999,12 @@ var ts; }; } function getSemanticDocumentHighlights(node) { - if (node.kind === 65 || - node.kind === 93 || - node.kind === 91 || + if (node.kind === 66 || + node.kind === 94 || + node.kind === 92 || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { - var referencedSymbols = getReferencedSymbolsForNodes(node, sourceFilesToSearch, false, false); + var referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, false, false); return convertReferencedSymbols(referencedSymbols); } return undefined; @@ -35013,76 +37050,76 @@ var ts; function getHighlightSpans(node) { if (node) { switch (node.kind) { - case 84: - case 76: - if (hasKind(node.parent, 186)) { + case 85: + case 77: + if (hasKind(node.parent, 193)) { return getIfElseOccurrences(node.parent); } break; - case 90: - if (hasKind(node.parent, 194)) { + case 91: + if (hasKind(node.parent, 201)) { return getReturnOccurrences(node.parent); } break; - case 94: - if (hasKind(node.parent, 198)) { + case 95: + if (hasKind(node.parent, 205)) { return getThrowOccurrences(node.parent); } break; - case 68: - if (hasKind(parent(parent(node)), 199)) { + case 69: + if (hasKind(parent(parent(node)), 206)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; - case 96: - case 81: - if (hasKind(parent(node), 199)) { + case 97: + case 82: + if (hasKind(parent(node), 206)) { return getTryCatchFinallyOccurrences(node.parent); } break; - case 92: - if (hasKind(node.parent, 196)) { + case 93: + if (hasKind(node.parent, 203)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; - case 67: - case 73: - if (hasKind(parent(parent(parent(node))), 196)) { + case 68: + case 74: + if (hasKind(parent(parent(parent(node))), 203)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; - case 66: - case 71: - if (hasKind(node.parent, 193) || hasKind(node.parent, 192)) { + case 67: + case 72: + if (hasKind(node.parent, 200) || hasKind(node.parent, 199)) { return getBreakOrContinueStatementOccurences(node.parent); } break; - case 82: - if (hasKind(node.parent, 189) || - hasKind(node.parent, 190) || - hasKind(node.parent, 191)) { + case 83: + if (hasKind(node.parent, 196) || + hasKind(node.parent, 197) || + hasKind(node.parent, 198)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 100: - case 75: - if (hasKind(node.parent, 188) || hasKind(node.parent, 187)) { + case 101: + case 76: + if (hasKind(node.parent, 195) || hasKind(node.parent, 194)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 114: - if (hasKind(node.parent, 137)) { + case 118: + if (hasKind(node.parent, 141)) { return getConstructorOccurrences(node.parent); } break; - case 116: - case 122: - if (hasKind(node.parent, 138) || hasKind(node.parent, 139)) { + case 120: + case 126: + if (hasKind(node.parent, 142) || hasKind(node.parent, 143)) { return getGetAndSetOccurrences(node.parent); } default: if (ts.isModifier(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 183)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 190)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -35094,10 +37131,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 198) { + if (node.kind === 205) { statementAccumulator.push(node); } - else if (node.kind === 199) { + else if (node.kind === 206) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -35118,17 +37155,17 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_11 = child.parent; - if (ts.isFunctionBlock(parent_11) || parent_11.kind === 230) { - return parent_11; + var parent_13 = child.parent; + if (ts.isFunctionBlock(parent_13) || parent_13.kind === 245) { + return parent_13; } - if (parent_11.kind === 199) { - var tryStatement = parent_11; + if (parent_13.kind === 206) { + var tryStatement = parent_13; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_11; + child = parent_13; } return undefined; } @@ -35137,7 +37174,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 193 || node.kind === 192) { + if (node.kind === 200 || node.kind === 199) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -35153,15 +37190,15 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { switch (node_2.kind) { - case 196: - if (statement.kind === 192) { + case 203: + if (statement.kind === 199) { continue; } - case 189: - case 190: - case 191: - case 188: - case 187: + case 196: + case 197: + case 198: + case 195: + case 194: if (!statement.label || isLabeledBy(node_2, statement.label.text)) { return node_2; } @@ -35178,18 +37215,18 @@ var ts; function getModifierOccurrences(modifier, declaration) { var container = declaration.parent; if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 204 || - (declaration.kind === 131 && hasKind(container, 137)))) { + if (!(container.kind === 211 || + (declaration.kind === 135 && hasKind(container, 141)))) { return undefined; } } - else if (modifier === 109) { - if (container.kind !== 204) { + else if (modifier === 110) { + if (container.kind !== 211) { return undefined; } } - else if (modifier === 78 || modifier === 115) { - if (!(container.kind === 209 || container.kind === 230)) { + else if (modifier === 79 || modifier === 119) { + if (!(container.kind === 216 || container.kind === 245)) { return undefined; } } @@ -35200,18 +37237,18 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 209: - case 230: + case 216: + case 245: nodes = container.statements; break; - case 137: + case 141: nodes = container.parameters.concat(container.parent.members); break; - case 204: + case 211: nodes = container.members; if (modifierFlag & 112) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 137 && member; + return member.kind === 141 && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -35229,17 +37266,17 @@ var ts; return ts.map(keywords, getHighlightSpanForNode); function getFlagFromModifier(modifier) { switch (modifier) { - case 108: - return 16; - case 106: - return 32; - case 107: - return 64; case 109: + return 16; + case 107: + return 32; + case 108: + return 64; + case 110: return 128; - case 78: + case 79: return 1; - case 115: + case 119: return 2; default: ts.Debug.fail(); @@ -35259,13 +37296,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 138); - tryPushAccessorKeyword(accessorDeclaration.symbol, 139); + tryPushAccessorKeyword(accessorDeclaration.symbol, 142); + tryPushAccessorKeyword(accessorDeclaration.symbol, 143); return ts.map(keywords, getHighlightSpanForNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 116, 122); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 120, 126); }); } } } @@ -35274,18 +37311,18 @@ var ts; var keywords = []; ts.forEach(declarations, function (declaration) { ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 114); + return pushKeywordIf(keywords, token, 118); }); }); return ts.map(keywords, getHighlightSpanForNode); } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 82, 100, 75)) { - if (loopNode.kind === 187) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 83, 101, 76)) { + if (loopNode.kind === 194) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 100)) { + if (pushKeywordIf(keywords, loopTokens[i], 101)) { break; } } @@ -35294,7 +37331,7 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 66, 71); + pushKeywordIf(keywords, statement.getFirstToken(), 67, 72); } }); return ts.map(keywords, getHighlightSpanForNode); @@ -35303,13 +37340,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 189: - case 190: - case 191: - case 187: - case 188: - return getLoopBreakContinueOccurrences(owner); case 196: + case 197: + case 198: + case 194: + case 195: + return getLoopBreakContinueOccurrences(owner); + case 203: return getSwitchCaseDefaultOccurrences(owner); } } @@ -35317,13 +37354,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 92); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 93); ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 67, 73); + pushKeywordIf(keywords, clause.getFirstToken(), 68, 74); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 66); + pushKeywordIf(keywords, statement.getFirstToken(), 67); } }); }); @@ -35331,13 +37368,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 96); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 97); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 68); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 69); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 81, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 81); + var finallyKeyword = ts.findChildOfKind(tryStatement, 82, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 82); } return ts.map(keywords, getHighlightSpanForNode); } @@ -35348,50 +37385,50 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 94); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 95); }); if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 90); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 91); }); } return ts.map(keywords, getHighlightSpanForNode); } function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 182))) { + if (!(func && hasKind(func.body, 189))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 90); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 91); }); ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 94); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 95); }); return ts.map(keywords, getHighlightSpanForNode); } function getIfElseOccurrences(ifStatement) { var keywords = []; - while (hasKind(ifStatement.parent, 186) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 193) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } while (ifStatement) { var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 84); + pushKeywordIf(keywords, children[0], 85); for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 76)) { + if (pushKeywordIf(keywords, children[i], 77)) { break; } } - if (!hasKind(ifStatement.elseStatement, 186)) { + if (!hasKind(ifStatement.elseStatement, 193)) { break; } ifStatement = ifStatement.elseStatement; } var result = []; for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 76 && i < keywords.length - 1) { + if (keywords[i].kind === 77 && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; var shouldCombindElseAndIf = true; @@ -35469,15 +37506,15 @@ var ts; if (!node) { return undefined; } - if (node.kind !== 65 && + if (node.kind !== 66 && !isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && !isNameOfExternalModuleImportOrDeclaration(node)) { return undefined; } - ts.Debug.assert(node.kind === 65 || node.kind === 7 || node.kind === 8); - return getReferencedSymbolsForNodes(node, program.getSourceFiles(), findInStrings, findInComments); + ts.Debug.assert(node.kind === 66 || node.kind === 7 || node.kind === 8); + return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); } - function getReferencedSymbolsForNodes(node, sourceFiles, findInStrings, findInComments) { + function getReferencedSymbolsForNode(node, sourceFiles, findInStrings, findInComments) { var typeChecker = program.getTypeChecker(); if (isLabelName(node)) { if (isJumpStatementTarget(node)) { @@ -35488,10 +37525,10 @@ var ts; return getLabelReferencesInNode(node.parent, node); } } - if (node.kind === 93) { + if (node.kind === 94) { return getReferencesForThisKeyword(node, sourceFiles); } - if (node.kind === 91) { + if (node.kind === 92) { return getReferencesForSuperKeyword(node); } var symbol = typeChecker.getSymbolAtLocation(node); @@ -35504,7 +37541,7 @@ var ts; } var result; var searchMeaning = getIntersectingMeaningFromDeclarations(getMeaningFromLocation(node), declarations); - var declaredName = getDeclaredName(symbol, node); + var declaredName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); var scope = getSymbolScope(symbol); var symbolToIndex = []; if (scope) { @@ -35540,51 +37577,28 @@ var ts; textSpan: ts.createTextSpan(declarations[0].getStart(), 0) }; } - function isImportOrExportSpecifierName(location) { - return location.parent && - (location.parent.kind === 216 || location.parent.kind === 220) && - location.parent.propertyName === location; - } function isImportOrExportSpecifierImportSymbol(symbol) { return (symbol.flags & 8388608) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 216 || declaration.kind === 220; + return declaration.kind === 223 || declaration.kind === 227; }); } - function getDeclaredName(symbol, location) { - var functionExpression = ts.forEach(symbol.declarations, function (d) { return d.kind === 165 ? d : undefined; }); - var name; - if (functionExpression && functionExpression.name) { - name = functionExpression.name.text; - } - if (isImportOrExportSpecifierName(location)) { - return location.getText(); - } - name = typeChecker.symbolToString(symbol); - return stripQuotes(name); - } function getInternedName(symbol, location, declarations) { - if (isImportOrExportSpecifierName(location)) { + if (ts.isImportOrExportSpecifierName(location)) { return location.getText(); } - var functionExpression = ts.forEach(declarations, function (d) { return d.kind === 165 ? d : undefined; }); - var name = functionExpression && functionExpression.name - ? functionExpression.name.text - : symbol.name; - return stripQuotes(name); - } - function stripQuotes(name) { - var length = name.length; - if (length >= 2 && name.charCodeAt(0) === 34 && name.charCodeAt(length - 1) === 34) { - return name.substring(1, length - 1); - } - ; - return name; + var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); + symbol = localExportDefaultSymbol || symbol; + return ts.stripQuotes(symbol.name); } function getSymbolScope(symbol) { + var valueDeclaration = symbol.valueDeclaration; + if (valueDeclaration && (valueDeclaration.kind === 170 || valueDeclaration.kind === 183)) { + 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, 204); + return ts.getAncestor(privateDeclaration, 211); } } if (symbol.flags & 8388608) { @@ -35605,7 +37619,7 @@ var ts; if (scope && scope !== container) { return undefined; } - if (container.kind === 230 && !ts.isExternalModule(container)) { + if (container.kind === 245 && !ts.isExternalModule(container)) { return undefined; } scope = container; @@ -35664,7 +37678,7 @@ var ts; function isValidReferencePosition(node, searchSymbolName) { if (node) { switch (node.kind) { - case 65: + case 66: return node.getWidth() === searchSymbolName.length; case 8: if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || @@ -35764,13 +37778,13 @@ var ts; } var staticFlag = 128; switch (searchSpaceNode.kind) { - case 134: - case 133: - case 136: - case 135: - case 137: case 138: + case 137: + case 140: case 139: + case 141: + case 142: + case 143: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; @@ -35783,7 +37797,7 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 91) { + if (!node || node.kind !== 92) { return; } var container = ts.getSuperContainer(node, false); @@ -35798,32 +37812,32 @@ var ts; var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); var staticFlag = 128; switch (searchSpaceNode.kind) { - case 136: - case 135: + case 140: + case 139: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } - case 134: - case 133: - case 137: case 138: - case 139: + case 137: + case 141: + case 142: + case 143: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; - case 230: + case 245: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } - case 203: - case 165: + case 210: + case 170: break; default: return undefined; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 230) { + if (searchSpaceNode.kind === 245) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -35849,30 +37863,30 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 93) { + if (!node || node.kind !== 94) { return; } var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { - case 165: - case 203: + case 170: + case 210: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 136: - case 135: + case 140: + case 139: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 204: + case 211: if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 230: - if (container.kind === 230 && !ts.isExternalModule(container)) { + case 245: + if (container.kind === 245 && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -35887,7 +37901,7 @@ var ts; } if (isNameOfPropertyAssignment(location)) { ts.forEach(getPropertySymbolsFromContextualType(location), function (contextualSymbol) { - result.push.apply(result, typeChecker.getRootSymbols(contextualSymbol)); + ts.addRange(result, typeChecker.getRootSymbols(contextualSymbol)); }); var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent); if (shorthandValueSymbol) { @@ -35907,11 +37921,11 @@ var ts; function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { if (symbol && symbol.flags & (32 | 64)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 204) { + if (declaration.kind === 211) { getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 205) { + else if (declaration.kind === 212) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -35961,17 +37975,17 @@ var ts; if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeChecker.getContextualType(objectLiteral); - var name_28 = node.text; + var name_32 = node.text; if (contextualType) { if (contextualType.flags & 16384) { - var unionProperty = contextualType.getProperty(name_28); + var unionProperty = contextualType.getProperty(name_32); if (unionProperty) { return [unionProperty]; } else { var result_4 = []; ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name_28); + var symbol = t.getProperty(name_32); if (symbol) { result_4.push(symbol); } @@ -35980,7 +37994,7 @@ var ts; } } else { - var symbol_1 = contextualType.getProperty(name_28); + var symbol_1 = contextualType.getProperty(name_32); if (symbol_1) { return [symbol_1]; } @@ -36020,17 +38034,17 @@ var ts; }; } function isWriteAccess(node) { - if (node.kind === 65 && ts.isDeclarationName(node)) { + if (node.kind === 66 && ts.isDeclarationName(node)) { return true; } var parent = node.parent; if (parent) { - if (parent.kind === 171 || parent.kind === 170) { + if (parent.kind === 177 || parent.kind === 176) { return true; } - else if (parent.kind === 172 && parent.left === node) { + else if (parent.kind === 178 && parent.left === node) { var operator = parent.operatorToken.kind; - return 53 <= operator && operator <= 64; + return 54 <= operator && operator <= 65; } } return false; @@ -36053,7 +38067,7 @@ var ts; text: data }); } - var emitOutput = program.emit(sourceFile, writeFile); + var emitOutput = program.emit(sourceFile, writeFile, cancellationToken); return { outputFiles: outputFiles, emitSkipped: emitOutput.emitSkipped @@ -36061,33 +38075,33 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 131: - case 201: - case 155: - case 134: - case 133: - case 227: - case 228: - case 229: - case 136: case 135: - case 137: - case 138: - case 139: - case 203: - case 165: - case 166: - case 226: - return 1; - case 130: - case 205: - case 206: - case 148: - return 2; - case 204: - case 207: - return 1 | 2; case 208: + case 160: + case 138: + case 137: + case 242: + case 243: + case 244: + case 140: + case 139: + case 141: + case 142: + case 143: + case 210: + case 170: + case 171: + case 241: + return 1; + case 134: + case 212: + case 213: + case 152: + return 2; + case 211: + case 214: + return 1 | 2; + case 215: if (node.name.kind === 8) { return 4 | 1; } @@ -36097,14 +38111,14 @@ var ts; else { return 4; } - case 215: - case 216: - case 211: - case 212: - case 217: + case 222: + case 223: case 218: + case 219: + case 224: + case 225: return 1 | 2 | 4; - case 230: + case 245: return 4 | 1; } return 1 | 2 | 4; @@ -36114,8 +38128,8 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 144 || - (node.parent.kind === 179 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); + return node.parent.kind === 148 || + (node.parent.kind === 185 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); } function isNamespaceReference(node) { return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); @@ -36123,47 +38137,47 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 158) { - while (root.parent && root.parent.kind === 158) { + if (root.parent.kind === 163) { + while (root.parent && root.parent.kind === 163) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 179 && root.parent.parent.kind === 225) { + if (!isLastClause && root.parent.kind === 185 && root.parent.parent.kind === 240) { var decl = root.parent.parent.parent; - return (decl.kind === 204 && root.parent.parent.token === 102) || - (decl.kind === 205 && root.parent.parent.token === 79); + return (decl.kind === 211 && root.parent.parent.token === 103) || + (decl.kind === 212 && root.parent.parent.token === 80); } return false; } function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 128) { - while (root.parent && root.parent.kind === 128) { + if (root.parent.kind === 132) { + while (root.parent && root.parent.kind === 132) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 144 && !isLastClause; + return root.parent.kind === 148 && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 128) { + while (node.parent.kind === 132) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; } function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 65); - if (node.parent.kind === 128 && + ts.Debug.assert(node.kind === 66); + if (node.parent.kind === 132 && node.parent.right === node && - node.parent.parent.kind === 211) { + node.parent.parent.kind === 218) { return 1 | 2 | 4; } return 4; } function getMeaningFromLocation(node) { - if (node.parent.kind === 217) { + if (node.parent.kind === 224) { return 1 | 2 | 4; } else if (isInRightSideOfImport(node)) { @@ -36197,15 +38211,15 @@ var ts; return; } switch (node.kind) { - case 158: - case 128: + case 163: + case 132: case 8: - case 80: - case 95: - case 89: - case 91: - case 93: - case 65: + case 81: + case 96: + case 90: + case 92: + case 94: + case 66: break; default: return; @@ -36216,7 +38230,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 208 && + if (nodeForStartPos.parent.parent.kind === 215 && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } @@ -36241,6 +38255,15 @@ var ts; function getSemanticClassifications(fileName, span) { return convertClassifications(getEncodedSemanticClassifications(fileName, span)); } + function checkForClassificationCancellation(kind) { + switch (kind) { + case 215: + case 211: + case 212: + case 210: + cancellationToken.throwIfCancellationRequested(); + } + } function getEncodedSemanticClassifications(fileName, span) { synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); @@ -36285,14 +38308,16 @@ var ts; return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 208 && + return declaration.kind === 215 && ts.getModuleInstanceState(declaration) === 1; }); } } function processNode(node) { if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { - if (node.kind === 65 && !ts.nodeIsMissing(node)) { + var kind = node.kind; + checkForClassificationCancellation(kind); + if (kind === 66 && !ts.nodeIsMissing(node)) { var identifier = node; if (classifiableNames[identifier.text]) { var symbol = typeChecker.getSymbolAtLocation(node); @@ -36348,8 +38373,8 @@ var ts; var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); var spanStart = span.start; var spanLength = span.length; - var triviaScanner = ts.createScanner(2, false, sourceFile.text); - var mergeConflictScanner = ts.createScanner(2, false, sourceFile.text); + var triviaScanner = ts.createScanner(2, false, sourceFile.languageVariant, sourceFile.text); + var mergeConflictScanner = ts.createScanner(2, false, sourceFile.languageVariant, sourceFile.text); var result = []; processElement(sourceFile); return { spans: result, endOfLineState: 0 }; @@ -36416,16 +38441,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18); pos = tag.tagName.end; switch (tag.kind) { - case 249: + case 264: processJSDocParameterTag(tag); break; - case 252: + case 267: processJSDocTemplateTag(tag); break; - case 251: + case 266: processElement(tag.typeExpression); break; - case 250: + case 265: processElement(tag.typeExpression); break; } @@ -36498,24 +38523,24 @@ var ts; if (ts.isKeyword(tokenKind)) { return 3; } - if (tokenKind === 24 || tokenKind === 25) { + if (tokenKind === 24 || tokenKind === 26) { if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { return 10; } } if (ts.isPunctuation(tokenKind)) { if (token) { - if (tokenKind === 53) { - if (token.parent.kind === 201 || - token.parent.kind === 134 || - token.parent.kind === 131) { + if (tokenKind === 54) { + if (token.parent.kind === 208 || + token.parent.kind === 138 || + token.parent.kind === 135) { return 5; } } - if (token.parent.kind === 172 || - token.parent.kind === 170 || - token.parent.kind === 171 || - token.parent.kind === 173) { + if (token.parent.kind === 178 || + token.parent.kind === 176 || + token.parent.kind === 177 || + token.parent.kind === 179) { return 5; } } @@ -36533,35 +38558,35 @@ var ts; else if (ts.isTemplateLiteralKind(tokenKind)) { return 6; } - else if (tokenKind === 65) { + else if (tokenKind === 66) { if (token) { switch (token.parent.kind) { - case 204: + case 211: if (token.parent.name === token) { return 11; } return; - case 130: + case 134: if (token.parent.name === token) { return 15; } return; - case 205: + case 212: if (token.parent.name === token) { return 13; } return; - case 207: + case 214: if (token.parent.name === token) { return 12; } return; - case 208: + case 215: if (token.parent.name === token) { return 14; } return; - case 131: + case 135: if (token.parent.name === token) { return 17; } @@ -36576,6 +38601,7 @@ var ts; return; } if (ts.decodedTextSpanIntersectsWith(spanStart, spanLength, element.pos, element.getFullWidth())) { + checkForClassificationCancellation(element.kind); var children = element.getChildren(sourceFile); for (var i = 0, n = children.length; i < n; i++) { var child = children[i]; @@ -36624,11 +38650,11 @@ var ts; case 14: return 15; case 16: return 17; case 18: return 19; - case 24: return 25; + case 24: return 26; case 15: return 14; case 17: return 16; case 19: return 18; - case 25: return 24; + case 26: return 24; } return undefined; } @@ -36729,7 +38755,7 @@ var ts; var sourceFile = getValidSourceFile(fileName); var typeChecker = program.getTypeChecker(); var node = ts.getTouchingWord(sourceFile, position); - if (node && node.kind === 65) { + if (node && node.kind === 66) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol) { var declarations = symbol.getDeclarations(); @@ -36739,17 +38765,19 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var current = declarations[_i]; var sourceFile_2 = current.getSourceFile(); + var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)); if (sourceFile_2 && getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)) === getCanonicalFileName(ts.normalizePath(defaultLibFileName))) { return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library.key)); } } } + var displayName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); var kind = getSymbolKind(symbol, node); if (kind) { return { canRename: true, localizedErrorMessage: undefined, - displayName: symbol.name, + displayName: displayName, fullDisplayName: typeChecker.getFullyQualifiedName(symbol), kind: kind, kindModifiers: getSymbolModifiers(symbol), @@ -36824,13 +38852,13 @@ var ts; sourceFile.nameTable = nameTable; function walk(node) { switch (node.kind) { - case 65: + case 66: nameTable[node.text] = node.text; break; case 8: case 7: if (ts.isDeclarationName(node) || - node.parent.kind === 222 || + node.parent.kind === 229 || isArgumentOfElementAccessExpression(node)) { nameTable[node.text] = node.text; } @@ -36843,31 +38871,31 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 159 && + node.parent.kind === 164 && node.parent.argumentExpression === node; } function createClassifier() { var scanner = ts.createScanner(2, false); var noRegexTable = []; - noRegexTable[65] = true; + noRegexTable[66] = true; noRegexTable[8] = true; noRegexTable[7] = true; noRegexTable[9] = true; - noRegexTable[93] = true; - noRegexTable[38] = true; + noRegexTable[94] = true; noRegexTable[39] = true; + noRegexTable[40] = true; noRegexTable[17] = true; noRegexTable[19] = true; noRegexTable[15] = true; - noRegexTable[95] = true; - noRegexTable[80] = true; + noRegexTable[96] = true; + noRegexTable[81] = true; var templateStack = []; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { - if (keyword2 === 116 || - keyword2 === 122 || - keyword2 === 114 || - keyword2 === 109) { + if (keyword2 === 120 || + keyword2 === 126 || + keyword2 === 118 || + keyword2 === 110) { return true; } return false; @@ -36962,31 +38990,31 @@ var ts; do { token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 36 || token === 57) && !noRegexTable[lastNonTriviaToken]) { + if ((token === 37 || token === 58) && !noRegexTable[lastNonTriviaToken]) { if (scanner.reScanSlashToken() === 9) { token = 9; } } else if (lastNonTriviaToken === 20 && isKeyword(token)) { - token = 65; + token = 66; } else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { - token = 65; + token = 66; } - else if (lastNonTriviaToken === 65 && + else if (lastNonTriviaToken === 66 && token === 24) { angleBracketStack++; } - else if (token === 25 && angleBracketStack > 0) { + else if (token === 26 && angleBracketStack > 0) { angleBracketStack--; } - else if (token === 112 || - token === 123 || - token === 121 || - token === 113 || - token === 124) { + else if (token === 114 || + token === 127 || + token === 125 || + token === 117 || + token === 128) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { - token = 65; + token = 66; } } else if (token === 11) { @@ -37083,41 +39111,41 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 35: case 36: case 37: - case 33: + case 38: case 34: - case 40: + case 35: case 41: case 42: + case 43: case 24: - case 25: case 26: case 27: - case 87: - case 86: case 28: + case 88: + case 87: case 29: case 30: case 31: - case 43: - case 45: + case 32: case 44: - case 48: + case 46: + case 45: case 49: - case 63: - case 62: + case 50: case 64: - case 59: + case 63: + case 65: case 60: case 61: - case 54: + case 62: case 55: case 56: case 57: case 58: - case 53: + case 59: + case 54: case 23: return true; default: @@ -37126,19 +39154,19 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 33: case 34: + case 35: + case 48: case 47: - case 46: - case 38: case 39: + case 40: return true; default: return false; } } function isKeyword(token) { - return token >= 66 && token <= 127; + return token >= 67 && token <= 131; } function classFromKind(token) { if (isKeyword(token)) { @@ -37147,7 +39175,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5; } - else if (token >= 14 && token <= 64) { + else if (token >= 14 && token <= 65) { return 10; } switch (token) { @@ -37164,7 +39192,7 @@ var ts; case 5: case 4: return 8; - case 65: + case 66: default: if (ts.isTemplateLiteralKind(token)) { return 6; @@ -37190,10 +39218,10 @@ var ts; getNodeConstructor: function (kind) { function Node() { } - var proto = kind === 230 ? new SourceFileObject() : new NodeObject(); + var proto = kind === 245 ? new SourceFileObject() : new NodeObject(); proto.kind = kind; - proto.pos = 0; - proto.end = 0; + proto.pos = -1; + proto.end = -1; proto.flags = 0; proto.parent = undefined; Node.prototype = proto; @@ -39956,3 +41984,629 @@ 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) { + function logInternalError(logger, err) { + if (logger) { + logger.log("*INTERNAL ERROR* - Exception in typescript services: " + err.message); + } + } + var ScriptSnapshotShimAdapter = (function () { + function ScriptSnapshotShimAdapter(scriptSnapshotShim) { + this.scriptSnapshotShim = scriptSnapshotShim; + this.lineStartPositions = null; + } + ScriptSnapshotShimAdapter.prototype.getText = function (start, end) { + return this.scriptSnapshotShim.getText(start, end); + }; + ScriptSnapshotShimAdapter.prototype.getLength = function () { + return this.scriptSnapshotShim.getLength(); + }; + ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { + var oldSnapshotShim = oldSnapshot; + var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); + if (encoded == null) { + return null; + } + var decoded = JSON.parse(encoded); + return ts.createTextChangeRange(ts.createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); + }; + return ScriptSnapshotShimAdapter; + })(); + var LanguageServiceShimHostAdapter = (function () { + function LanguageServiceShimHostAdapter(shimHost) { + this.shimHost = shimHost; + this.loggingEnabled = false; + this.tracingEnabled = false; + } + LanguageServiceShimHostAdapter.prototype.log = function (s) { + if (this.loggingEnabled) { + this.shimHost.log(s); + } + }; + LanguageServiceShimHostAdapter.prototype.trace = function (s) { + if (this.tracingEnabled) { + this.shimHost.trace(s); + } + }; + LanguageServiceShimHostAdapter.prototype.error = function (s) { + this.shimHost.error(s); + }; + LanguageServiceShimHostAdapter.prototype.getProjectVersion = function () { + if (!this.shimHost.getProjectVersion) { + return undefined; + } + return this.shimHost.getProjectVersion(); + }; + LanguageServiceShimHostAdapter.prototype.useCaseSensitiveFileNames = function () { + return this.shimHost.useCaseSensitiveFileNames ? this.shimHost.useCaseSensitiveFileNames() : false; + }; + LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { + var settingsJson = this.shimHost.getCompilationSettings(); + if (settingsJson == null || settingsJson == "") { + throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); + return null; + } + return JSON.parse(settingsJson); + }; + LanguageServiceShimHostAdapter.prototype.getScriptFileNames = function () { + var encoded = this.shimHost.getScriptFileNames(); + return this.files = JSON.parse(encoded); + }; + LanguageServiceShimHostAdapter.prototype.getScriptSnapshot = function (fileName) { + if (this.files && this.files.indexOf(fileName) < 0) { + return undefined; + } + var scriptSnapshot = this.shimHost.getScriptSnapshot(fileName); + return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot); + }; + LanguageServiceShimHostAdapter.prototype.getScriptVersion = function (fileName) { + return this.shimHost.getScriptVersion(fileName); + }; + LanguageServiceShimHostAdapter.prototype.getLocalizedDiagnosticMessages = function () { + var diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); + if (diagnosticMessagesJson == null || diagnosticMessagesJson == "") { + return null; + } + try { + return JSON.parse(diagnosticMessagesJson); + } + catch (e) { + this.log(e.description || "diagnosticMessages.generated.json has invalid JSON format"); + return null; + } + }; + LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { + var hostCancellationToken = this.shimHost.getCancellationToken(); + return new ThrottledCancellationToken(hostCancellationToken); + }; + LanguageServiceShimHostAdapter.prototype.getCurrentDirectory = function () { + return this.shimHost.getCurrentDirectory(); + }; + LanguageServiceShimHostAdapter.prototype.getDefaultLibFileName = function (options) { + try { + return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); + } + catch (e) { + return ""; + } + }; + return LanguageServiceShimHostAdapter; + })(); + ts.LanguageServiceShimHostAdapter = LanguageServiceShimHostAdapter; + var ThrottledCancellationToken = (function () { + function ThrottledCancellationToken(hostCancellationToken) { + this.hostCancellationToken = hostCancellationToken; + this.lastCancellationCheckTime = 0; + } + ThrottledCancellationToken.prototype.isCancellationRequested = function () { + var time = Date.now(); + var duration = Math.abs(time - this.lastCancellationCheckTime); + if (duration > 10) { + this.lastCancellationCheckTime = time; + return this.hostCancellationToken.isCancellationRequested(); + } + return false; + }; + return ThrottledCancellationToken; + })(); + var CoreServicesShimHostAdapter = (function () { + function CoreServicesShimHostAdapter(shimHost) { + this.shimHost = shimHost; + } + CoreServicesShimHostAdapter.prototype.readDirectory = function (rootDir, extension) { + var encoded = this.shimHost.readDirectory(rootDir, extension); + return JSON.parse(encoded); + }; + return CoreServicesShimHostAdapter; + })(); + ts.CoreServicesShimHostAdapter = CoreServicesShimHostAdapter; + function simpleForwardCall(logger, actionDescription, action, logPerformance) { + if (logPerformance) { + logger.log(actionDescription); + var start = Date.now(); + } + var result = action(); + if (logPerformance) { + var end = Date.now(); + logger.log(actionDescription + " completed in " + (end - start) + " msec"); + if (typeof (result) === "string") { + var str = result; + if (str.length > 128) { + str = str.substring(0, 128) + "..."; + } + logger.log(" result.length=" + str.length + ", result='" + JSON.stringify(str) + "'"); + } + } + return result; + } + function forwardJSONCall(logger, actionDescription, action, logPerformance) { + try { + var result = simpleForwardCall(logger, actionDescription, action, logPerformance); + return JSON.stringify({ result: result }); + } + catch (err) { + if (err instanceof ts.OperationCanceledException) { + return JSON.stringify({ canceled: true }); + } + logInternalError(logger, err); + err.description = actionDescription; + return JSON.stringify({ error: err }); + } + } + var ShimBase = (function () { + function ShimBase(factory) { + this.factory = factory; + factory.registerShim(this); + } + ShimBase.prototype.dispose = function (dummy) { + this.factory.unregisterShim(this); + }; + return ShimBase; + })(); + function realizeDiagnostics(diagnostics, newLine) { + return diagnostics.map(function (d) { return realizeDiagnostic(d, newLine); }); + } + ts.realizeDiagnostics = realizeDiagnostics; + function realizeDiagnostic(diagnostic, newLine) { + return { + message: ts.flattenDiagnosticMessageText(diagnostic.messageText, newLine), + start: diagnostic.start, + length: diagnostic.length, + category: ts.DiagnosticCategory[diagnostic.category].toLowerCase(), + code: diagnostic.code + }; + } + var LanguageServiceShimObject = (function (_super) { + __extends(LanguageServiceShimObject, _super); + function LanguageServiceShimObject(factory, host, languageService) { + _super.call(this, factory); + this.host = host; + this.languageService = languageService; + this.logPerformance = false; + this.logger = this.host; + } + LanguageServiceShimObject.prototype.forwardJSONCall = function (actionDescription, action) { + return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); + }; + LanguageServiceShimObject.prototype.dispose = function (dummy) { + this.logger.log("dispose()"); + this.languageService.dispose(); + this.languageService = null; + if (debugObjectHost && debugObjectHost.CollectGarbage) { + debugObjectHost.CollectGarbage(); + this.logger.log("CollectGarbage()"); + } + this.logger = null; + _super.prototype.dispose.call(this, dummy); + }; + LanguageServiceShimObject.prototype.refresh = function (throwOnError) { + this.forwardJSONCall("refresh(" + throwOnError + ")", function () { + return null; + }); + }; + LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { + var _this = this; + this.forwardJSONCall("cleanupSemanticCache()", function () { + _this.languageService.cleanupSemanticCache(); + return null; + }); + }; + LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { + var newLine = this.getNewLine(); + return ts.realizeDiagnostics(diagnostics, newLine); + }; + LanguageServiceShimObject.prototype.getSyntacticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { + var classifications = _this.languageService.getSyntacticClassifications(fileName, ts.createTextSpan(start, length)); + return classifications; + }); + }; + LanguageServiceShimObject.prototype.getSemanticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { + var classifications = _this.languageService.getSemanticClassifications(fileName, ts.createTextSpan(start, length)); + return classifications; + }); + }; + LanguageServiceShimObject.prototype.getEncodedSyntacticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getEncodedSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { + return convertClassifications(_this.languageService.getEncodedSyntacticClassifications(fileName, ts.createTextSpan(start, length))); + }); + }; + LanguageServiceShimObject.prototype.getEncodedSemanticClassifications = function (fileName, start, length) { + var _this = this; + return this.forwardJSONCall("getEncodedSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", function () { + return convertClassifications(_this.languageService.getEncodedSemanticClassifications(fileName, ts.createTextSpan(start, length))); + }); + }; + LanguageServiceShimObject.prototype.getNewLine = function () { + return this.host.getNewLine ? this.host.getNewLine() : "\r\n"; + }; + LanguageServiceShimObject.prototype.getSyntacticDiagnostics = function (fileName) { + var _this = this; + return this.forwardJSONCall("getSyntacticDiagnostics('" + fileName + "')", function () { + var diagnostics = _this.languageService.getSyntacticDiagnostics(fileName); + return _this.realizeDiagnostics(diagnostics); + }); + }; + LanguageServiceShimObject.prototype.getSemanticDiagnostics = function (fileName) { + var _this = this; + return this.forwardJSONCall("getSemanticDiagnostics('" + fileName + "')", function () { + var diagnostics = _this.languageService.getSemanticDiagnostics(fileName); + return _this.realizeDiagnostics(diagnostics); + }); + }; + LanguageServiceShimObject.prototype.getCompilerOptionsDiagnostics = function () { + var _this = this; + return this.forwardJSONCall("getCompilerOptionsDiagnostics()", function () { + var diagnostics = _this.languageService.getCompilerOptionsDiagnostics(); + return _this.realizeDiagnostics(diagnostics); + }); + }; + LanguageServiceShimObject.prototype.getQuickInfoAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getQuickInfoAtPosition('" + fileName + "', " + position + ")", function () { + var quickInfo = _this.languageService.getQuickInfoAtPosition(fileName, position); + return quickInfo; + }); + }; + LanguageServiceShimObject.prototype.getNameOrDottedNameSpan = function (fileName, startPos, endPos) { + var _this = this; + return this.forwardJSONCall("getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")", function () { + var spanInfo = _this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); + return spanInfo; + }); + }; + LanguageServiceShimObject.prototype.getBreakpointStatementAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", function () { + var spanInfo = _this.languageService.getBreakpointStatementAtPosition(fileName, position); + return spanInfo; + }); + }; + LanguageServiceShimObject.prototype.getSignatureHelpItems = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getSignatureHelpItems('" + fileName + "', " + position + ")", function () { + var signatureInfo = _this.languageService.getSignatureHelpItems(fileName, position); + return signatureInfo; + }); + }; + LanguageServiceShimObject.prototype.getDefinitionAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getDefinitionAtPosition('" + fileName + "', " + position + ")", function () { + return _this.languageService.getDefinitionAtPosition(fileName, position); + }); + }; + LanguageServiceShimObject.prototype.getTypeDefinitionAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getTypeDefinitionAtPosition('" + fileName + "', " + position + ")", function () { + return _this.languageService.getTypeDefinitionAtPosition(fileName, position); + }); + }; + LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { + return _this.languageService.getRenameInfo(fileName, position); + }); + }; + LanguageServiceShimObject.prototype.findRenameLocations = function (fileName, position, findInStrings, findInComments) { + var _this = this; + return this.forwardJSONCall("findRenameLocations('" + fileName + "', " + position + ", " + findInStrings + ", " + findInComments + ")", function () { + return _this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments); + }); + }; + LanguageServiceShimObject.prototype.getBraceMatchingAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getBraceMatchingAtPosition('" + fileName + "', " + position + ")", function () { + var textRanges = _this.languageService.getBraceMatchingAtPosition(fileName, position); + return textRanges; + }); + }; + LanguageServiceShimObject.prototype.getIndentationAtPosition = function (fileName, position, options) { + var _this = this; + return this.forwardJSONCall("getIndentationAtPosition('" + fileName + "', " + position + ")", function () { + var localOptions = JSON.parse(options); + return _this.languageService.getIndentationAtPosition(fileName, position, localOptions); + }); + }; + LanguageServiceShimObject.prototype.getReferencesAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getReferencesAtPosition('" + fileName + "', " + position + ")", function () { + return _this.languageService.getReferencesAtPosition(fileName, position); + }); + }; + LanguageServiceShimObject.prototype.findReferences = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("findReferences('" + fileName + "', " + position + ")", function () { + return _this.languageService.findReferences(fileName, position); + }); + }; + LanguageServiceShimObject.prototype.getOccurrencesAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getOccurrencesAtPosition('" + fileName + "', " + position + ")", function () { + return _this.languageService.getOccurrencesAtPosition(fileName, position); + }); + }; + LanguageServiceShimObject.prototype.getDocumentHighlights = function (fileName, position, filesToSearch) { + var _this = this; + return this.forwardJSONCall("getDocumentHighlights('" + fileName + "', " + position + ")", function () { + return _this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); + }); + }; + LanguageServiceShimObject.prototype.getCompletionsAtPosition = function (fileName, position) { + var _this = this; + return this.forwardJSONCall("getCompletionsAtPosition('" + fileName + "', " + position + ")", function () { + var completion = _this.languageService.getCompletionsAtPosition(fileName, position); + return completion; + }); + }; + LanguageServiceShimObject.prototype.getCompletionEntryDetails = function (fileName, position, entryName) { + var _this = this; + return this.forwardJSONCall("getCompletionEntryDetails('" + fileName + "', " + position + ", " + entryName + ")", function () { + var details = _this.languageService.getCompletionEntryDetails(fileName, position, entryName); + return details; + }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsForRange = function (fileName, start, end, options) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsForRange('" + fileName + "', " + start + ", " + end + ")", function () { + var localOptions = JSON.parse(options); + var edits = _this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); + return edits; + }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsForDocument = function (fileName, options) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsForDocument('" + fileName + "')", function () { + var localOptions = JSON.parse(options); + var edits = _this.languageService.getFormattingEditsForDocument(fileName, localOptions); + return edits; + }); + }; + LanguageServiceShimObject.prototype.getFormattingEditsAfterKeystroke = function (fileName, position, key, options) { + var _this = this; + return this.forwardJSONCall("getFormattingEditsAfterKeystroke('" + fileName + "', " + position + ", '" + key + "')", function () { + var localOptions = JSON.parse(options); + var edits = _this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); + return edits; + }); + }; + LanguageServiceShimObject.prototype.getNavigateToItems = function (searchValue, maxResultCount) { + var _this = this; + return this.forwardJSONCall("getNavigateToItems('" + searchValue + "', " + maxResultCount + ")", function () { + var items = _this.languageService.getNavigateToItems(searchValue, maxResultCount); + return items; + }); + }; + LanguageServiceShimObject.prototype.getNavigationBarItems = function (fileName) { + var _this = this; + return this.forwardJSONCall("getNavigationBarItems('" + fileName + "')", function () { + var items = _this.languageService.getNavigationBarItems(fileName); + return items; + }); + }; + LanguageServiceShimObject.prototype.getOutliningSpans = function (fileName) { + var _this = this; + return this.forwardJSONCall("getOutliningSpans('" + fileName + "')", function () { + var items = _this.languageService.getOutliningSpans(fileName); + return items; + }); + }; + LanguageServiceShimObject.prototype.getTodoComments = function (fileName, descriptors) { + var _this = this; + return this.forwardJSONCall("getTodoComments('" + fileName + "')", function () { + var items = _this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); + return items; + }); + }; + LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) { + var _this = this; + return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { + var output = _this.languageService.getEmitOutput(fileName); + output.emitOutputStatus = output.emitSkipped ? 1 : 0; + return output; + }); + }; + return LanguageServiceShimObject; + })(ShimBase); + function convertClassifications(classifications) { + return { spans: classifications.spans.join(","), endOfLineState: classifications.endOfLineState }; + } + var ClassifierShimObject = (function (_super) { + __extends(ClassifierShimObject, _super); + function ClassifierShimObject(factory, logger) { + _super.call(this, factory); + this.logger = logger; + this.logPerformance = false; + this.classifier = ts.createClassifier(); + } + ClassifierShimObject.prototype.getEncodedLexicalClassifications = function (text, lexState, syntacticClassifierAbsent) { + var _this = this; + return forwardJSONCall(this.logger, "getEncodedLexicalClassifications", function () { return convertClassifications(_this.classifier.getEncodedLexicalClassifications(text, lexState, syntacticClassifierAbsent)); }, this.logPerformance); + }; + ClassifierShimObject.prototype.getClassificationsForLine = function (text, lexState, classifyKeywordsInGenerics) { + var classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics); + var items = classification.entries; + var result = ""; + for (var i = 0; i < items.length; i++) { + result += items[i].length + "\n"; + result += items[i].classification + "\n"; + } + result += classification.finalLexState; + return result; + }; + return ClassifierShimObject; + })(ShimBase); + var CoreServicesShimObject = (function (_super) { + __extends(CoreServicesShimObject, _super); + function CoreServicesShimObject(factory, logger, host) { + _super.call(this, factory); + this.logger = logger; + this.host = host; + this.logPerformance = false; + } + CoreServicesShimObject.prototype.forwardJSONCall = function (actionDescription, action) { + return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); + }; + CoreServicesShimObject.prototype.getPreProcessedFileInfo = function (fileName, sourceTextSnapshot) { + return this.forwardJSONCall("getPreProcessedFileInfo('" + fileName + "')", function () { + var result = ts.preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength())); + var convertResult = { + referencedFiles: [], + importedFiles: [], + isLibFile: result.isLibFile + }; + ts.forEach(result.referencedFiles, function (refFile) { + convertResult.referencedFiles.push({ + path: ts.normalizePath(refFile.fileName), + position: refFile.pos, + length: refFile.end - refFile.pos + }); + }); + ts.forEach(result.importedFiles, function (importedFile) { + convertResult.importedFiles.push({ + path: ts.normalizeSlashes(importedFile.fileName), + position: importedFile.pos, + length: importedFile.end - importedFile.pos + }); + }); + return convertResult; + }); + }; + CoreServicesShimObject.prototype.getTSConfigFileInfo = function (fileName, sourceTextSnapshot) { + var _this = this; + return this.forwardJSONCall("getTSConfigFileInfo('" + fileName + "')", function () { + var text = sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()); + var result = ts.parseConfigFileText(fileName, text); + if (result.error) { + return { + options: {}, + files: [], + errors: [realizeDiagnostic(result.error, '\r\n')] + }; + } + var configFile = ts.parseConfigFile(result.config, _this.host, ts.getDirectoryPath(ts.normalizeSlashes(fileName))); + return { + options: configFile.options, + files: configFile.fileNames, + errors: realizeDiagnostics(configFile.errors, '\r\n') + }; + }); + }; + CoreServicesShimObject.prototype.getDefaultCompilationSettings = function () { + return this.forwardJSONCall("getDefaultCompilationSettings()", function () { + return ts.getDefaultCompilerOptions(); + }); + }; + return CoreServicesShimObject; + })(ShimBase); + var TypeScriptServicesFactory = (function () { + function TypeScriptServicesFactory() { + this._shims = []; + } + TypeScriptServicesFactory.prototype.getServicesVersion = function () { + return ts.servicesVersion; + }; + TypeScriptServicesFactory.prototype.createLanguageServiceShim = function (host) { + try { + if (this.documentRegistry === undefined) { + this.documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + } + var hostAdapter = new LanguageServiceShimHostAdapter(host); + var languageService = ts.createLanguageService(hostAdapter, this.documentRegistry); + return new LanguageServiceShimObject(this, host, languageService); + } + catch (err) { + logInternalError(host, err); + throw err; + } + }; + TypeScriptServicesFactory.prototype.createClassifierShim = function (logger) { + try { + return new ClassifierShimObject(this, logger); + } + catch (err) { + logInternalError(logger, err); + throw err; + } + }; + TypeScriptServicesFactory.prototype.createCoreServicesShim = function (host) { + try { + var adapter = new CoreServicesShimHostAdapter(host); + return new CoreServicesShimObject(this, host, adapter); + } + catch (err) { + logInternalError(host, err); + throw err; + } + }; + TypeScriptServicesFactory.prototype.close = function () { + this._shims = []; + this.documentRegistry = ts.createDocumentRegistry(); + }; + TypeScriptServicesFactory.prototype.registerShim = function (shim) { + this._shims.push(shim); + }; + TypeScriptServicesFactory.prototype.unregisterShim = function (shim) { + for (var i = 0, n = this._shims.length; i < n; i++) { + if (this._shims[i] === shim) { + delete this._shims[i]; + return; + } + } + throw new Error("Invalid operation"); + }; + return TypeScriptServicesFactory; + })(); + ts.TypeScriptServicesFactory = TypeScriptServicesFactory; + if (typeof module !== "undefined" && module.exports) { + module.exports = ts; + } +})(ts || (ts = {})); +var TypeScript; +(function (TypeScript) { + var Services; + (function (Services) { + Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory; + })(Services = TypeScript.Services || (TypeScript.Services = {})); +})(TypeScript || (TypeScript = {})); +var toolsVersion = "1.5"; diff --git a/bin/typescript.d.ts b/bin/typescript.d.ts index e7637e0bc19..869fbb32d98 100644 --- a/bin/typescript.d.ts +++ b/bin/typescript.d.ts @@ -54,250 +54,265 @@ declare module "typescript" { SemicolonToken = 22, CommaToken = 23, LessThanToken = 24, - GreaterThanToken = 25, - LessThanEqualsToken = 26, - GreaterThanEqualsToken = 27, - EqualsEqualsToken = 28, - ExclamationEqualsToken = 29, - EqualsEqualsEqualsToken = 30, - ExclamationEqualsEqualsToken = 31, - EqualsGreaterThanToken = 32, - PlusToken = 33, - MinusToken = 34, - AsteriskToken = 35, - SlashToken = 36, - PercentToken = 37, - PlusPlusToken = 38, - MinusMinusToken = 39, - LessThanLessThanToken = 40, - GreaterThanGreaterThanToken = 41, - GreaterThanGreaterThanGreaterThanToken = 42, - AmpersandToken = 43, - BarToken = 44, - CaretToken = 45, - ExclamationToken = 46, - TildeToken = 47, - AmpersandAmpersandToken = 48, - BarBarToken = 49, - QuestionToken = 50, - ColonToken = 51, - AtToken = 52, - EqualsToken = 53, - PlusEqualsToken = 54, - MinusEqualsToken = 55, - AsteriskEqualsToken = 56, - SlashEqualsToken = 57, - PercentEqualsToken = 58, - LessThanLessThanEqualsToken = 59, - GreaterThanGreaterThanEqualsToken = 60, - GreaterThanGreaterThanGreaterThanEqualsToken = 61, - AmpersandEqualsToken = 62, - BarEqualsToken = 63, - CaretEqualsToken = 64, - Identifier = 65, - BreakKeyword = 66, - CaseKeyword = 67, - CatchKeyword = 68, - ClassKeyword = 69, - ConstKeyword = 70, - ContinueKeyword = 71, - DebuggerKeyword = 72, - DefaultKeyword = 73, - DeleteKeyword = 74, - DoKeyword = 75, - ElseKeyword = 76, - EnumKeyword = 77, - ExportKeyword = 78, - ExtendsKeyword = 79, - FalseKeyword = 80, - FinallyKeyword = 81, - ForKeyword = 82, - FunctionKeyword = 83, - IfKeyword = 84, - ImportKeyword = 85, - InKeyword = 86, - InstanceOfKeyword = 87, - NewKeyword = 88, - NullKeyword = 89, - ReturnKeyword = 90, - SuperKeyword = 91, - SwitchKeyword = 92, - ThisKeyword = 93, - ThrowKeyword = 94, - TrueKeyword = 95, - TryKeyword = 96, - TypeOfKeyword = 97, - VarKeyword = 98, - VoidKeyword = 99, - WhileKeyword = 100, - WithKeyword = 101, - ImplementsKeyword = 102, - InterfaceKeyword = 103, - LetKeyword = 104, - PackageKeyword = 105, - PrivateKeyword = 106, - ProtectedKeyword = 107, - PublicKeyword = 108, - StaticKeyword = 109, - YieldKeyword = 110, - AsKeyword = 111, - AnyKeyword = 112, - BooleanKeyword = 113, - ConstructorKeyword = 114, - DeclareKeyword = 115, - GetKeyword = 116, - IsKeyword = 117, - ModuleKeyword = 118, - NamespaceKeyword = 119, - RequireKeyword = 120, - NumberKeyword = 121, - SetKeyword = 122, - StringKeyword = 123, - SymbolKeyword = 124, - TypeKeyword = 125, - FromKeyword = 126, - OfKeyword = 127, - QualifiedName = 128, - ComputedPropertyName = 129, - TypeParameter = 130, - Parameter = 131, - Decorator = 132, - PropertySignature = 133, - PropertyDeclaration = 134, - MethodSignature = 135, - MethodDeclaration = 136, - Constructor = 137, - GetAccessor = 138, - SetAccessor = 139, - CallSignature = 140, - ConstructSignature = 141, - IndexSignature = 142, - TypePredicate = 143, - TypeReference = 144, - FunctionType = 145, - ConstructorType = 146, - TypeQuery = 147, - TypeLiteral = 148, - ArrayType = 149, - TupleType = 150, - UnionType = 151, - ParenthesizedType = 152, - ObjectBindingPattern = 153, - ArrayBindingPattern = 154, - BindingElement = 155, - ArrayLiteralExpression = 156, - ObjectLiteralExpression = 157, - PropertyAccessExpression = 158, - ElementAccessExpression = 159, - CallExpression = 160, - NewExpression = 161, - TaggedTemplateExpression = 162, - TypeAssertionExpression = 163, - ParenthesizedExpression = 164, - FunctionExpression = 165, - ArrowFunction = 166, - DeleteExpression = 167, - TypeOfExpression = 168, - VoidExpression = 169, - PrefixUnaryExpression = 170, - PostfixUnaryExpression = 171, - BinaryExpression = 172, - ConditionalExpression = 173, - TemplateExpression = 174, - YieldExpression = 175, - SpreadElementExpression = 176, - ClassExpression = 177, - OmittedExpression = 178, - ExpressionWithTypeArguments = 179, - TemplateSpan = 180, - SemicolonClassElement = 181, - Block = 182, - VariableStatement = 183, - EmptyStatement = 184, - ExpressionStatement = 185, - IfStatement = 186, - DoStatement = 187, - WhileStatement = 188, - ForStatement = 189, - ForInStatement = 190, - ForOfStatement = 191, - ContinueStatement = 192, - BreakStatement = 193, - ReturnStatement = 194, - WithStatement = 195, - SwitchStatement = 196, - LabeledStatement = 197, - ThrowStatement = 198, - TryStatement = 199, - DebuggerStatement = 200, - VariableDeclaration = 201, - VariableDeclarationList = 202, - FunctionDeclaration = 203, - ClassDeclaration = 204, - InterfaceDeclaration = 205, - TypeAliasDeclaration = 206, - EnumDeclaration = 207, - ModuleDeclaration = 208, - ModuleBlock = 209, - CaseBlock = 210, - ImportEqualsDeclaration = 211, - ImportDeclaration = 212, - ImportClause = 213, - NamespaceImport = 214, - NamedImports = 215, - ImportSpecifier = 216, - ExportAssignment = 217, - ExportDeclaration = 218, - NamedExports = 219, - ExportSpecifier = 220, - MissingDeclaration = 221, - ExternalModuleReference = 222, - CaseClause = 223, - DefaultClause = 224, - HeritageClause = 225, - CatchClause = 226, - PropertyAssignment = 227, - ShorthandPropertyAssignment = 228, - EnumMember = 229, - SourceFile = 230, - JSDocTypeExpression = 231, - JSDocAllType = 232, - JSDocUnknownType = 233, - JSDocArrayType = 234, - JSDocUnionType = 235, - JSDocTupleType = 236, - JSDocNullableType = 237, - JSDocNonNullableType = 238, - JSDocRecordType = 239, - JSDocRecordMember = 240, - JSDocTypeReference = 241, - JSDocOptionalType = 242, - JSDocFunctionType = 243, - JSDocVariadicType = 244, - JSDocConstructorType = 245, - JSDocThisType = 246, - JSDocComment = 247, - JSDocTag = 248, - JSDocParameterTag = 249, - JSDocReturnTag = 250, - JSDocTypeTag = 251, - JSDocTemplateTag = 252, - SyntaxList = 253, - Count = 254, - FirstAssignment = 53, - LastAssignment = 64, - FirstReservedWord = 66, - LastReservedWord = 101, - FirstKeyword = 66, - LastKeyword = 127, - FirstFutureReservedWord = 102, - LastFutureReservedWord = 110, - FirstTypeNode = 144, - LastTypeNode = 152, + LessThanSlashToken = 25, + GreaterThanToken = 26, + LessThanEqualsToken = 27, + GreaterThanEqualsToken = 28, + EqualsEqualsToken = 29, + ExclamationEqualsToken = 30, + EqualsEqualsEqualsToken = 31, + ExclamationEqualsEqualsToken = 32, + EqualsGreaterThanToken = 33, + PlusToken = 34, + MinusToken = 35, + AsteriskToken = 36, + SlashToken = 37, + PercentToken = 38, + PlusPlusToken = 39, + MinusMinusToken = 40, + LessThanLessThanToken = 41, + GreaterThanGreaterThanToken = 42, + GreaterThanGreaterThanGreaterThanToken = 43, + AmpersandToken = 44, + BarToken = 45, + CaretToken = 46, + ExclamationToken = 47, + TildeToken = 48, + AmpersandAmpersandToken = 49, + BarBarToken = 50, + QuestionToken = 51, + ColonToken = 52, + AtToken = 53, + EqualsToken = 54, + PlusEqualsToken = 55, + MinusEqualsToken = 56, + AsteriskEqualsToken = 57, + SlashEqualsToken = 58, + PercentEqualsToken = 59, + LessThanLessThanEqualsToken = 60, + GreaterThanGreaterThanEqualsToken = 61, + GreaterThanGreaterThanGreaterThanEqualsToken = 62, + AmpersandEqualsToken = 63, + BarEqualsToken = 64, + CaretEqualsToken = 65, + Identifier = 66, + BreakKeyword = 67, + CaseKeyword = 68, + CatchKeyword = 69, + ClassKeyword = 70, + ConstKeyword = 71, + ContinueKeyword = 72, + DebuggerKeyword = 73, + DefaultKeyword = 74, + DeleteKeyword = 75, + DoKeyword = 76, + ElseKeyword = 77, + EnumKeyword = 78, + ExportKeyword = 79, + ExtendsKeyword = 80, + FalseKeyword = 81, + FinallyKeyword = 82, + ForKeyword = 83, + FunctionKeyword = 84, + IfKeyword = 85, + ImportKeyword = 86, + InKeyword = 87, + InstanceOfKeyword = 88, + NewKeyword = 89, + NullKeyword = 90, + ReturnKeyword = 91, + SuperKeyword = 92, + SwitchKeyword = 93, + ThisKeyword = 94, + ThrowKeyword = 95, + TrueKeyword = 96, + TryKeyword = 97, + TypeOfKeyword = 98, + VarKeyword = 99, + VoidKeyword = 100, + WhileKeyword = 101, + WithKeyword = 102, + ImplementsKeyword = 103, + InterfaceKeyword = 104, + LetKeyword = 105, + PackageKeyword = 106, + PrivateKeyword = 107, + ProtectedKeyword = 108, + PublicKeyword = 109, + StaticKeyword = 110, + YieldKeyword = 111, + AbstractKeyword = 112, + AsKeyword = 113, + AnyKeyword = 114, + AsyncKeyword = 115, + AwaitKeyword = 116, + BooleanKeyword = 117, + ConstructorKeyword = 118, + DeclareKeyword = 119, + GetKeyword = 120, + IsKeyword = 121, + ModuleKeyword = 122, + NamespaceKeyword = 123, + RequireKeyword = 124, + NumberKeyword = 125, + SetKeyword = 126, + StringKeyword = 127, + SymbolKeyword = 128, + TypeKeyword = 129, + FromKeyword = 130, + OfKeyword = 131, + QualifiedName = 132, + ComputedPropertyName = 133, + TypeParameter = 134, + Parameter = 135, + Decorator = 136, + PropertySignature = 137, + PropertyDeclaration = 138, + MethodSignature = 139, + MethodDeclaration = 140, + Constructor = 141, + GetAccessor = 142, + SetAccessor = 143, + CallSignature = 144, + ConstructSignature = 145, + IndexSignature = 146, + TypePredicate = 147, + TypeReference = 148, + FunctionType = 149, + ConstructorType = 150, + TypeQuery = 151, + TypeLiteral = 152, + ArrayType = 153, + TupleType = 154, + UnionType = 155, + IntersectionType = 156, + ParenthesizedType = 157, + ObjectBindingPattern = 158, + ArrayBindingPattern = 159, + BindingElement = 160, + ArrayLiteralExpression = 161, + ObjectLiteralExpression = 162, + PropertyAccessExpression = 163, + ElementAccessExpression = 164, + CallExpression = 165, + NewExpression = 166, + TaggedTemplateExpression = 167, + TypeAssertionExpression = 168, + ParenthesizedExpression = 169, + FunctionExpression = 170, + ArrowFunction = 171, + DeleteExpression = 172, + TypeOfExpression = 173, + VoidExpression = 174, + AwaitExpression = 175, + PrefixUnaryExpression = 176, + PostfixUnaryExpression = 177, + BinaryExpression = 178, + ConditionalExpression = 179, + TemplateExpression = 180, + YieldExpression = 181, + SpreadElementExpression = 182, + ClassExpression = 183, + OmittedExpression = 184, + ExpressionWithTypeArguments = 185, + AsExpression = 186, + TemplateSpan = 187, + SemicolonClassElement = 188, + Block = 189, + VariableStatement = 190, + EmptyStatement = 191, + ExpressionStatement = 192, + IfStatement = 193, + DoStatement = 194, + WhileStatement = 195, + ForStatement = 196, + ForInStatement = 197, + ForOfStatement = 198, + ContinueStatement = 199, + BreakStatement = 200, + ReturnStatement = 201, + WithStatement = 202, + SwitchStatement = 203, + LabeledStatement = 204, + ThrowStatement = 205, + TryStatement = 206, + DebuggerStatement = 207, + VariableDeclaration = 208, + VariableDeclarationList = 209, + FunctionDeclaration = 210, + ClassDeclaration = 211, + InterfaceDeclaration = 212, + TypeAliasDeclaration = 213, + EnumDeclaration = 214, + ModuleDeclaration = 215, + ModuleBlock = 216, + CaseBlock = 217, + ImportEqualsDeclaration = 218, + ImportDeclaration = 219, + ImportClause = 220, + NamespaceImport = 221, + NamedImports = 222, + ImportSpecifier = 223, + ExportAssignment = 224, + ExportDeclaration = 225, + NamedExports = 226, + ExportSpecifier = 227, + MissingDeclaration = 228, + ExternalModuleReference = 229, + JsxElement = 230, + JsxSelfClosingElement = 231, + JsxOpeningElement = 232, + JsxText = 233, + JsxClosingElement = 234, + JsxAttribute = 235, + JsxSpreadAttribute = 236, + JsxExpression = 237, + CaseClause = 238, + DefaultClause = 239, + HeritageClause = 240, + CatchClause = 241, + PropertyAssignment = 242, + ShorthandPropertyAssignment = 243, + EnumMember = 244, + SourceFile = 245, + JSDocTypeExpression = 246, + JSDocAllType = 247, + JSDocUnknownType = 248, + JSDocArrayType = 249, + JSDocUnionType = 250, + JSDocTupleType = 251, + JSDocNullableType = 252, + JSDocNonNullableType = 253, + JSDocRecordType = 254, + JSDocRecordMember = 255, + JSDocTypeReference = 256, + JSDocOptionalType = 257, + JSDocFunctionType = 258, + JSDocVariadicType = 259, + JSDocConstructorType = 260, + JSDocThisType = 261, + JSDocComment = 262, + JSDocTag = 263, + JSDocParameterTag = 264, + JSDocReturnTag = 265, + JSDocTypeTag = 266, + JSDocTemplateTag = 267, + SyntaxList = 268, + Count = 269, + FirstAssignment = 54, + LastAssignment = 65, + FirstReservedWord = 67, + LastReservedWord = 102, + FirstKeyword = 67, + LastKeyword = 131, + FirstFutureReservedWord = 103, + LastFutureReservedWord = 111, + FirstTypeNode = 148, + LastTypeNode = 157, FirstPunctuation = 14, - LastPunctuation = 64, + LastPunctuation = 65, FirstToken = 0, - LastToken = 127, + LastToken = 131, FirstTriviaToken = 2, LastTriviaToken = 6, FirstLiteralToken = 7, @@ -305,8 +320,8 @@ declare module "typescript" { FirstTemplateToken = 10, LastTemplateToken = 13, FirstBinaryOperator = 24, - LastBinaryOperator = 64, - FirstNode = 128, + LastBinaryOperator = 65, + FirstNode = 132, } const enum NodeFlags { Export = 1, @@ -315,18 +330,28 @@ declare module "typescript" { Private = 32, Protected = 64, Static = 128, - Default = 256, - MultiLine = 512, - Synthetic = 1024, - DeclarationFile = 2048, - Let = 4096, - Const = 8192, - OctalLiteral = 16384, - Namespace = 32768, - ExportContext = 65536, - Modifier = 499, + Abstract = 256, + Async = 512, + Default = 1024, + MultiLine = 2048, + Synthetic = 4096, + DeclarationFile = 8192, + Let = 16384, + Const = 32768, + OctalLiteral = 65536, + Namespace = 131072, + ExportContext = 262144, + Modifier = 2035, AccessibilityModifier = 112, - BlockScoped = 12288, + BlockScoped = 49152, + } + const enum JsxFlags { + None = 0, + IntrinsicNamedElement = 1, + IntrinsicIndexedElement = 2, + ClassElement = 4, + UnknownElement = 8, + IntrinsicElement = 3, } interface Node extends TextRange { kind: SyntaxKind; @@ -483,9 +508,13 @@ declare module "typescript" { interface TupleTypeNode extends TypeNode { elementTypes: NodeArray; } - interface UnionTypeNode extends TypeNode { + interface UnionOrIntersectionTypeNode extends TypeNode { types: NodeArray; } + interface UnionTypeNode extends UnionOrIntersectionTypeNode { + } + interface IntersectionTypeNode extends UnionOrIntersectionTypeNode { + } interface ParenthesizedTypeNode extends TypeNode { type: TypeNode; } @@ -528,6 +557,9 @@ declare module "typescript" { interface VoidExpression extends UnaryExpression { expression: UnaryExpression; } + interface AwaitExpression extends UnaryExpression { + expression: UnaryExpression; + } interface YieldExpression extends Expression { asteriskToken?: Node; expression?: Expression; @@ -601,10 +633,46 @@ declare module "typescript" { template: LiteralExpression | TemplateExpression; } type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator; + interface AsExpression extends Expression { + expression: Expression; + type: TypeNode; + } interface TypeAssertion extends UnaryExpression { type: TypeNode; expression: UnaryExpression; } + type AssertionExpression = TypeAssertion | AsExpression; + interface JsxElement extends PrimaryExpression { + openingElement: JsxOpeningElement; + children: NodeArray; + closingElement: JsxClosingElement; + } + interface JsxOpeningElement extends Expression { + _openingElementBrand?: any; + tagName: EntityName; + attributes: NodeArray; + } + interface JsxSelfClosingElement extends PrimaryExpression, JsxOpeningElement { + _selfClosingElementBrand?: any; + } + type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; + interface JsxAttribute extends Node { + name: Identifier; + initializer?: Expression; + } + interface JsxSpreadAttribute extends Node { + expression: Expression; + } + interface JsxClosingElement extends Node { + tagName: EntityName; + } + interface JsxExpression extends Expression { + expression?: Expression; + } + interface JsxText extends Node { + _jsxTextExpressionBrand: any; + } + type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement; interface Statement extends Node { _statementBrand: any; } @@ -859,6 +927,7 @@ declare module "typescript" { }[]; moduleName: string; referencedFiles: FileReference[]; + languageVariant: LanguageVariant; /** * lib.d.ts should have a reference comment like * @@ -881,6 +950,13 @@ declare module "typescript" { interface WriteFileCallback { (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void; } + class OperationCanceledException { + } + interface CancellationToken { + isCancellationRequested(): boolean; + /** @throws OperationCanceledException if isCancellationRequested is true */ + throwIfCancellationRequested(): void; + } interface Program extends ScriptReferenceHost { /** * Get a list of files in the program @@ -896,12 +972,12 @@ declare module "typescript" { * used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter * will be invoked when writing the JavaScript and declaration files. */ - emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult; - getOptionsDiagnostics(): Diagnostic[]; - getGlobalDiagnostics(): Diagnostic[]; - getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[]; - getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[]; - getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[]; + emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken): EmitResult; + getOptionsDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; + getGlobalDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; /** * Gets a type checker that can be used to semantically analyze source fils in the program. */ @@ -976,6 +1052,8 @@ declare module "typescript" { isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean; getAliasedSymbol(symbol: Symbol): Symbol; getExportsOfModule(moduleSymbol: Symbol): Symbol[]; + getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type; + getJsxIntrinsicTagNames(): Symbol[]; } interface SymbolDisplayBuilder { buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; @@ -1053,7 +1131,7 @@ declare module "typescript" { Merged = 33554432, Transient = 67108864, Prototype = 134217728, - UnionProperty = 268435456, + SyntheticProperty = 268435456, Optional = 536870912, ExportStar = 1073741824, Enum = 384, @@ -1069,8 +1147,8 @@ declare module "typescript" { PropertyExcludes = 107455, EnumMemberExcludes = 107455, FunctionExcludes = 106927, - ClassExcludes = 899583, - InterfaceExcludes = 792992, + ClassExcludes = 899519, + InterfaceExcludes = 792960, RegularEnumExcludes = 899327, ConstEnumExcludes = 899967, ValueModuleExcludes = 106639, @@ -1116,13 +1194,16 @@ declare module "typescript" { Reference = 4096, Tuple = 8192, Union = 16384, - Anonymous = 32768, - Instantiated = 65536, - ObjectLiteral = 262144, - ESSymbol = 2097152, + Intersection = 32768, + Anonymous = 65536, + Instantiated = 131072, + ObjectLiteral = 524288, + ESSymbol = 4194304, StringLike = 258, NumberLike = 132, - ObjectType = 48128, + ObjectType = 80896, + UnionOrIntersection = 49152, + StructuredType = 130048, } interface Type { flags: TypeFlags; @@ -1157,9 +1238,13 @@ declare module "typescript" { elementTypes: Type[]; baseArrayType: TypeReference; } - interface UnionType extends Type { + interface UnionOrIntersectionType extends Type { types: Type[]; } + interface UnionType extends UnionOrIntersectionType { + } + interface IntersectionType extends UnionOrIntersectionType { + } interface TypeParameter extends Type { constraint: Type; } @@ -1216,6 +1301,7 @@ declare module "typescript" { help?: boolean; inlineSourceMap?: boolean; inlineSources?: boolean; + jsx?: JsxEmit; listFiles?: boolean; locale?: string; mapRoot?: string; @@ -1242,6 +1328,7 @@ declare module "typescript" { watch?: boolean; isolatedModules?: boolean; experimentalDecorators?: boolean; + experimentalAsyncFunctions?: boolean; emitDecoratorMetadata?: boolean; [option: string]: string | number | boolean; } @@ -1252,6 +1339,11 @@ declare module "typescript" { UMD = 3, System = 4, } + const enum JsxEmit { + None = 0, + Preserve = 1, + React = 2, + } const enum NewLineKind { CarriageReturnLineFeed = 0, LineFeed = 1, @@ -1266,18 +1358,18 @@ declare module "typescript" { ES6 = 2, Latest = 2, } + const enum LanguageVariant { + Standard = 0, + JSX = 1, + } interface ParsedCommandLine { options: CompilerOptions; fileNames: string[]; errors: Diagnostic[]; } - interface CancellationToken { - isCancellationRequested(): boolean; - } interface CompilerHost { getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; getDefaultLibFileName(options: CompilerOptions): string; - getCancellationToken?(): CancellationToken; writeFile: WriteFileCallback; getCurrentDirectory(): string; getCanonicalFileName(fileName: string): string; @@ -1336,10 +1428,14 @@ declare module "typescript" { reScanGreaterToken(): SyntaxKind; reScanSlashToken(): SyntaxKind; reScanTemplateToken(): SyntaxKind; + scanJsxIdentifier(): SyntaxKind; + reScanJsxToken(): SyntaxKind; + scanJsxToken(): SyntaxKind; scan(): SyntaxKind; setText(text: string, start?: number, length?: number): void; setOnError(onError: ErrorCallback): void; setScriptTarget(scriptTarget: ScriptTarget): void; + setLanguageVariant(variant: LanguageVariant): void; setTextPos(textPos: number): void; lookAhead(callback: () => T): T; tryScan(callback: () => T): T; @@ -1397,7 +1493,7 @@ declare module "typescript" { const version: string; function findConfigFile(searchPath: string): string; function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; - function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile): Diagnostic[]; + function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program; } @@ -1504,6 +1600,9 @@ declare module "typescript" { importedFiles: FileReference[]; isLibFile: boolean; } + interface HostCancellationToken { + isCancellationRequested(): boolean; + } interface LanguageServiceHost { getCompilationSettings(): CompilerOptions; getNewLine?(): string; @@ -1512,7 +1611,7 @@ declare module "typescript" { getScriptVersion(fileName: string): string; getScriptSnapshot(fileName: string): IScriptSnapshot; getLocalizedDiagnosticMessages?(): any; - getCancellationToken?(): CancellationToken; + getCancellationToken?(): HostCancellationToken; getCurrentDirectory(): string; getDefaultLibFileName(options: CompilerOptions): string; log?(s: string): void; @@ -1892,6 +1991,7 @@ declare module "typescript" { const scriptElement: string; const moduleElement: string; const classElement: string; + const localClassElement: string; const interfaceElement: string; const typeElement: string; const enumElement: string; @@ -1923,6 +2023,7 @@ declare module "typescript" { const exportedModifier: string; const ambientModifier: string; const staticModifier: string; + const abstractModifier: string; } class ClassificationTypeNames { static comment: string; @@ -1968,15 +2069,6 @@ declare module "typescript" { } function displayPartsToString(displayParts: SymbolDisplayPart[]): string; function getDefaultCompilerOptions(): CompilerOptions; - class OperationCanceledException { - } - class CancellationTokenObject { - private cancellationToken; - static None: CancellationTokenObject; - constructor(cancellationToken: CancellationToken); - isCancellationRequested(): boolean; - throwIfCancellationRequested(): void; - } function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string; function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile; let disableIncrementalParsing: boolean; @@ -1986,7 +2078,7 @@ declare module "typescript" { function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; function createClassifier(): Classifier; /** - * Get the path of the default library file (lib.d.ts) as distributed with the typescript + * Get the path of the default library files (lib.d.ts) as distributed with the typescript * node package. * The functionality is not supported if the ts module is consumed outside of a node module. */ diff --git a/bin/typescript.js b/bin/typescript.js index 6373e3f9c58..219a0b3924f 100644 --- a/bin/typescript.js +++ b/bin/typescript.js @@ -47,275 +47,291 @@ var ts; SyntaxKind[SyntaxKind["SemicolonToken"] = 22] = "SemicolonToken"; SyntaxKind[SyntaxKind["CommaToken"] = 23] = "CommaToken"; SyntaxKind[SyntaxKind["LessThanToken"] = 24] = "LessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 25] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 26] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 27] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 28] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 29] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 30] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 31] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 32] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 33] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 34] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 35] = "AsteriskToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 36] = "SlashToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 37] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 38] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 39] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 40] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 41] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 42] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 43] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 44] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 45] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 46] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 47] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 48] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 49] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 50] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 51] = "ColonToken"; - SyntaxKind[SyntaxKind["AtToken"] = 52] = "AtToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 25] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 26] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 27] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 28] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 29] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 30] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 31] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 32] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 33] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 34] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 35] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 36] = "AsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 37] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 38] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 39] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 40] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 41] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 42] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 43] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 44] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 45] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 46] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 47] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 48] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 49] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 50] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 51] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 52] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 53] = "AtToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 53] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 54] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 55] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 56] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 57] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 58] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 59] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 60] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 61] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 62] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 63] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 64] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 54] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 55] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 56] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 57] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 58] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 59] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 60] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 61] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 62] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 63] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 64] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 65] = "CaretEqualsToken"; // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 65] = "Identifier"; + SyntaxKind[SyntaxKind["Identifier"] = 66] = "Identifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 66] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 67] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 68] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 69] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 70] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 71] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 72] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 73] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 74] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 75] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 76] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 77] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 78] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 79] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 80] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 81] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 82] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 83] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 84] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 85] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 86] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 87] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 88] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 89] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 90] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 91] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 92] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 93] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 94] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 95] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 96] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 97] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 98] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 99] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 100] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 101] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 67] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 68] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 69] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 70] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 71] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 72] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 73] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 74] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 75] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 76] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 77] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 78] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 79] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 80] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 81] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 82] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 83] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 84] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 85] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 86] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 87] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 88] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 89] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 90] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 91] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 92] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 93] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 94] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 95] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 96] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 97] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 98] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 99] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 100] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 101] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 102] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 102] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 103] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 104] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 105] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 106] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 107] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 108] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 109] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 110] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 103] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 104] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 105] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 106] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 107] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 108] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 109] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 110] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 111] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AsKeyword"] = 111] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 112] = "AnyKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 113] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 114] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 115] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 116] = "GetKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 117] = "IsKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 118] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 119] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 120] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 121] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 122] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 123] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 124] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 125] = "TypeKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 126] = "FromKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 127] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 112] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 113] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 114] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 115] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 116] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 117] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 118] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 119] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 120] = "GetKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 121] = "IsKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 122] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 123] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 124] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 125] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 126] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 127] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 128] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 129] = "TypeKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 130] = "FromKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 131] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 128] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 129] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 132] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 133] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 130] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 131] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 132] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 134] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 135] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 136] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 133] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 134] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 135] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 136] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 137] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 138] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 139] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 140] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 141] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 142] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 137] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 138] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 139] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 140] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 141] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 142] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 143] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 144] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 145] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 146] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 143] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 144] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 145] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 146] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 147] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 148] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 149] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 150] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 151] = "UnionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 152] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 147] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 148] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 149] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 150] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 151] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 152] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 153] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 154] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 155] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 156] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 157] = "ParenthesizedType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 153] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 154] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 155] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 158] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 159] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 160] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 156] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 157] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 158] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 159] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 160] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 161] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 162] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 163] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 164] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 165] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 166] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 167] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 168] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 169] = "VoidExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 170] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 171] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 172] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 173] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 174] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 175] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElementExpression"] = 176] = "SpreadElementExpression"; - SyntaxKind[SyntaxKind["ClassExpression"] = 177] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 178] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 179] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 161] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 162] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 163] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 164] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 165] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 166] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 167] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 168] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 169] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 170] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 171] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 172] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 173] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 174] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 175] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 176] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 177] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 178] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 179] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 180] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 181] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 182] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 183] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 184] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 185] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 186] = "AsExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 180] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 181] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 187] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 188] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 182] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 183] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 184] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 185] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 186] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 187] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 188] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 189] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 190] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 191] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 192] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 193] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 194] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 195] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 196] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 197] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 198] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 199] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 200] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 201] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 202] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 203] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 204] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 205] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 206] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 207] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 208] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 209] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 210] = "CaseBlock"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 211] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 212] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 213] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 214] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 215] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 216] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 217] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 218] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 219] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 220] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 221] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 189] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 190] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 191] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 192] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 193] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 194] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 195] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 196] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 197] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 198] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 199] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 200] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 201] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 202] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 203] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 204] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 205] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 206] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 207] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 208] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 209] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 210] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 211] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 212] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 213] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 214] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 215] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 216] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 217] = "CaseBlock"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 218] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 219] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 220] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 221] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 222] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 223] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 224] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 225] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 226] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 227] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 228] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 222] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 229] = "ExternalModuleReference"; + // JSX + SyntaxKind[SyntaxKind["JsxElement"] = 230] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 231] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 232] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxText"] = 233] = "JsxText"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 234] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 235] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 236] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 237] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 223] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 224] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 225] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 226] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 238] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 239] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 240] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 241] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 227] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 228] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 242] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 243] = "ShorthandPropertyAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 229] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 244] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 230] = "SourceFile"; + SyntaxKind[SyntaxKind["SourceFile"] = 245] = "SourceFile"; // JSDoc nodes. - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 231] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 246] = "JSDocTypeExpression"; // The * type. - SyntaxKind[SyntaxKind["JSDocAllType"] = 232] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 247] = "JSDocAllType"; // The ? type. - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 233] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 234] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 235] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 236] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 237] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 238] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 239] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 240] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 241] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 242] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 243] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 244] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 245] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 246] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 247] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 248] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 249] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 250] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 251] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 252] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 248] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 249] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 250] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 251] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 252] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 253] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 254] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 255] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 256] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 257] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 258] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 259] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 260] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 261] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 262] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 263] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 264] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 265] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 266] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 267] = "JSDocTemplateTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 253] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 268] = "SyntaxList"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 254] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 269] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 53] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 64] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 66] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 101] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 66] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 127] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 102] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 110] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 144] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 152] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 54] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 65] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 67] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 102] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 67] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 131] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 103] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 111] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 148] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 157] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 14] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 64] = "LastPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 65] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 127] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 131] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 6] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 7] = "FirstLiteralToken"; @@ -323,8 +339,8 @@ var ts; SyntaxKind[SyntaxKind["FirstTemplateToken"] = 10] = "FirstTemplateToken"; SyntaxKind[SyntaxKind["LastTemplateToken"] = 13] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 24] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 64] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 128] = "FirstNode"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 65] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 132] = "FirstNode"; })(ts.SyntaxKind || (ts.SyntaxKind = {})); var SyntaxKind = ts.SyntaxKind; (function (NodeFlags) { @@ -334,48 +350,61 @@ var ts; NodeFlags[NodeFlags["Private"] = 32] = "Private"; NodeFlags[NodeFlags["Protected"] = 64] = "Protected"; NodeFlags[NodeFlags["Static"] = 128] = "Static"; - NodeFlags[NodeFlags["Default"] = 256] = "Default"; - NodeFlags[NodeFlags["MultiLine"] = 512] = "MultiLine"; - NodeFlags[NodeFlags["Synthetic"] = 1024] = "Synthetic"; - NodeFlags[NodeFlags["DeclarationFile"] = 2048] = "DeclarationFile"; - NodeFlags[NodeFlags["Let"] = 4096] = "Let"; - NodeFlags[NodeFlags["Const"] = 8192] = "Const"; - NodeFlags[NodeFlags["OctalLiteral"] = 16384] = "OctalLiteral"; - NodeFlags[NodeFlags["Namespace"] = 32768] = "Namespace"; - NodeFlags[NodeFlags["ExportContext"] = 65536] = "ExportContext"; - NodeFlags[NodeFlags["Modifier"] = 499] = "Modifier"; + NodeFlags[NodeFlags["Abstract"] = 256] = "Abstract"; + NodeFlags[NodeFlags["Async"] = 512] = "Async"; + NodeFlags[NodeFlags["Default"] = 1024] = "Default"; + NodeFlags[NodeFlags["MultiLine"] = 2048] = "MultiLine"; + NodeFlags[NodeFlags["Synthetic"] = 4096] = "Synthetic"; + NodeFlags[NodeFlags["DeclarationFile"] = 8192] = "DeclarationFile"; + NodeFlags[NodeFlags["Let"] = 16384] = "Let"; + NodeFlags[NodeFlags["Const"] = 32768] = "Const"; + NodeFlags[NodeFlags["OctalLiteral"] = 65536] = "OctalLiteral"; + NodeFlags[NodeFlags["Namespace"] = 131072] = "Namespace"; + NodeFlags[NodeFlags["ExportContext"] = 262144] = "ExportContext"; + NodeFlags[NodeFlags["Modifier"] = 2035] = "Modifier"; NodeFlags[NodeFlags["AccessibilityModifier"] = 112] = "AccessibilityModifier"; - NodeFlags[NodeFlags["BlockScoped"] = 12288] = "BlockScoped"; + NodeFlags[NodeFlags["BlockScoped"] = 49152] = "BlockScoped"; })(ts.NodeFlags || (ts.NodeFlags = {})); var NodeFlags = ts.NodeFlags; /* @internal */ (function (ParserContextFlags) { ParserContextFlags[ParserContextFlags["None"] = 0] = "None"; // If this node was parsed in a context where 'in-expressions' are not allowed. - ParserContextFlags[ParserContextFlags["DisallowIn"] = 2] = "DisallowIn"; + ParserContextFlags[ParserContextFlags["DisallowIn"] = 1] = "DisallowIn"; // If this node was parsed in the 'yield' context created when parsing a generator. - ParserContextFlags[ParserContextFlags["Yield"] = 4] = "Yield"; - // If this node was parsed in the parameters of a generator. - ParserContextFlags[ParserContextFlags["GeneratorParameter"] = 8] = "GeneratorParameter"; + ParserContextFlags[ParserContextFlags["Yield"] = 2] = "Yield"; // If this node was parsed as part of a decorator - ParserContextFlags[ParserContextFlags["Decorator"] = 16] = "Decorator"; + ParserContextFlags[ParserContextFlags["Decorator"] = 4] = "Decorator"; + // If this node was parsed in the 'await' context created when parsing an async function. + ParserContextFlags[ParserContextFlags["Await"] = 8] = "Await"; // If the parser encountered an error when parsing the code that created this node. Note // the parser only sets this directly on the node it creates right after encountering the // error. - ParserContextFlags[ParserContextFlags["ThisNodeHasError"] = 32] = "ThisNodeHasError"; + ParserContextFlags[ParserContextFlags["ThisNodeHasError"] = 16] = "ThisNodeHasError"; // This node was parsed in a JavaScript file and can be processed differently. For example // its type can be specified usign a JSDoc comment. - ParserContextFlags[ParserContextFlags["JavaScriptFile"] = 64] = "JavaScriptFile"; + ParserContextFlags[ParserContextFlags["JavaScriptFile"] = 32] = "JavaScriptFile"; // Context flags set directly by the parser. - ParserContextFlags[ParserContextFlags["ParserGeneratedFlags"] = 62] = "ParserGeneratedFlags"; + ParserContextFlags[ParserContextFlags["ParserGeneratedFlags"] = 31] = "ParserGeneratedFlags"; + // Exclude these flags when parsing a Type + ParserContextFlags[ParserContextFlags["TypeExcludesFlags"] = 10] = "TypeExcludesFlags"; // Context flags computed by aggregating child flags upwards. // Used during incremental parsing to determine if this node or any of its children had an // error. Computed only once and then cached. - ParserContextFlags[ParserContextFlags["ThisNodeOrAnySubNodesHasError"] = 128] = "ThisNodeOrAnySubNodesHasError"; + ParserContextFlags[ParserContextFlags["ThisNodeOrAnySubNodesHasError"] = 64] = "ThisNodeOrAnySubNodesHasError"; // Used to know if we've computed data from children and cached it in this node. - ParserContextFlags[ParserContextFlags["HasAggregatedChildData"] = 256] = "HasAggregatedChildData"; + ParserContextFlags[ParserContextFlags["HasAggregatedChildData"] = 128] = "HasAggregatedChildData"; })(ts.ParserContextFlags || (ts.ParserContextFlags = {})); var ParserContextFlags = ts.ParserContextFlags; + (function (JsxFlags) { + JsxFlags[JsxFlags["None"] = 0] = "None"; + JsxFlags[JsxFlags["IntrinsicNamedElement"] = 1] = "IntrinsicNamedElement"; + JsxFlags[JsxFlags["IntrinsicIndexedElement"] = 2] = "IntrinsicIndexedElement"; + JsxFlags[JsxFlags["ClassElement"] = 4] = "ClassElement"; + JsxFlags[JsxFlags["UnknownElement"] = 8] = "UnknownElement"; + JsxFlags[JsxFlags["IntrinsicElement"] = 3] = "IntrinsicElement"; + })(ts.JsxFlags || (ts.JsxFlags = {})); + var JsxFlags = ts.JsxFlags; /* @internal */ (function (RelationComparisonResult) { RelationComparisonResult[RelationComparisonResult["Succeeded"] = 1] = "Succeeded"; @@ -383,6 +412,12 @@ var ts; RelationComparisonResult[RelationComparisonResult["FailedAndReported"] = 3] = "FailedAndReported"; })(ts.RelationComparisonResult || (ts.RelationComparisonResult = {})); var RelationComparisonResult = ts.RelationComparisonResult; + var OperationCanceledException = (function () { + function OperationCanceledException() { + } + return OperationCanceledException; + })(); + ts.OperationCanceledException = OperationCanceledException; /** Return code used by getEmitOutput function to indicate status of the function */ (function (ExitStatus) { // Compiler ran successfully. Either this was a simple do-nothing compilation (for example, @@ -427,6 +462,27 @@ var ts; SymbolAccessibility[SymbolAccessibility["CannotBeNamed"] = 2] = "CannotBeNamed"; })(ts.SymbolAccessibility || (ts.SymbolAccessibility = {})); var SymbolAccessibility = ts.SymbolAccessibility; + /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator + * metadata */ + /* @internal */ + (function (TypeReferenceSerializationKind) { + TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; + // should be emitted using a safe fallback. + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + // function that can be reached at runtime (e.g. a `class` + // declaration or a `var` declaration for the static side + // of a type, such as the global `Promise` type in lib.d.ts). + TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidType"] = 2] = "VoidType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 4] = "StringLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 5] = "BooleanType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 6] = "ArrayLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 7] = "ESSymbolType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 8] = "TypeWithCallSignature"; + // with call signatures. + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 9] = "ObjectType"; + })(ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); + var TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind; (function (SymbolFlags) { SymbolFlags[SymbolFlags["None"] = 0] = "None"; SymbolFlags[SymbolFlags["FunctionScopedVariable"] = 1] = "FunctionScopedVariable"; @@ -457,7 +513,7 @@ var ts; SymbolFlags[SymbolFlags["Merged"] = 33554432] = "Merged"; SymbolFlags[SymbolFlags["Transient"] = 67108864] = "Transient"; SymbolFlags[SymbolFlags["Prototype"] = 134217728] = "Prototype"; - SymbolFlags[SymbolFlags["UnionProperty"] = 268435456] = "UnionProperty"; + SymbolFlags[SymbolFlags["SyntheticProperty"] = 268435456] = "SyntheticProperty"; SymbolFlags[SymbolFlags["Optional"] = 536870912] = "Optional"; SymbolFlags[SymbolFlags["ExportStar"] = 1073741824] = "ExportStar"; SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; @@ -477,8 +533,8 @@ var ts; SymbolFlags[SymbolFlags["PropertyExcludes"] = 107455] = "PropertyExcludes"; SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 107455] = "EnumMemberExcludes"; SymbolFlags[SymbolFlags["FunctionExcludes"] = 106927] = "FunctionExcludes"; - SymbolFlags[SymbolFlags["ClassExcludes"] = 899583] = "ClassExcludes"; - SymbolFlags[SymbolFlags["InterfaceExcludes"] = 792992] = "InterfaceExcludes"; + SymbolFlags[SymbolFlags["ClassExcludes"] = 899519] = "ClassExcludes"; + SymbolFlags[SymbolFlags["InterfaceExcludes"] = 792960] = "InterfaceExcludes"; SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 899327] = "RegularEnumExcludes"; SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 899967] = "ConstEnumExcludes"; SymbolFlags[SymbolFlags["ValueModuleExcludes"] = 106639] = "ValueModuleExcludes"; @@ -497,7 +553,7 @@ var ts; SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; SymbolFlags[SymbolFlags["Export"] = 7340032] = "Export"; /* @internal */ - // The set of things we consider semantically classifiable. Used to speed up the LS during + // The set of things we consider semantically classifiable. Used to speed up the LS during // classification. SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; })(ts.SymbolFlags || (ts.SymbolFlags = {})); @@ -508,15 +564,19 @@ var ts; NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis"; NodeCheckFlags[NodeCheckFlags["EmitExtends"] = 8] = "EmitExtends"; - NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 16] = "SuperInstance"; - NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 32] = "SuperStatic"; - NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 64] = "ContextChecked"; + NodeCheckFlags[NodeCheckFlags["EmitDecorate"] = 16] = "EmitDecorate"; + NodeCheckFlags[NodeCheckFlags["EmitParam"] = 32] = "EmitParam"; + NodeCheckFlags[NodeCheckFlags["EmitAwaiter"] = 64] = "EmitAwaiter"; + NodeCheckFlags[NodeCheckFlags["EmitGenerator"] = 128] = "EmitGenerator"; + NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; + NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; + NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; + NodeCheckFlags[NodeCheckFlags["LexicalArguments"] = 2048] = "LexicalArguments"; + NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 4096] = "CaptureArguments"; // Values for enum members have been computed, and any errors have been reported for them. - NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 128] = "EnumValuesComputed"; - NodeCheckFlags[NodeCheckFlags["BlockScopedBindingInLoop"] = 256] = "BlockScopedBindingInLoop"; - NodeCheckFlags[NodeCheckFlags["EmitDecorate"] = 512] = "EmitDecorate"; - NodeCheckFlags[NodeCheckFlags["EmitParam"] = 1024] = "EmitParam"; - NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 2048] = "LexicalModuleMergesWithClass"; + NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 8192] = "EnumValuesComputed"; + NodeCheckFlags[NodeCheckFlags["BlockScopedBindingInLoop"] = 16384] = "BlockScopedBindingInLoop"; + NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass"; })(ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); var NodeCheckFlags = ts.NodeCheckFlags; (function (TypeFlags) { @@ -535,25 +595,28 @@ var ts; TypeFlags[TypeFlags["Reference"] = 4096] = "Reference"; TypeFlags[TypeFlags["Tuple"] = 8192] = "Tuple"; TypeFlags[TypeFlags["Union"] = 16384] = "Union"; - TypeFlags[TypeFlags["Anonymous"] = 32768] = "Anonymous"; - TypeFlags[TypeFlags["Instantiated"] = 65536] = "Instantiated"; + TypeFlags[TypeFlags["Intersection"] = 32768] = "Intersection"; + TypeFlags[TypeFlags["Anonymous"] = 65536] = "Anonymous"; + TypeFlags[TypeFlags["Instantiated"] = 131072] = "Instantiated"; /* @internal */ - TypeFlags[TypeFlags["FromSignature"] = 131072] = "FromSignature"; - TypeFlags[TypeFlags["ObjectLiteral"] = 262144] = "ObjectLiteral"; + TypeFlags[TypeFlags["FromSignature"] = 262144] = "FromSignature"; + TypeFlags[TypeFlags["ObjectLiteral"] = 524288] = "ObjectLiteral"; /* @internal */ - TypeFlags[TypeFlags["ContainsUndefinedOrNull"] = 524288] = "ContainsUndefinedOrNull"; + TypeFlags[TypeFlags["ContainsUndefinedOrNull"] = 1048576] = "ContainsUndefinedOrNull"; /* @internal */ - TypeFlags[TypeFlags["ContainsObjectLiteral"] = 1048576] = "ContainsObjectLiteral"; - TypeFlags[TypeFlags["ESSymbol"] = 2097152] = "ESSymbol"; + TypeFlags[TypeFlags["ContainsObjectLiteral"] = 2097152] = "ContainsObjectLiteral"; + TypeFlags[TypeFlags["ESSymbol"] = 4194304] = "ESSymbol"; /* @internal */ - TypeFlags[TypeFlags["Intrinsic"] = 2097279] = "Intrinsic"; + TypeFlags[TypeFlags["Intrinsic"] = 4194431] = "Intrinsic"; /* @internal */ - TypeFlags[TypeFlags["Primitive"] = 2097662] = "Primitive"; + TypeFlags[TypeFlags["Primitive"] = 4194814] = "Primitive"; TypeFlags[TypeFlags["StringLike"] = 258] = "StringLike"; TypeFlags[TypeFlags["NumberLike"] = 132] = "NumberLike"; - TypeFlags[TypeFlags["ObjectType"] = 48128] = "ObjectType"; + TypeFlags[TypeFlags["ObjectType"] = 80896] = "ObjectType"; + TypeFlags[TypeFlags["UnionOrIntersection"] = 49152] = "UnionOrIntersection"; + TypeFlags[TypeFlags["StructuredType"] = 130048] = "StructuredType"; /* @internal */ - TypeFlags[TypeFlags["RequiresWidening"] = 1572864] = "RequiresWidening"; + TypeFlags[TypeFlags["RequiresWidening"] = 3145728] = "RequiresWidening"; })(ts.TypeFlags || (ts.TypeFlags = {})); var TypeFlags = ts.TypeFlags; (function (SignatureKind) { @@ -580,6 +643,12 @@ var ts; ModuleKind[ModuleKind["System"] = 4] = "System"; })(ts.ModuleKind || (ts.ModuleKind = {})); var ModuleKind = ts.ModuleKind; + (function (JsxEmit) { + JsxEmit[JsxEmit["None"] = 0] = "None"; + JsxEmit[JsxEmit["Preserve"] = 1] = "Preserve"; + JsxEmit[JsxEmit["React"] = 2] = "React"; + })(ts.JsxEmit || (ts.JsxEmit = {})); + var JsxEmit = ts.JsxEmit; (function (NewLineKind) { NewLineKind[NewLineKind["CarriageReturnLineFeed"] = 0] = "CarriageReturnLineFeed"; NewLineKind[NewLineKind["LineFeed"] = 1] = "LineFeed"; @@ -592,6 +661,11 @@ var ts; ScriptTarget[ScriptTarget["Latest"] = 2] = "Latest"; })(ts.ScriptTarget || (ts.ScriptTarget = {})); var ScriptTarget = ts.ScriptTarget; + (function (LanguageVariant) { + LanguageVariant[LanguageVariant["Standard"] = 0] = "Standard"; + LanguageVariant[LanguageVariant["JSX"] = 1] = "JSX"; + })(ts.LanguageVariant || (ts.LanguageVariant = {})); + var LanguageVariant = ts.LanguageVariant; /* @internal */ (function (CharacterCodes) { CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; @@ -726,13 +800,15 @@ var ts; /* @internal */ var ts; (function (ts) { - // Ternary values are defined such that - // x & y is False if either x or y is False. - // x & y is Maybe if either x or y is Maybe, but neither x or y is False. - // x & y is True if both x and y are True. - // x | y is False if both x and y are False. - // x | y is Maybe if either x or y is Maybe, but neither x or y is True. - // x | y is True if either x or y is True. + /** + * Ternary values are defined such that + * x & y is False if either x or y is False. + * x & y is Maybe if either x or y is Maybe, but neither x or y is False. + * x & y is True if both x and y are True. + * x | y is False if both x and y are False. + * x | y is Maybe if either x or y is Maybe, but neither x or y is True. + * x | y is True if either x or y is True. + */ (function (Ternary) { Ternary[Ternary["False"] = 0] = "False"; Ternary[Ternary["Maybe"] = 1] = "Maybe"; @@ -775,6 +851,11 @@ var ts; Comparison[Comparison["GreaterThan"] = 1] = "GreaterThan"; })(ts.Comparison || (ts.Comparison = {})); var Comparison = ts.Comparison; + /** + * Iterates through 'array' by index and performs the callback on each element of array until the callback + * returns a truthy value, then returns that value. + * If no such value is found, the callback is applied to each element of array and undefined is returned. + */ function forEach(array, callback) { if (array) { for (var i = 0, len = array.length; i < len; i++) { @@ -1286,19 +1367,19 @@ 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/ + // 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; // Initial root length is http:// part var rootLength = url.indexOf("://") + "://".length; while (rootLength < urlLength) { - // Consume all immediate slashes in the protocol + // Consume all immediate slashes in the protocol // eg.initial rootlength is just file:// but it needs to consume another "/" in file:/// if (url.charCodeAt(rootLength) === 47 /* slash */) { rootLength++; } else { - // non slash character means we continue proceeding to next component of root search + // non slash character means we continue proceeding to next component of root search break; } } @@ -1309,15 +1390,15 @@ var ts; // Find the index of "/" after website.com so the root can be http://www.website.com/ (from existing http://) var indexOfNextSlash = url.indexOf(ts.directorySeparator, rootLength); if (indexOfNextSlash !== -1) { - // Found the "/" after the website.com so the root is length of http://www.website.com/ + // Found the "/" after the website.com so the root is length of http://www.website.com/ // and get components afetr the root normally like any other folder components rootLength = indexOfNextSlash + 1; return normalizedPathComponents(url, rootLength); } else { - // Can't find the host assume the rest of the string as component + // Can't find the host assume the rest of the string as component // but make sure we append "/" to it as root is not joined using "/" - // eg. if url passed in was http://website.com we want to use root as [http://website.com/] + // eg. if url passed in was http://website.com we want to use root as [http://website.com/] // so that other path manipulations will be correct and it can be merged with relative paths correctly return [url + ts.directorySeparator]; } @@ -1389,8 +1470,8 @@ var ts; /** * List of supported extensions in order of file resolution precedence. */ - ts.supportedExtensions = [".ts", ".d.ts"]; - var extensionsToRemove = [".d.ts", ".ts", ".js"]; + ts.supportedExtensions = [".tsx", ".ts", ".d.ts"]; + var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { for (var _i = 0; _i < extensionsToRemove.length; _i++) { var ext = extensionsToRemove[_i]; @@ -1433,8 +1514,8 @@ var ts; } Node.prototype = { kind: kind, - pos: 0, - end: 0, + pos: -1, + end: -1, flags: 0, parent: undefined }; @@ -1670,16 +1751,16 @@ var ts; var directories = []; for (var _i = 0; _i < files.length; _i++) { var current = files[_i]; - var name = ts.combinePaths(path, current); - if (!ts.contains(exclude, getCanonicalPath(name))) { - var stat = _fs.statSync(name); + var name_3 = ts.combinePaths(path, current); + if (!ts.contains(exclude, getCanonicalPath(name_3))) { + var stat = _fs.statSync(name_3); if (stat.isFile()) { - if (!extension || ts.fileExtensionIs(name, extension)) { - result.push(name); + if (!extension || ts.fileExtensionIs(name_3, extension)) { + result.push(name_3); } } else if (stat.isDirectory()) { - directories.push(name); + directories.push(name_3); } } } @@ -1779,22 +1860,21 @@ var ts; An_index_signature_must_have_a_type_annotation: { code: 1021, category: ts.DiagnosticCategory.Error, key: "An index signature must have a type annotation." }, An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: ts.DiagnosticCategory.Error, key: "An index signature parameter must have a type annotation." }, An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: ts.DiagnosticCategory.Error, key: "An index signature parameter type must be 'string' or 'number'." }, - A_class_or_interface_declaration_can_only_have_one_extends_clause: { code: 1024, category: ts.DiagnosticCategory.Error, key: "A class or interface declaration can only have one 'extends' clause." }, - An_extends_clause_must_precede_an_implements_clause: { code: 1025, category: ts.DiagnosticCategory.Error, key: "An 'extends' clause must precede an 'implements' clause." }, - A_class_can_only_extend_a_single_class: { code: 1026, category: ts.DiagnosticCategory.Error, key: "A class can only extend a single class." }, - A_class_declaration_can_only_have_one_implements_clause: { code: 1027, category: ts.DiagnosticCategory.Error, key: "A class declaration can only have one 'implements' clause." }, Accessibility_modifier_already_seen: { code: 1028, category: ts.DiagnosticCategory.Error, key: "Accessibility modifier already seen." }, _0_modifier_must_precede_1_modifier: { code: 1029, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier must precede '{1}' modifier." }, _0_modifier_already_seen: { code: 1030, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier already seen." }, _0_modifier_cannot_appear_on_a_class_element: { code: 1031, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a class element." }, - An_interface_declaration_cannot_have_an_implements_clause: { code: 1032, category: ts.DiagnosticCategory.Error, key: "An interface declaration cannot have an 'implements' clause." }, super_must_be_followed_by_an_argument_list_or_member_access: { code: 1034, category: ts.DiagnosticCategory.Error, key: "'super' must be followed by an argument list or member access." }, Only_ambient_modules_can_use_quoted_names: { code: 1035, category: ts.DiagnosticCategory.Error, key: "Only ambient modules can use quoted names." }, Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: ts.DiagnosticCategory.Error, key: "Statements are not allowed in ambient contexts." }, A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used in an already ambient context." }, Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: ts.DiagnosticCategory.Error, key: "Initializers are not allowed in ambient contexts." }, + _0_modifier_cannot_be_used_in_an_ambient_context: { code: 1040, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used in an ambient context." }, + _0_modifier_cannot_be_used_with_a_class_declaration: { code: 1041, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with a class declaration." }, + _0_modifier_cannot_be_used_here: { code: 1042, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used here." }, + _0_modifier_cannot_appear_on_a_data_property: { code: 1043, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a data property." }, _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a module element." }, - A_declare_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an interface declaration." }, + A_0_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: ts.DiagnosticCategory.Error, key: "A '{0}' modifier cannot be used with an interface declaration." }, A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, A_rest_parameter_cannot_be_optional: { code: 1047, category: ts.DiagnosticCategory.Error, key: "A rest parameter cannot be optional." }, A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: ts.DiagnosticCategory.Error, key: "A rest parameter cannot have an initializer." }, @@ -1803,12 +1883,18 @@ var ts; A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor parameter cannot have an initializer." }, A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor cannot have rest parameter." }, A_get_accessor_cannot_have_parameters: { code: 1054, category: ts.DiagnosticCategory.Error, key: "A 'get' accessor cannot have parameters." }, + Type_0_is_not_a_valid_async_function_return_type: { code: 1055, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not a valid async function return type." }, Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: ts.DiagnosticCategory.Error, key: "Accessors are only available when targeting ECMAScript 5 and higher." }, + An_async_function_or_method_must_have_a_valid_awaitable_return_type: { code: 1057, category: ts.DiagnosticCategory.Error, key: "An async function or method must have a valid awaitable return type." }, + Operand_for_await_does_not_have_a_valid_callable_then_member: { code: 1058, category: ts.DiagnosticCategory.Error, key: "Operand for 'await' does not have a valid callable 'then' member." }, + Return_expression_in_async_function_does_not_have_a_valid_callable_then_member: { code: 1059, category: ts.DiagnosticCategory.Error, key: "Return expression in async function does not have a valid callable 'then' member." }, + Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member: { code: 1060, category: ts.DiagnosticCategory.Error, key: "Expression body for async arrow function does not have a valid callable 'then' member." }, 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." }, 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_declare_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an import declaration." }, + 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." }, Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal literals are not available when targeting ECMAScript 5 and higher." }, An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: ts.DiagnosticCategory.Error, key: "An accessor cannot be declared in an ambient context." }, @@ -1853,7 +1939,6 @@ var ts; case_or_default_expected: { code: 1130, category: ts.DiagnosticCategory.Error, key: "'case' or 'default' expected." }, Property_or_signature_expected: { code: 1131, category: ts.DiagnosticCategory.Error, key: "Property or signature expected." }, Enum_member_expected: { code: 1132, category: ts.DiagnosticCategory.Error, key: "Enum member expected." }, - Type_reference_expected: { code: 1133, category: ts.DiagnosticCategory.Error, key: "Type reference expected." }, Variable_declaration_expected: { code: 1134, category: ts.DiagnosticCategory.Error, key: "Variable declaration expected." }, Argument_expression_expected: { code: 1135, category: ts.DiagnosticCategory.Error, key: "Argument expression expected." }, Property_assignment_expected: { code: 1136, category: ts.DiagnosticCategory.Error, key: "Property assignment expected." }, @@ -1870,9 +1955,6 @@ var ts; Cannot_compile_modules_unless_the_module_flag_is_provided: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules unless the '--module' flag is provided." }, File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: ts.DiagnosticCategory.Error, key: "File name '{0}' differs from already included file name '{1}' only in casing" }, new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: ts.DiagnosticCategory.Error, key: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, - var_let_or_const_expected: { code: 1152, category: ts.DiagnosticCategory.Error, key: "'var', 'let' or 'const' expected." }, - let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1153, category: ts.DiagnosticCategory.Error, key: "'let' declarations are only available when targeting ECMAScript 6 and higher." }, - const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1154, category: ts.DiagnosticCategory.Error, key: "'const' declarations are only available when targeting ECMAScript 6 and higher." }, const_declarations_must_be_initialized: { code: 1155, category: ts.DiagnosticCategory.Error, key: "'const' declarations must be initialized" }, const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: ts.DiagnosticCategory.Error, key: "'const' declarations can only be declared inside a block." }, let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: ts.DiagnosticCategory.Error, key: "'let' declarations can only be declared inside a block." }, @@ -1883,7 +1965,6 @@ var ts; Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: ts.DiagnosticCategory.Error, key: "Computed property names are not allowed in enums." }, A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { code: 1165, category: ts.DiagnosticCategory.Error, key: "A computed property name in an ambient context must directly refer to a built-in symbol." }, A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { code: 1166, category: ts.DiagnosticCategory.Error, key: "A computed property name in a class property declaration must directly refer to a built-in symbol." }, - Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1167, category: ts.DiagnosticCategory.Error, key: "Computed property names are only available when targeting ECMAScript 6 and higher." }, A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol: { code: 1168, category: ts.DiagnosticCategory.Error, key: "A computed property name in a method overload must directly refer to a built-in symbol." }, A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol: { code: 1169, category: ts.DiagnosticCategory.Error, key: "A computed property name in an interface must directly refer to a built-in symbol." }, A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol: { code: 1170, category: ts.DiagnosticCategory.Error, key: "A computed property name in a type literal must directly refer to a built-in symbol." }, @@ -1899,7 +1980,6 @@ 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." }, - Destructuring_declarations_are_not_allowed_in_ambient_contexts: { code: 1183, category: ts.DiagnosticCategory.Error, key: "Destructuring declarations are not allowed in ambient contexts." }, An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1184, 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." }, @@ -1950,12 +2030,20 @@ 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." }, Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { code: 1239, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of parameter decorator when called as an expression." }, Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { code: 1240, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of property decorator when called as an expression." }, Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { code: 1241, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of method decorator when called as an expression." }, + abstract_modifier_can_only_appear_on_a_class_or_method_declaration: { code: 1242, category: ts.DiagnosticCategory.Error, key: "'abstract' modifier can only appear on a class or method declaration." }, + _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." }, 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." }, @@ -1964,7 +2052,6 @@ var ts; Module_0_has_no_exported_member_1: { code: 2305, category: ts.DiagnosticCategory.Error, key: "Module '{0}' has no exported member '{1}'." }, File_0_is_not_a_module: { code: 2306, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not a module." }, Cannot_find_module_0: { code: 2307, category: ts.DiagnosticCategory.Error, key: "Cannot find module '{0}'." }, - A_module_cannot_have_more_than_one_export_assignment: { code: 2308, category: ts.DiagnosticCategory.Error, key: "A module cannot have more than one export assignment." }, An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { code: 2309, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in a module with other exported elements." }, Type_0_recursively_references_itself_as_a_base_type: { code: 2310, category: ts.DiagnosticCategory.Error, key: "Type '{0}' recursively references itself as a base type." }, A_class_may_only_extend_another_class: { code: 2311, category: ts.DiagnosticCategory.Error, key: "A class may only extend another class." }, @@ -1992,10 +2079,10 @@ var ts; this_cannot_be_referenced_in_a_static_property_initializer: { code: 2334, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a static property initializer." }, super_can_only_be_referenced_in_a_derived_class: { code: 2335, category: ts.DiagnosticCategory.Error, key: "'super' can only be referenced in a derived class." }, super_cannot_be_referenced_in_constructor_arguments: { code: 2336, category: ts.DiagnosticCategory.Error, key: "'super' cannot be referenced in constructor arguments." }, - Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: ts.DiagnosticCategory.Error, key: "Super calls are not permitted outside constructors or in nested functions inside constructors" }, - super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: ts.DiagnosticCategory.Error, key: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class" }, + Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: ts.DiagnosticCategory.Error, key: "Super calls are not permitted outside constructors or in nested functions inside constructors." }, + super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: ts.DiagnosticCategory.Error, key: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class." }, 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" }, + 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'." }, Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: ts.DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." }, @@ -2154,6 +2241,29 @@ var ts; No_base_constructor_has_the_specified_number_of_type_arguments: { code: 2508, category: ts.DiagnosticCategory.Error, key: "No base constructor has the specified number of type arguments." }, Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: ts.DiagnosticCategory.Error, key: "Base constructor return type '{0}' is not a class or interface type." }, Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: ts.DiagnosticCategory.Error, key: "Base constructors must all have the same return type." }, + Cannot_create_an_instance_of_the_abstract_class_0: { code: 2511, category: ts.DiagnosticCategory.Error, key: "Cannot create an instance of the abstract class '{0}'." }, + Overload_signatures_must_all_be_abstract_or_not_abstract: { code: 2512, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be abstract or not abstract." }, + Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: { code: 2513, category: ts.DiagnosticCategory.Error, key: "Abstract method '{0}' in class '{1}' cannot be accessed via super expression." }, + Classes_containing_abstract_methods_must_be_marked_abstract: { code: 2514, category: ts.DiagnosticCategory.Error, key: "Classes containing abstract methods must be marked abstract." }, + 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." }, + Constructor_objects_of_abstract_type_cannot_be_assigned_to_constructor_objects_of_non_abstract_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Constructor objects of abstract type cannot be assigned to constructor objects of non-abstract 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." }, + 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." }, + Property_0_in_type_1_is_not_assignable_to_type_2: { code: 2603, category: ts.DiagnosticCategory.Error, key: "Property '{0}' in type '{1}' is not assignable to type '{2}'" }, + JSX_element_type_0_does_not_have_any_construct_or_call_signatures: { code: 2604, category: ts.DiagnosticCategory.Error, key: "JSX element type '{0}' does not have any construct or call signatures." }, + JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements: { code: 2605, category: ts.DiagnosticCategory.Error, key: "JSX element type '{0}' is not a constructor function for JSX elements." }, + Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of JSX spread attribute is not assignable to target property." }, + JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" }, + The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" }, + Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" }, 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}'." }, @@ -2290,15 +2400,18 @@ var ts; File_0_has_unsupported_extension_The_only_supported_extensions_are_1: { code: 6054, category: ts.DiagnosticCategory.Error, key: "File '{0}' has unsupported extension. The only supported extensions are {1}." }, Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: ts.DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: ts.DiagnosticCategory.Message, key: "Do not emit declarations for code that has an '@internal' annotation." }, - Preserve_new_lines_when_emitting_code: { code: 6057, category: ts.DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." }, Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: ts.DiagnosticCategory.Message, key: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." }, File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." }, Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: ts.DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE" }, Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, + Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify JSX code generation: 'preserve' or 'react'" }, + Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: ts.DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." }, 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." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -2315,6 +2428,7 @@ var ts; _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: { code: 7023, category: ts.DiagnosticCategory.Error, key: "'{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." }, Function_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: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function 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." }, Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: ts.DiagnosticCategory.Error, key: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." }, + JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: ts.DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists" }, You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: ts.DiagnosticCategory.Error, key: "'import ... =' can only be used in a .ts file." }, @@ -2331,7 +2445,14 @@ var ts; property_declarations_can_only_be_used_in_a_ts_file: { code: 8014, category: ts.DiagnosticCategory.Error, key: "'property declarations' can only be used in a .ts file." }, enum_declarations_can_only_be_used_in_a_ts_file: { code: 8015, category: ts.DiagnosticCategory.Error, key: "'enum declarations' can only be used in a .ts file." }, type_assertion_expressions_can_only_be_used_in_a_ts_file: { code: 8016, category: ts.DiagnosticCategory.Error, key: "'type assertion expressions' can only be used in a .ts file." }, - decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: ts.DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." } + decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: ts.DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." }, + Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: ts.DiagnosticCategory.Error, key: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." }, + class_expressions_are_not_currently_supported: { code: 9003, category: ts.DiagnosticCategory.Error, key: "'class' expressions are not currently supported." }, + JSX_attributes_must_only_be_assigned_a_non_empty_expression: { code: 17000, category: ts.DiagnosticCategory.Error, key: "JSX attributes must only be assigned a non-empty 'expression'." }, + JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { code: 17001, category: ts.DiagnosticCategory.Error, key: "JSX elements cannot have multiple attributes with the same name." }, + 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." } }; })(ts || (ts = {})); /// @@ -2339,68 +2460,71 @@ var ts; var ts; (function (ts) { var textToToken = { - "any": 112 /* AnyKeyword */, - "as": 111 /* AsKeyword */, - "boolean": 113 /* BooleanKeyword */, - "break": 66 /* BreakKeyword */, - "case": 67 /* CaseKeyword */, - "catch": 68 /* CatchKeyword */, - "class": 69 /* ClassKeyword */, - "continue": 71 /* ContinueKeyword */, - "const": 70 /* ConstKeyword */, - "constructor": 114 /* ConstructorKeyword */, - "debugger": 72 /* DebuggerKeyword */, - "declare": 115 /* DeclareKeyword */, - "default": 73 /* DefaultKeyword */, - "delete": 74 /* DeleteKeyword */, - "do": 75 /* DoKeyword */, - "else": 76 /* ElseKeyword */, - "enum": 77 /* EnumKeyword */, - "export": 78 /* ExportKeyword */, - "extends": 79 /* ExtendsKeyword */, - "false": 80 /* FalseKeyword */, - "finally": 81 /* FinallyKeyword */, - "for": 82 /* ForKeyword */, - "from": 126 /* FromKeyword */, - "function": 83 /* FunctionKeyword */, - "get": 116 /* GetKeyword */, - "if": 84 /* IfKeyword */, - "implements": 102 /* ImplementsKeyword */, - "import": 85 /* ImportKeyword */, - "in": 86 /* InKeyword */, - "instanceof": 87 /* InstanceOfKeyword */, - "interface": 103 /* InterfaceKeyword */, - "is": 117 /* IsKeyword */, - "let": 104 /* LetKeyword */, - "module": 118 /* ModuleKeyword */, - "namespace": 119 /* NamespaceKeyword */, - "new": 88 /* NewKeyword */, - "null": 89 /* NullKeyword */, - "number": 121 /* NumberKeyword */, - "package": 105 /* PackageKeyword */, - "private": 106 /* PrivateKeyword */, - "protected": 107 /* ProtectedKeyword */, - "public": 108 /* PublicKeyword */, - "require": 120 /* RequireKeyword */, - "return": 90 /* ReturnKeyword */, - "set": 122 /* SetKeyword */, - "static": 109 /* StaticKeyword */, - "string": 123 /* StringKeyword */, - "super": 91 /* SuperKeyword */, - "switch": 92 /* SwitchKeyword */, - "symbol": 124 /* SymbolKeyword */, - "this": 93 /* ThisKeyword */, - "throw": 94 /* ThrowKeyword */, - "true": 95 /* TrueKeyword */, - "try": 96 /* TryKeyword */, - "type": 125 /* TypeKeyword */, - "typeof": 97 /* TypeOfKeyword */, - "var": 98 /* VarKeyword */, - "void": 99 /* VoidKeyword */, - "while": 100 /* WhileKeyword */, - "with": 101 /* WithKeyword */, - "yield": 110 /* YieldKeyword */, - "of": 127 /* OfKeyword */, + "abstract": 112 /* AbstractKeyword */, + "any": 114 /* AnyKeyword */, + "as": 113 /* AsKeyword */, + "boolean": 117 /* BooleanKeyword */, + "break": 67 /* BreakKeyword */, + "case": 68 /* CaseKeyword */, + "catch": 69 /* CatchKeyword */, + "class": 70 /* ClassKeyword */, + "continue": 72 /* ContinueKeyword */, + "const": 71 /* ConstKeyword */, + "constructor": 118 /* ConstructorKeyword */, + "debugger": 73 /* DebuggerKeyword */, + "declare": 119 /* DeclareKeyword */, + "default": 74 /* DefaultKeyword */, + "delete": 75 /* DeleteKeyword */, + "do": 76 /* DoKeyword */, + "else": 77 /* ElseKeyword */, + "enum": 78 /* EnumKeyword */, + "export": 79 /* ExportKeyword */, + "extends": 80 /* ExtendsKeyword */, + "false": 81 /* FalseKeyword */, + "finally": 82 /* FinallyKeyword */, + "for": 83 /* ForKeyword */, + "from": 130 /* FromKeyword */, + "function": 84 /* FunctionKeyword */, + "get": 120 /* GetKeyword */, + "if": 85 /* IfKeyword */, + "implements": 103 /* ImplementsKeyword */, + "import": 86 /* ImportKeyword */, + "in": 87 /* InKeyword */, + "instanceof": 88 /* InstanceOfKeyword */, + "interface": 104 /* InterfaceKeyword */, + "is": 121 /* IsKeyword */, + "let": 105 /* LetKeyword */, + "module": 122 /* ModuleKeyword */, + "namespace": 123 /* NamespaceKeyword */, + "new": 89 /* NewKeyword */, + "null": 90 /* NullKeyword */, + "number": 125 /* NumberKeyword */, + "package": 106 /* PackageKeyword */, + "private": 107 /* PrivateKeyword */, + "protected": 108 /* ProtectedKeyword */, + "public": 109 /* PublicKeyword */, + "require": 124 /* RequireKeyword */, + "return": 91 /* ReturnKeyword */, + "set": 126 /* SetKeyword */, + "static": 110 /* StaticKeyword */, + "string": 127 /* StringKeyword */, + "super": 92 /* SuperKeyword */, + "switch": 93 /* SwitchKeyword */, + "symbol": 128 /* SymbolKeyword */, + "this": 94 /* ThisKeyword */, + "throw": 95 /* ThrowKeyword */, + "true": 96 /* TrueKeyword */, + "try": 97 /* TryKeyword */, + "type": 129 /* TypeKeyword */, + "typeof": 98 /* TypeOfKeyword */, + "var": 99 /* VarKeyword */, + "void": 100 /* VoidKeyword */, + "while": 101 /* WhileKeyword */, + "with": 102 /* WithKeyword */, + "yield": 111 /* YieldKeyword */, + "async": 115 /* AsyncKeyword */, + "await": 116 /* AwaitKeyword */, + "of": 131 /* OfKeyword */, "{": 14 /* OpenBraceToken */, "}": 15 /* CloseBraceToken */, "(": 16 /* OpenParenToken */, @@ -2412,46 +2536,47 @@ var ts; ";": 22 /* SemicolonToken */, ",": 23 /* CommaToken */, "<": 24 /* LessThanToken */, - ">": 25 /* GreaterThanToken */, - "<=": 26 /* LessThanEqualsToken */, - ">=": 27 /* GreaterThanEqualsToken */, - "==": 28 /* EqualsEqualsToken */, - "!=": 29 /* ExclamationEqualsToken */, - "===": 30 /* EqualsEqualsEqualsToken */, - "!==": 31 /* ExclamationEqualsEqualsToken */, - "=>": 32 /* EqualsGreaterThanToken */, - "+": 33 /* PlusToken */, - "-": 34 /* MinusToken */, - "*": 35 /* AsteriskToken */, - "/": 36 /* SlashToken */, - "%": 37 /* PercentToken */, - "++": 38 /* PlusPlusToken */, - "--": 39 /* MinusMinusToken */, - "<<": 40 /* LessThanLessThanToken */, - ">>": 41 /* GreaterThanGreaterThanToken */, - ">>>": 42 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 43 /* AmpersandToken */, - "|": 44 /* BarToken */, - "^": 45 /* CaretToken */, - "!": 46 /* ExclamationToken */, - "~": 47 /* TildeToken */, - "&&": 48 /* AmpersandAmpersandToken */, - "||": 49 /* BarBarToken */, - "?": 50 /* QuestionToken */, - ":": 51 /* ColonToken */, - "=": 53 /* EqualsToken */, - "+=": 54 /* PlusEqualsToken */, - "-=": 55 /* MinusEqualsToken */, - "*=": 56 /* AsteriskEqualsToken */, - "/=": 57 /* SlashEqualsToken */, - "%=": 58 /* PercentEqualsToken */, - "<<=": 59 /* LessThanLessThanEqualsToken */, - ">>=": 60 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 61 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 62 /* AmpersandEqualsToken */, - "|=": 63 /* BarEqualsToken */, - "^=": 64 /* CaretEqualsToken */, - "@": 52 /* AtToken */ + ">": 26 /* GreaterThanToken */, + "<=": 27 /* LessThanEqualsToken */, + ">=": 28 /* GreaterThanEqualsToken */, + "==": 29 /* EqualsEqualsToken */, + "!=": 30 /* ExclamationEqualsToken */, + "===": 31 /* EqualsEqualsEqualsToken */, + "!==": 32 /* ExclamationEqualsEqualsToken */, + "=>": 33 /* EqualsGreaterThanToken */, + "+": 34 /* PlusToken */, + "-": 35 /* MinusToken */, + "*": 36 /* AsteriskToken */, + "/": 37 /* SlashToken */, + "%": 38 /* PercentToken */, + "++": 39 /* PlusPlusToken */, + "--": 40 /* MinusMinusToken */, + "<<": 41 /* LessThanLessThanToken */, + ">": 42 /* GreaterThanGreaterThanToken */, + ">>>": 43 /* GreaterThanGreaterThanGreaterThanToken */, + "&": 44 /* AmpersandToken */, + "|": 45 /* BarToken */, + "^": 46 /* CaretToken */, + "!": 47 /* ExclamationToken */, + "~": 48 /* TildeToken */, + "&&": 49 /* AmpersandAmpersandToken */, + "||": 50 /* BarBarToken */, + "?": 51 /* QuestionToken */, + ":": 52 /* ColonToken */, + "=": 54 /* EqualsToken */, + "+=": 55 /* PlusEqualsToken */, + "-=": 56 /* MinusEqualsToken */, + "*=": 57 /* AsteriskEqualsToken */, + "/=": 58 /* SlashEqualsToken */, + "%=": 59 /* PercentEqualsToken */, + "<<=": 60 /* LessThanLessThanEqualsToken */, + ">>=": 61 /* GreaterThanGreaterThanEqualsToken */, + ">>>=": 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */, + "&=": 63 /* AmpersandEqualsToken */, + "|=": 64 /* BarEqualsToken */, + "^=": 65 /* CaretEqualsToken */, + "@": 53 /* AtToken */ }; /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers @@ -2537,9 +2662,9 @@ var ts; } function makeReverseMap(source) { var result = []; - for (var name_3 in source) { - if (source.hasOwnProperty(name_3)) { - result[source[name_3]] = name_3; + for (var name_4 in source) { + if (source.hasOwnProperty(name_4)) { + result[source[name_4]] = name_4; } } return result; @@ -2601,7 +2726,7 @@ var ts; function computeLineAndCharacterOfPosition(lineStarts, position) { var lineNumber = ts.binarySearch(lineStarts, position); if (lineNumber < 0) { - // If the actual position was not found, + // If the actual position was not found, // the binary search returns the negative value of the next line start // e.g. if the line starts at [5, 10, 23, 80] and the position requested was 20 // then the search will return -2 @@ -2644,8 +2769,8 @@ var ts; // \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. + // 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 /* lineFeed */ || ch === 13 /* carriageReturn */ || ch === 8232 /* lineSeparator */ || @@ -2746,7 +2871,7 @@ var ts; } } ts.skipTrivia = skipTrivia; - // All conflict markers consist of the same character repeated seven times. If it is + // All conflict markers consist of the same character repeated seven times. If it is // a <<<<<<< or >>>>>>> marker then it is also followd by a space. var mergeConflictMarkerLength = "<<<<<<<".length; function isConflictMarkerTrivia(text, pos) { @@ -2791,12 +2916,12 @@ var ts; } return pos; } - // Extract comments from the given source text starting at the given position. If trailing is - // false, whitespace is skipped until the first line break and comments between that location - // and the next token are returned.If trailing is true, comments occurring between the given - // position and the next line break are returned.The return value is an array containing a - // TextRange for each comment. Single-line comment ranges include the beginning '//' characters - // but not the ending line break. Multi - line comment ranges include the beginning '/* and + // Extract comments from the given source text starting at the given position. If trailing is + // false, whitespace is skipped until the first line break and comments between that location + // and the next token are returned.If trailing is true, comments occurring between the given + // position and the next line break are returned.The return value is an array containing a + // TextRange for each comment. Single-line comment ranges include the beginning '//' characters + // but not the ending line break. Multi - line comment ranges include the beginning '/* and // ending '*/' characters.The return value is undefined if no comments were found. function getCommentRanges(text, pos, trailing) { var result; @@ -2893,7 +3018,8 @@ var ts; ts.isIdentifierPart = isIdentifierPart; /* @internal */ // Creates a scanner over a (possibly unspecified) range of a piece of text. - function createScanner(languageVersion, skipTrivia, text, onError, start, length) { + function createScanner(languageVersion, skipTrivia, languageVariant, text, onError, start, length) { + if (languageVariant === void 0) { languageVariant = 0 /* Standard */; } // Current position (end position of text of current token) var pos; // end of text @@ -2917,15 +3043,19 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 65 /* Identifier */ || token > 101 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 66 /* FirstReservedWord */ && token <= 101 /* LastReservedWord */; }, + isIdentifier: function () { return token === 66 /* Identifier */ || token > 102 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 67 /* FirstReservedWord */ && token <= 102 /* LastReservedWord */; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, reScanTemplateToken: reScanTemplateToken, + scanJsxIdentifier: scanJsxIdentifier, + reScanJsxToken: reScanJsxToken, + scanJsxToken: scanJsxToken, scan: scan, setText: setText, setScriptTarget: setScriptTarget, + setLanguageVariant: setLanguageVariant, setOnError: setOnError, setTextPos: setTextPos, tryScan: tryScan, @@ -3258,7 +3388,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 65 /* Identifier */; + return token = 66 /* Identifier */; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); @@ -3328,11 +3458,11 @@ var ts; case 33 /* exclamation */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 31 /* ExclamationEqualsEqualsToken */; + return pos += 3, token = 32 /* ExclamationEqualsEqualsToken */; } - return pos += 2, token = 29 /* ExclamationEqualsToken */; + return pos += 2, token = 30 /* ExclamationEqualsToken */; } - return pos++, token = 46 /* ExclamationToken */; + return pos++, token = 47 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); @@ -3341,44 +3471,44 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 58 /* PercentEqualsToken */; + return pos += 2, token = 59 /* PercentEqualsToken */; } - return pos++, token = 37 /* PercentToken */; + return pos++, token = 38 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 48 /* AmpersandAmpersandToken */; + return pos += 2, token = 49 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 62 /* AmpersandEqualsToken */; + return pos += 2, token = 63 /* AmpersandEqualsToken */; } - return pos++, token = 43 /* AmpersandToken */; + return pos++, token = 44 /* AmpersandToken */; case 40 /* openParen */: return pos++, token = 16 /* OpenParenToken */; case 41 /* closeParen */: return pos++, token = 17 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 56 /* AsteriskEqualsToken */; + return pos += 2, token = 57 /* AsteriskEqualsToken */; } - return pos++, token = 35 /* AsteriskToken */; + return pos++, token = 36 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 38 /* PlusPlusToken */; + return pos += 2, token = 39 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 54 /* PlusEqualsToken */; + return pos += 2, token = 55 /* PlusEqualsToken */; } - return pos++, token = 33 /* PlusToken */; + return pos++, token = 34 /* PlusToken */; case 44 /* comma */: return pos++, token = 23 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 39 /* MinusMinusToken */; + return pos += 2, token = 40 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 55 /* MinusEqualsToken */; + return pos += 2, token = 56 /* MinusEqualsToken */; } - return pos++, token = 34 /* MinusToken */; + return pos++, token = 35 /* MinusToken */; case 46 /* dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanNumber(); @@ -3433,9 +3563,9 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 57 /* SlashEqualsToken */; + return pos += 2, token = 58 /* SlashEqualsToken */; } - return pos++, token = 36 /* SlashToken */; + return pos++, token = 37 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; @@ -3487,7 +3617,7 @@ var ts; tokenValue = "" + scanNumber(); return token = 7 /* NumericLiteral */; case 58 /* colon */: - return pos++, token = 51 /* ColonToken */; + return pos++, token = 52 /* ColonToken */; case 59 /* semicolon */: return pos++, token = 22 /* SemicolonToken */; case 60 /* lessThan */: @@ -3502,12 +3632,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 59 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 60 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 40 /* LessThanLessThanToken */; + return pos += 2, token = 41 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 26 /* LessThanEqualsToken */; + return pos += 2, token = 27 /* LessThanEqualsToken */; + } + if (text.charCodeAt(pos + 1) === 47 /* slash */ && languageVariant === 1 /* JSX */) { + return pos += 2, token = 25 /* LessThanSlashToken */; } return pos++, token = 24 /* LessThanToken */; case 61 /* equals */: @@ -3522,14 +3655,14 @@ var ts; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 30 /* EqualsEqualsEqualsToken */; + return pos += 3, token = 31 /* EqualsEqualsEqualsToken */; } - return pos += 2, token = 28 /* EqualsEqualsToken */; + return pos += 2, token = 29 /* EqualsEqualsToken */; } if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 32 /* EqualsGreaterThanToken */; + return pos += 2, token = 33 /* EqualsGreaterThanToken */; } - return pos++, token = 53 /* EqualsToken */; + return pos++, token = 54 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -3540,34 +3673,34 @@ var ts; return token = 6 /* ConflictMarkerTrivia */; } } - return pos++, token = 25 /* GreaterThanToken */; + return pos++, token = 26 /* GreaterThanToken */; case 63 /* question */: - return pos++, token = 50 /* QuestionToken */; + return pos++, token = 51 /* QuestionToken */; case 91 /* openBracket */: return pos++, token = 18 /* OpenBracketToken */; case 93 /* closeBracket */: return pos++, token = 19 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* CaretEqualsToken */; + return pos += 2, token = 65 /* CaretEqualsToken */; } - return pos++, token = 45 /* CaretToken */; + return pos++, token = 46 /* CaretToken */; case 123 /* openBrace */: return pos++, token = 14 /* OpenBraceToken */; case 124 /* bar */: if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 49 /* BarBarToken */; + return pos += 2, token = 50 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 63 /* BarEqualsToken */; + return pos += 2, token = 64 /* BarEqualsToken */; } - return pos++, token = 44 /* BarToken */; + return pos++, token = 45 /* BarToken */; case 125 /* closeBrace */: return pos++, token = 15 /* CloseBraceToken */; case 126 /* tilde */: - return pos++, token = 47 /* TildeToken */; + return pos++, token = 48 /* TildeToken */; case 64 /* at */: - return pos++, token = 52 /* AtToken */; + return pos++, token = 53 /* AtToken */; case 92 /* backslash */: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { @@ -3603,27 +3736,27 @@ var ts; } } function reScanGreaterToken() { - if (token === 25 /* GreaterThanToken */) { + if (token === 26 /* GreaterThanToken */) { if (text.charCodeAt(pos) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 61 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 42 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 43 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 60 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 61 /* GreaterThanGreaterThanEqualsToken */; } - return pos++, token = 41 /* GreaterThanGreaterThanToken */; + return pos++, token = 42 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { - return pos++, token = 27 /* GreaterThanEqualsToken */; + return pos++, token = 28 /* GreaterThanEqualsToken */; } } return token; } function reScanSlashToken() { - if (token === 36 /* SlashToken */ || token === 57 /* SlashEqualsToken */) { + if (token === 37 /* SlashToken */ || token === 58 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -3680,6 +3813,55 @@ var ts; pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } + function reScanJsxToken() { + pos = tokenPos = startPos; + return token = scanJsxToken(); + } + function scanJsxToken() { + startPos = tokenPos = pos; + if (pos >= end) { + return token = 1 /* EndOfFileToken */; + } + var char = text.charCodeAt(pos); + if (char === 60 /* lessThan */) { + if (text.charCodeAt(pos + 1) === 47 /* slash */) { + pos += 2; + return token = 25 /* LessThanSlashToken */; + } + pos++; + return token = 24 /* LessThanToken */; + } + if (char === 123 /* openBrace */) { + pos++; + return token = 14 /* OpenBraceToken */; + } + while (pos < end) { + pos++; + char = text.charCodeAt(pos); + if ((char === 123 /* openBrace */) || (char === 60 /* lessThan */)) { + break; + } + } + return token = 233 /* JsxText */; + } + // Scans a JSX identifier; these differ from normal identifiers in that + // they allow dashes + function scanJsxIdentifier() { + if (token === 66 /* Identifier */) { + var firstCharPosition = pos; + while (pos < end) { + var ch = text.charCodeAt(pos); + if (ch === 45 /* minus */ || ((firstCharPosition === pos) ? isIdentifierStart(ch) : isIdentifierPart(ch))) { + pos++; + } + else { + break; + } + } + tokenValue += text.substr(firstCharPosition, pos - firstCharPosition); + } + return token; + } function speculationHelper(callback, isLookahead) { var savePos = pos; var saveStartPos = startPos; @@ -3717,6 +3899,9 @@ var ts; function setScriptTarget(scriptTarget) { languageVersion = scriptTarget; } + function setLanguageVariant(variant) { + languageVariant = variant; + } function setTextPos(textPos) { ts.Debug.assert(textPos >= 0); pos = textPos; @@ -3743,18 +3928,18 @@ var ts; })(ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); var ModuleInstanceState = ts.ModuleInstanceState; function getModuleInstanceState(node) { - // A module is uninstantiated if it contains only + // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 205 /* InterfaceDeclaration */ || node.kind === 206 /* TypeAliasDeclaration */) { + if (node.kind === 212 /* InterfaceDeclaration */ || node.kind === 213 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 212 /* ImportDeclaration */ || node.kind === 211 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { + else if ((node.kind === 219 /* ImportDeclaration */ || node.kind === 218 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { return 0 /* NonInstantiated */; } - else if (node.kind === 209 /* ModuleBlock */) { + else if (node.kind === 216 /* ModuleBlock */) { var state = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -3773,7 +3958,7 @@ var ts; }); return state; } - else if (node.kind === 208 /* ModuleDeclaration */) { + else if (node.kind === 215 /* ModuleDeclaration */) { return getModuleInstanceState(node.body); } else { @@ -3783,7 +3968,7 @@ var ts; ts.getModuleInstanceState = getModuleInstanceState; var ContainerFlags; (function (ContainerFlags) { - // The current node is not a container, and no container manipulation should happen before + // The current node is not a container, and no container manipulation should happen before // recursing into it. ContainerFlags[ContainerFlags["None"] = 0] = "None"; // The current node is a container. It should be set as the current container (and block- @@ -3814,7 +3999,7 @@ var ts; var blockScopeContainer; var lastContainer; // If this file is an external module, then it is automatically in strict-mode according to - // ES6. If it is not an external module, then we'll determine if it is in strict mode or + // ES6. If it is not an external module, then we'll determine if it is in strict mode or // not depending on if we see "use strict" in certain places (or if we hit a class/namespace). var inStrictMode = !!file.externalModuleIndicator; var symbolCount = 0; @@ -3851,10 +4036,10 @@ var ts; // unless it is a well known Symbol. function getDeclarationName(node) { if (node.name) { - if (node.kind === 208 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */) { + if (node.kind === 215 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */) { return '"' + node.name.text + '"'; } - if (node.name.kind === 129 /* ComputedPropertyName */) { + if (node.name.kind === 133 /* ComputedPropertyName */) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -3862,43 +4047,51 @@ var ts; return node.name.text; } switch (node.kind) { - case 137 /* Constructor */: + case 141 /* Constructor */: return "__constructor"; - case 145 /* FunctionType */: - case 140 /* CallSignature */: + case 149 /* FunctionType */: + case 144 /* CallSignature */: return "__call"; - case 146 /* ConstructorType */: - case 141 /* ConstructSignature */: + case 150 /* ConstructorType */: + case 145 /* ConstructSignature */: return "__new"; - case 142 /* IndexSignature */: + case 146 /* IndexSignature */: return "__index"; - case 218 /* ExportDeclaration */: + case 225 /* ExportDeclaration */: return "__export"; - case 217 /* ExportAssignment */: + case 224 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 203 /* FunctionDeclaration */: - case 204 /* ClassDeclaration */: - return node.flags & 256 /* Default */ ? "default" : undefined; + case 210 /* FunctionDeclaration */: + case 211 /* ClassDeclaration */: + return node.flags & 1024 /* Default */ ? "default" : undefined; } } function getDisplayName(node) { return node.name ? ts.declarationNameToString(node.name) : getDeclarationName(node); } + /** + * Declares a Symbol for the node and adds it to symbols. Reports errors for conflicting identifier names. + * @param symbolTable - The symbol table which node will be added to. + * @param parent - node's parent declaration. + * @param node - The declaration to be added to the symbol table + * @param includes - The SymbolFlags that node has in addition to its declaration type (eg: export, ambient, etc.) + * @param excludes - The flags which node cannot be declared alongside in a symbol table. Used to report forbidden declarations. + */ function declareSymbol(symbolTable, parent, node, includes, excludes) { ts.Debug.assert(!ts.hasDynamicName(node)); // The exported symbol for an export default function/class node is always named "default" - var name = node.flags & 256 /* Default */ && parent ? "default" : getDeclarationName(node); + var name = node.flags & 1024 /* Default */ && parent ? "default" : getDeclarationName(node); var symbol; if (name !== undefined) { // Check and see if the symbol table already has a symbol with this name. If not, // create a new symbol with this name and add it to the table. Note that we don't - // give the new symbol any flags *yet*. This ensures that it will not conflict - // witht he 'excludes' flags we pass in. + // give the new symbol any flags *yet*. This ensures that it will not conflict + // with the 'excludes' flags we pass in. // // If we do get an existing symbol, see if it conflicts with the new symbol we're // creating. For example, a 'var' symbol and a 'class' symbol will conflict within - // the same symbol table. If we have a conflict, report the issue on each - // declaration we have for this symbol, and then create a new symbol for this + // the same symbol table. If we have a conflict, report the issue on each + // declaration we have for this symbol, and then create a new symbol for this // declaration. // // If we created a new symbol, either because we didn't have a symbol with this name @@ -3940,7 +4133,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 220 /* ExportSpecifier */ || (node.kind === 211 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 227 /* ExportSpecifier */ || (node.kind === 218 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -3952,14 +4145,14 @@ var ts; // ExportType, or ExportContainer flag, and an associated export symbol with all the correct flags set // on it. There are 2 main reasons: // - // 1. We treat locals and exports of the same name as mutually exclusive within a container. + // 1. We treat locals and exports of the same name as mutually exclusive within a container. // That means the binder will issue a Duplicate Identifier error if you mix locals and exports // with the same name in the same container. // TODO: Make this a more specific error and decouple it from the exclusion logic. // 2. When we checkIdentifier in the checker, we set its resolved symbol to the local symbol, // but return the export symbol (by calling getExportSymbolOfValueSymbolIfExported). That way // when the emitter comes back to it, it knows not to qualify the name if it was found in a containing scope. - if (hasExportModifier || container.flags & 65536 /* ExportContext */) { + if (hasExportModifier || container.flags & 262144 /* ExportContext */) { var exportKind = (symbolFlags & 107455 /* Value */ ? 1048576 /* ExportValue */ : 0) | (symbolFlags & 793056 /* Type */ ? 2097152 /* ExportType */ : 0) | (symbolFlags & 1536 /* Namespace */ ? 4194304 /* ExportNamespace */ : 0); @@ -3973,11 +4166,11 @@ var ts; } } } - // All container nodes are kept on a linked list in declaration order. This list is used by - // the getLocalNameOfContainer function in the type checker to validate that the local name + // All container nodes are kept on a linked list in declaration order. This list is used by + // the getLocalNameOfContainer function in the type checker to validate that the local name // used for a container is unique. function bindChildren(node) { - // Before we recurse into a node's chilren, we first save the existing parent, container + // Before we recurse into a node's chilren, we first save the existing parent, container // and block-container. Then after we pop out of processing the children, we restore // these saved values. var saveParent = parent; @@ -3991,9 +4184,9 @@ var ts; // may contain locals, we proactively initialize the .locals field. We do this because // it's highly likely that the .locals will be needed to place some child in (for example, // a parameter, or variable declaration). - // + // // However, we do not proactively create the .locals for block-containers because it's - // totally normal and common for block-containers to never actually have a block-scoped + // totally normal and common for block-containers to never actually have a block-scoped // variable in them. We don't want to end up allocating an object for every 'block' we // run into when most of them won't be necessary. // @@ -4021,39 +4214,39 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 177 /* ClassExpression */: - case 204 /* ClassDeclaration */: - case 205 /* InterfaceDeclaration */: - case 207 /* EnumDeclaration */: - case 148 /* TypeLiteral */: - case 157 /* ObjectLiteralExpression */: + case 183 /* ClassExpression */: + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: + case 214 /* EnumDeclaration */: + case 152 /* TypeLiteral */: + case 162 /* ObjectLiteralExpression */: return 1 /* IsContainer */; - case 140 /* CallSignature */: - case 141 /* ConstructSignature */: - case 142 /* IndexSignature */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 203 /* FunctionDeclaration */: - case 137 /* Constructor */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 145 /* FunctionType */: - case 146 /* ConstructorType */: - case 165 /* FunctionExpression */: - case 166 /* ArrowFunction */: - case 208 /* ModuleDeclaration */: - case 230 /* SourceFile */: - case 206 /* TypeAliasDeclaration */: + case 144 /* CallSignature */: + case 145 /* ConstructSignature */: + case 146 /* IndexSignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 210 /* FunctionDeclaration */: + case 141 /* Constructor */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 149 /* FunctionType */: + case 150 /* ConstructorType */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: + case 215 /* ModuleDeclaration */: + case 245 /* SourceFile */: + case 213 /* TypeAliasDeclaration */: return 5 /* IsContainerWithLocals */; - case 226 /* CatchClause */: - case 189 /* ForStatement */: - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: - case 210 /* CaseBlock */: + case 241 /* CatchClause */: + case 196 /* ForStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: + case 217 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 182 /* Block */: + case 189 /* Block */: // do not treat blocks directly inside a function as a block-scoped-container. - // Locals that reside in this block should go to the function locals. Othewise 'x' + // Locals that reside in this block should go to the function locals. Othewise 'x' // would not appear to be a redeclaration of a block scoped local in the following // example: // @@ -4066,7 +4259,7 @@ var ts; // the block, then there would be no collision. // // By not creating a new block-scoped-container here, we ensure that both 'var x' - // and 'let x' go into the Function-container's locals, and we do get a collision + // and 'let x' go into the Function-container's locals, and we do get a collision // conflict. return ts.isFunctionLike(node.parent) ? 0 /* None */ : 2 /* IsBlockScopedContainer */; } @@ -4088,38 +4281,38 @@ var ts; // members are declared (for example, a member of a class will go into a specific // symbol table depending on if it is static or not). We defer to specialized // handlers to take care of declaring these child members. - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 230 /* SourceFile */: + case 245 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 177 /* ClassExpression */: - case 204 /* ClassDeclaration */: + case 183 /* ClassExpression */: + case 211 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 207 /* EnumDeclaration */: + case 214 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 148 /* TypeLiteral */: - case 157 /* ObjectLiteralExpression */: - case 205 /* InterfaceDeclaration */: + case 152 /* TypeLiteral */: + case 162 /* ObjectLiteralExpression */: + case 212 /* InterfaceDeclaration */: // Interface/Object-types always have their children added to the 'members' of // their container. They are only accessible through an instance of their // container, and are never in scope otherwise (even inside the body of the // object / type / interface declaring them). An exception is type parameters, // which are in scope without qualification (similar to 'locals'). return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 145 /* FunctionType */: - case 146 /* ConstructorType */: - case 140 /* CallSignature */: - case 141 /* ConstructSignature */: - case 142 /* IndexSignature */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 137 /* Constructor */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 203 /* FunctionDeclaration */: - case 165 /* FunctionExpression */: - case 166 /* ArrowFunction */: - case 206 /* TypeAliasDeclaration */: + case 149 /* FunctionType */: + case 150 /* ConstructorType */: + case 144 /* CallSignature */: + case 145 /* ConstructSignature */: + case 146 /* IndexSignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 141 /* Constructor */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 210 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: + case 213 /* TypeAliasDeclaration */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -4149,11 +4342,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 230 /* SourceFile */ ? node : node.body; - if (body.kind === 230 /* SourceFile */ || body.kind === 209 /* ModuleBlock */) { + var body = node.kind === 245 /* SourceFile */ ? node : node.body; + if (body.kind === 245 /* SourceFile */ || body.kind === 216 /* ModuleBlock */) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 218 /* ExportDeclaration */ || stat.kind === 217 /* ExportAssignment */) { + if (stat.kind === 225 /* ExportDeclaration */ || stat.kind === 224 /* ExportAssignment */) { return true; } } @@ -4164,10 +4357,10 @@ var ts; // A declaration source file or ambient module declaration that contains no export declarations (but possibly regular // declarations with export modifiers) is an export context in which declarations are implicitly exported. if (isAmbientContext(node) && !hasExportDeclarations(node)) { - node.flags |= 65536 /* ExportContext */; + node.flags |= 262144 /* ExportContext */; } else { - node.flags &= ~65536 /* ExportContext */; + node.flags &= ~262144 /* ExportContext */; } } function bindModuleDeclaration(node) { @@ -4198,8 +4391,8 @@ var ts; // For a given function symbol "<...>(...) => T" we want to generate a symbol identical // to the one we would get for: { <...>(...): T } // - // We do that by making an anonymous type literal symbol, and then setting the function - // symbol as its sole member. To the rest of the system, this symbol will be indistinguishable + // We do that by making an anonymous type literal symbol, and then setting the function + // symbol as its sole member. To the rest of the system, this symbol will be indistinguishable // from an actual type literal symbol you would have gotten had you used the long form. var symbol = createSymbol(131072 /* Signature */, getDeclarationName(node)); addDeclarationToSymbol(symbol, node, 131072 /* Signature */); @@ -4218,7 +4411,7 @@ var ts; var seen = {}; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 65 /* Identifier */) { + if (prop.name.kind !== 66 /* Identifier */) { continue; } var identifier = prop.name; @@ -4230,7 +4423,7 @@ var ts; // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind = prop.kind === 227 /* PropertyAssignment */ || prop.kind === 228 /* ShorthandPropertyAssignment */ || prop.kind === 136 /* MethodDeclaration */ + var currentKind = prop.kind === 242 /* PropertyAssignment */ || prop.kind === 243 /* ShorthandPropertyAssignment */ || prop.kind === 140 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen[identifier.text]; @@ -4252,10 +4445,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 230 /* SourceFile */: + case 245 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -4276,8 +4469,8 @@ var ts; // check for reserved words used as identifiers in strict mode code. function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 102 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 110 /* LastFutureReservedWord */ && + node.originalKeywordKind >= 103 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 111 /* LastFutureReservedWord */ && !ts.isIdentifierName(node)) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length) { @@ -4286,7 +4479,7 @@ var ts; } } function getStrictModeIdentifierMessage(node) { - // Provide specialized messages to help the user understand why we think they're in + // Provide specialized messages to help the user understand why we think they're in // strict mode. if (ts.getContainingClass(node)) { return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode; @@ -4312,7 +4505,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 65 /* Identifier */) { + if (inStrictMode && node.expression.kind === 66 /* Identifier */) { // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its // UnaryExpression is a direct reference to a variable, function argument, or function name var span = ts.getErrorSpanForNode(file, node.expression); @@ -4320,11 +4513,11 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 65 /* Identifier */ && + return node.kind === 66 /* Identifier */ && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 65 /* Identifier */) { + if (name && name.kind === 66 /* Identifier */) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -4335,7 +4528,7 @@ var ts; } } function getStrictModeEvalOrArgumentsMessage(node) { - // Provide specialized messages to help the user understand why we think they're in + // Provide specialized messages to help the user understand why we think they're in // strict mode. if (ts.getContainingClass(node)) { return ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode; @@ -4352,7 +4545,7 @@ var ts; } } function checkStrictModeNumericLiteral(node) { - if (inStrictMode && node.flags & 16384 /* OctalLiteral */) { + if (inStrictMode && node.flags & 65536 /* OctalLiteral */) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); } } @@ -4368,7 +4561,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 38 /* PlusPlusToken */ || node.operator === 39 /* MinusMinusToken */) { + if (node.operator === 39 /* PlusPlusToken */ || node.operator === 40 /* MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -4393,17 +4586,17 @@ var ts; updateStrictMode(node); } // First we bind declaration nodes to a symbol if possible. We'll both create a symbol - // and then potentially add the symbol to an appropriate symbol table. Possible + // and then potentially add the symbol to an appropriate symbol table. Possible // destination symbol tables are: - // + // // 1) The 'exports' table of the current container's symbol. // 2) The 'members' table of the current container's symbol. // 3) The 'locals' table of the current container. // - // However, not all symbols will end up in any of these tables. 'Anonymous' symbols + // However, not all symbols will end up in any of these tables. 'Anonymous' symbols // (like TypeLiterals for example) will not be put in any table. bindWorker(node); - // Then we recurse into the children of the node to bind them as well. For certain + // Then we recurse into the children of the node to bind them as well. For certain // symbols we do specialized work when we recurse. For example, we'll keep track of // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. @@ -4412,17 +4605,17 @@ var ts; } function updateStrictMode(node) { switch (node.kind) { - case 230 /* SourceFile */: - case 209 /* ModuleBlock */: + case 245 /* SourceFile */: + case 216 /* ModuleBlock */: updateStrictModeStatementList(node.statements); return; - case 182 /* Block */: + case 189 /* Block */: if (ts.isFunctionLike(node.parent)) { updateStrictModeStatementList(node.statements); } return; - case 204 /* ClassDeclaration */: - case 177 /* ClassExpression */: + case 211 /* ClassDeclaration */: + case 183 /* ClassExpression */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return; @@ -4449,91 +4642,92 @@ var ts; } function bindWorker(node) { switch (node.kind) { - case 65 /* Identifier */: + case 66 /* Identifier */: return checkStrictModeIdentifier(node); - case 172 /* BinaryExpression */: + case 178 /* BinaryExpression */: return checkStrictModeBinaryExpression(node); - case 226 /* CatchClause */: + case 241 /* CatchClause */: return checkStrictModeCatchClause(node); - case 167 /* DeleteExpression */: + case 172 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 7 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 171 /* PostfixUnaryExpression */: + case 177 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 170 /* PrefixUnaryExpression */: + case 176 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 195 /* WithStatement */: + case 202 /* WithStatement */: return checkStrictModeWithStatement(node); - case 130 /* TypeParameter */: + case 134 /* TypeParameter */: return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530912 /* TypeParameterExcludes */); - case 131 /* Parameter */: + case 135 /* Parameter */: return bindParameter(node); - case 201 /* VariableDeclaration */: - case 155 /* BindingElement */: + case 208 /* VariableDeclaration */: + case 160 /* BindingElement */: return bindVariableDeclarationOrBindingElement(node); - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 107455 /* PropertyExcludes */); - case 227 /* PropertyAssignment */: - case 228 /* ShorthandPropertyAssignment */: + case 242 /* PropertyAssignment */: + case 243 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 107455 /* PropertyExcludes */); - case 229 /* EnumMember */: + case 244 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */); - case 140 /* CallSignature */: - case 141 /* ConstructSignature */: - case 142 /* IndexSignature */: + case 144 /* CallSignature */: + case 145 /* ConstructSignature */: + case 146 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 107455 /* PropertyExcludes */ : 99263 /* MethodExcludes */); - case 203 /* FunctionDeclaration */: + case 210 /* FunctionDeclaration */: checkStrictModeFunctionName(node); return declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 106927 /* FunctionExcludes */); - case 137 /* Constructor */: + case 141 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, 0 /* None */); - case 138 /* GetAccessor */: + case 142 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); - case 139 /* SetAccessor */: + case 143 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); - case 145 /* FunctionType */: - case 146 /* ConstructorType */: + case 149 /* FunctionType */: + case 150 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 148 /* TypeLiteral */: + case 152 /* TypeLiteral */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 157 /* ObjectLiteralExpression */: + case 162 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 165 /* FunctionExpression */: - case 166 /* ArrowFunction */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: checkStrictModeFunctionName(node); - return bindAnonymousDeclaration(node, 16 /* Function */, "__function"); - case 177 /* ClassExpression */: - case 204 /* ClassDeclaration */: + var bindingName = node.name ? node.name.text : "__function"; + return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); + case 183 /* ClassExpression */: + case 211 /* ClassDeclaration */: return bindClassLikeDeclaration(node); - case 205 /* InterfaceDeclaration */: - return bindBlockScopedDeclaration(node, 64 /* Interface */, 792992 /* InterfaceExcludes */); - case 206 /* TypeAliasDeclaration */: + case 212 /* InterfaceDeclaration */: + return bindBlockScopedDeclaration(node, 64 /* Interface */, 792960 /* InterfaceExcludes */); + case 213 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793056 /* TypeAliasExcludes */); - case 207 /* EnumDeclaration */: + case 214 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: return bindModuleDeclaration(node); - case 211 /* ImportEqualsDeclaration */: - case 214 /* NamespaceImport */: - case 216 /* ImportSpecifier */: - case 220 /* ExportSpecifier */: + case 218 /* ImportEqualsDeclaration */: + case 221 /* NamespaceImport */: + case 223 /* ImportSpecifier */: + case 227 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 213 /* ImportClause */: + case 220 /* ImportClause */: return bindImportClause(node); - case 218 /* ExportDeclaration */: + case 225 /* ExportDeclaration */: return bindExportDeclaration(node); - case 217 /* ExportAssignment */: + case 224 /* ExportAssignment */: return bindExportAssignment(node); - case 230 /* SourceFile */: + case 245 /* SourceFile */: return bindSourceFileIfExternalModule(); } } @@ -4548,7 +4742,7 @@ var ts; // Export assignment in some sort of block construct bindAnonymousDeclaration(node, 8388608 /* Alias */, getDeclarationName(node)); } - else if (node.expression.kind === 65 /* Identifier */) { + else if (node.expression.kind === 66 /* Identifier */) { // An export default clause with an identifier exports all meanings of that identifier declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* Alias */, 107455 /* PropertyExcludes */ | 8388608 /* AliasExcludes */); } @@ -4573,17 +4767,18 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 204 /* ClassDeclaration */) { - bindBlockScopedDeclaration(node, 32 /* Class */, 899583 /* ClassExcludes */); + if (node.kind === 211 /* ClassDeclaration */) { + bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { - bindAnonymousDeclaration(node, 32 /* Class */, "__class"); + var bindingName = node.name ? node.name.text : "__class"; + bindAnonymousDeclaration(node, 32 /* Class */, bindingName); } var symbol = node.symbol; // TypeScript 1.0 spec (April 2014): 8.4 - // Every class automatically contains a static property member named 'prototype', the + // Every class automatically contains a static property member named 'prototype', the // type of which is an instantiation of the class type with type Any supplied as a type - // argument for each type parameter. It is an error to explicitly declare a static + // argument for each type parameter. It is an error to explicitly declare a static // property member with the name 'prototype'. // // Note: we check for this here because this class may be merging into a module. The @@ -4641,10 +4836,10 @@ var ts; else { declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 107455 /* ParameterExcludes */); } - // If this is a property-parameter, then also declare the property symbol into the + // If this is a property-parameter, then also declare the property symbol into the // containing class. if (node.flags & 112 /* AccessibilityModifier */ && - node.parent.kind === 137 /* Constructor */ && + node.parent.kind === 141 /* Constructor */ && ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */); @@ -4663,10 +4858,12 @@ var ts; (function (ts) { function getDeclarationOfKind(symbol, kind) { var declarations = symbol.declarations; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; - if (declaration.kind === kind) { - return declaration; + if (declarations) { + for (var _i = 0; _i < declarations.length; _i++) { + var declaration = declarations[_i]; + if (declaration.kind === kind) { + return declaration; + } } } return undefined; @@ -4711,28 +4908,28 @@ var ts; // Returns true if this node contains a parse error anywhere underneath it. function containsParseError(node) { aggregateChildData(node); - return (node.parserContextFlags & 128 /* ThisNodeOrAnySubNodesHasError */) !== 0; + return (node.parserContextFlags & 64 /* ThisNodeOrAnySubNodesHasError */) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.parserContextFlags & 256 /* HasAggregatedChildData */)) { + if (!(node.parserContextFlags & 128 /* HasAggregatedChildData */)) { // A node is considered to contain a parse error if: // a) the parser explicitly marked that it had an error // b) any of it's children reported that it had an error. - var thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & 32 /* ThisNodeHasError */) !== 0) || + var thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & 16 /* ThisNodeHasError */) !== 0) || ts.forEachChild(node, containsParseError); - // If so, mark ourselves accordingly. + // If so, mark ourselves accordingly. if (thisNodeOrAnySubNodesHasError) { - node.parserContextFlags |= 128 /* ThisNodeOrAnySubNodesHasError */; + node.parserContextFlags |= 64 /* ThisNodeOrAnySubNodesHasError */; } // Also mark that we've propogated the child information to this node. This way we can // always consult the bit directly on this node without needing to check its children // again. - node.parserContextFlags |= 256 /* HasAggregatedChildData */; + node.parserContextFlags |= 128 /* HasAggregatedChildData */; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 230 /* SourceFile */) { + while (node && node.kind !== 245 /* SourceFile */) { node = node.parent; } return node; @@ -4756,13 +4953,13 @@ var ts; ts.getStartPosOfNode = getStartPosOfNode; // Returns true if this node is missing from the actual source code. 'missing' is different // from 'undefined/defined'. When a node is undefined (which can happen for optional nodes - // in the tree), it is definitel missing. HOwever, a node may be defined, but still be + // in the tree), it is definitel missing. HOwever, a node may be defined, but still be // missing. This happens whenever the parser knows it needs to parse something, but can't // get anything in the source code that it expects at that location. For example: // // let a: ; // - // Here, the Type in the Type-Annotation is not-optional (as there is a colon in the source + // Here, the Type in the Type-Annotation is not-optional (as there is a colon in the source // code). So the parser will attempt to parse out a type, and will create an actual node. // However, this node will be 'missing' in the sense that no actual source-code/tokens are // contained within it. @@ -4770,7 +4967,7 @@ var ts; if (!node) { return true; } - return node.pos === node.end && node.kind !== 1 /* EndOfFileToken */; + return node.pos === node.end && node.pos >= 0 && node.kind !== 1 /* EndOfFileToken */; } ts.nodeIsMissing = nodeIsMissing; function nodeIsPresent(node) { @@ -4793,12 +4990,13 @@ var ts; return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end); } ts.getNonDecoratorTokenPosOfNode = getNonDecoratorTokenPosOfNode; - function getSourceTextOfNodeFromSourceFile(sourceFile, node) { + function getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia) { + if (includeTrivia === void 0) { includeTrivia = false; } if (nodeIsMissing(node)) { return ""; } var text = sourceFile.text; - return text.substring(ts.skipTrivia(text, node.pos), node.end); + return text.substring(includeTrivia ? node.pos : ts.skipTrivia(text, node.pos), node.end); } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function getTextOfNodeFromSourceText(sourceText, node) { @@ -4808,8 +5006,9 @@ var ts; return sourceText.substring(ts.skipTrivia(sourceText, node.pos), node.end); } ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText; - function getTextOfNode(node) { - return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node); + function getTextOfNode(node, includeTrivia) { + if (includeTrivia === void 0) { includeTrivia = false; } + return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); } ts.getTextOfNode = getTextOfNode; // Add an extra underscore to identifiers that start with two underscores to avoid issues with magic names like '__proto__' @@ -4829,11 +5028,11 @@ var ts; } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { - return (getCombinedNodeFlags(declaration) & 12288 /* BlockScoped */) !== 0 || + return (getCombinedNodeFlags(declaration) & 49152 /* BlockScoped */) !== 0 || isCatchClauseVariableDeclaration(declaration); } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; - // Gets the nearest enclosing block scope container that has the provided node + // Gets the nearest enclosing block scope container that has the provided node // as a descendant, that is not the provided node. function getEnclosingBlockScopeContainer(node) { var current = node.parent; @@ -4842,15 +5041,15 @@ var ts; return current; } switch (current.kind) { - case 230 /* SourceFile */: - case 210 /* CaseBlock */: - case 226 /* CatchClause */: - case 208 /* ModuleDeclaration */: - case 189 /* ForStatement */: - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: + case 245 /* SourceFile */: + case 217 /* CaseBlock */: + case 241 /* CatchClause */: + case 215 /* ModuleDeclaration */: + case 196 /* ForStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: return current; - case 182 /* Block */: + case 189 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block if (!isFunctionLike(current.parent)) { @@ -4863,9 +5062,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 201 /* VariableDeclaration */ && + declaration.kind === 208 /* VariableDeclaration */ && declaration.parent && - declaration.parent.kind === 226 /* CatchClause */; + declaration.parent.kind === 241 /* CatchClause */; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; // Return display name of an identifier @@ -4895,7 +5094,7 @@ var ts; } ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; function getSpanOfTokenAtPosition(sourceFile, pos) { - var scanner = ts.createScanner(sourceFile.languageVersion, true, sourceFile.text, undefined, pos); + var scanner = ts.createScanner(sourceFile.languageVersion, true, sourceFile.languageVariant, sourceFile.text, undefined, pos); scanner.scan(); var start = scanner.getTokenPos(); return ts.createTextSpanFromBounds(start, scanner.getTextPos()); @@ -4904,7 +5103,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 230 /* SourceFile */: + case 245 /* SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -4913,21 +5112,21 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 201 /* VariableDeclaration */: - case 155 /* BindingElement */: - case 204 /* ClassDeclaration */: - case 177 /* ClassExpression */: - case 205 /* InterfaceDeclaration */: - case 208 /* ModuleDeclaration */: - case 207 /* EnumDeclaration */: - case 229 /* EnumMember */: - case 203 /* FunctionDeclaration */: - case 165 /* FunctionExpression */: + case 208 /* VariableDeclaration */: + case 160 /* BindingElement */: + case 211 /* ClassDeclaration */: + case 183 /* ClassExpression */: + case 212 /* InterfaceDeclaration */: + case 215 /* ModuleDeclaration */: + case 214 /* EnumDeclaration */: + case 244 /* EnumMember */: + case 210 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: errorNode = node.name; break; } if (errorNode === undefined) { - // If we don't have a better node, then just set the error on the first token of + // If we don't have a better node, then just set the error on the first token of // construct. return getSpanOfTokenAtPosition(sourceFile, node.pos); } @@ -4942,57 +5141,57 @@ var ts; } ts.isExternalModule = isExternalModule; function isDeclarationFile(file) { - return (file.flags & 2048 /* DeclarationFile */) !== 0; + return (file.flags & 8192 /* DeclarationFile */) !== 0; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 207 /* EnumDeclaration */ && isConst(node); + return node.kind === 214 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 155 /* BindingElement */ || isBindingPattern(node))) { + while (node && (node.kind === 160 /* BindingElement */ || isBindingPattern(node))) { node = node.parent; } return node; } - // Returns the node flags for this node and all relevant parent nodes. This is done so that + // Returns the node flags for this node and all relevant parent nodes. This is done so that // nodes like variable declarations and binding elements can returned a view of their flags // that includes the modifiers from their container. i.e. flags like export/declare aren't - // stored on the variable declaration directly, but on the containing variable statement + // stored on the variable declaration directly, but on the containing variable statement // (if it has one). Similarly, flags for let/const are store on the variable declaration // list. By calling this function, all those flags are combined so that the client can treat // the node as if it actually had those flags. function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 201 /* VariableDeclaration */) { + if (node.kind === 208 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 202 /* VariableDeclarationList */) { + if (node && node.kind === 209 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 183 /* VariableStatement */) { + if (node && node.kind === 190 /* VariableStatement */) { flags |= node.flags; } return flags; } ts.getCombinedNodeFlags = getCombinedNodeFlags; function isConst(node) { - return !!(getCombinedNodeFlags(node) & 8192 /* Const */); + return !!(getCombinedNodeFlags(node) & 32768 /* Const */); } ts.isConst = isConst; function isLet(node) { - return !!(getCombinedNodeFlags(node) & 4096 /* Let */); + return !!(getCombinedNodeFlags(node) & 16384 /* Let */); } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 185 /* ExpressionStatement */ && node.expression.kind === 8 /* StringLiteral */; + return node.kind === 192 /* ExpressionStatement */ && node.expression.kind === 8 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { // If parameter/type parameter, the prev token trailing comments are part of this node too - if (node.kind === 131 /* Parameter */ || node.kind === 130 /* TypeParameter */) { + if (node.kind === 135 /* Parameter */ || node.kind === 134 /* TypeParameter */) { // e.g. (/** blah */ a, /** blah */ b); // e.g.: ( // /** blah */ a, @@ -5016,40 +5215,40 @@ var ts; ts.getJsDocComments = getJsDocComments; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (144 /* FirstTypeNode */ <= node.kind && node.kind <= 152 /* LastTypeNode */) { + if (148 /* FirstTypeNode */ <= node.kind && node.kind <= 157 /* LastTypeNode */) { return true; } switch (node.kind) { - case 112 /* AnyKeyword */: - case 121 /* NumberKeyword */: - case 123 /* StringKeyword */: - case 113 /* BooleanKeyword */: - case 124 /* SymbolKeyword */: + case 114 /* AnyKeyword */: + case 125 /* NumberKeyword */: + case 127 /* StringKeyword */: + case 117 /* BooleanKeyword */: + case 128 /* SymbolKeyword */: return true; - case 99 /* VoidKeyword */: - return node.parent.kind !== 169 /* VoidExpression */; + case 100 /* VoidKeyword */: + return node.parent.kind !== 174 /* VoidExpression */; case 8 /* StringLiteral */: // Specialized signatures can have string literals as their parameters' type names - return node.parent.kind === 131 /* Parameter */; - case 179 /* ExpressionWithTypeArguments */: + return node.parent.kind === 135 /* Parameter */; + case 185 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 65 /* Identifier */: + case 66 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 128 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 132 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 158 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 163 /* PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // fall through - case 128 /* QualifiedName */: - case 158 /* PropertyAccessExpression */: + case 132 /* QualifiedName */: + case 163 /* PropertyAccessExpression */: // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 65 /* Identifier */ || node.kind === 128 /* QualifiedName */ || node.kind === 158 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + ts.Debug.assert(node.kind === 66 /* Identifier */ || node.kind === 132 /* QualifiedName */ || node.kind === 163 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); var parent_1 = node.parent; - if (parent_1.kind === 147 /* TypeQuery */) { + if (parent_1.kind === 151 /* TypeQuery */) { return false; } // Do not recursively call isTypeNode on the parent. In the example: @@ -5058,38 +5257,38 @@ var ts; // // Calling isTypeNode would consider the qualified name A.B a type node. Only C or // A.B.C is a type node. - if (144 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 152 /* LastTypeNode */) { + if (148 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 157 /* LastTypeNode */) { return true; } switch (parent_1.kind) { - case 179 /* ExpressionWithTypeArguments */: + case 185 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 130 /* TypeParameter */: + case 134 /* TypeParameter */: return node === parent_1.constraint; - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: - case 131 /* Parameter */: - case 201 /* VariableDeclaration */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: + case 135 /* Parameter */: + case 208 /* VariableDeclaration */: return node === parent_1.type; - case 203 /* FunctionDeclaration */: - case 165 /* FunctionExpression */: - case 166 /* ArrowFunction */: - case 137 /* Constructor */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: + case 210 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: + case 141 /* Constructor */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: return node === parent_1.type; - case 140 /* CallSignature */: - case 141 /* ConstructSignature */: - case 142 /* IndexSignature */: + case 144 /* CallSignature */: + case 145 /* ConstructSignature */: + case 146 /* IndexSignature */: return node === parent_1.type; - case 163 /* TypeAssertionExpression */: + case 168 /* TypeAssertionExpression */: return node === parent_1.type; - case 160 /* CallExpression */: - case 161 /* NewExpression */: + case 165 /* CallExpression */: + case 166 /* NewExpression */: return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 162 /* TaggedTemplateExpression */: + case 167 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -5103,23 +5302,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 194 /* ReturnStatement */: + case 201 /* ReturnStatement */: return visitor(node); - case 210 /* CaseBlock */: - case 182 /* Block */: - case 186 /* IfStatement */: - case 187 /* DoStatement */: - case 188 /* WhileStatement */: - case 189 /* ForStatement */: - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: - case 195 /* WithStatement */: - case 196 /* SwitchStatement */: - case 223 /* CaseClause */: - case 224 /* DefaultClause */: - case 197 /* LabeledStatement */: - case 199 /* TryStatement */: - case 226 /* CatchClause */: + case 217 /* CaseBlock */: + case 189 /* Block */: + case 193 /* IfStatement */: + case 194 /* DoStatement */: + case 195 /* WhileStatement */: + case 196 /* ForStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: + case 202 /* WithStatement */: + case 203 /* SwitchStatement */: + case 238 /* CaseClause */: + case 239 /* DefaultClause */: + case 204 /* LabeledStatement */: + case 206 /* TryStatement */: + case 241 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -5129,29 +5328,29 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 175 /* YieldExpression */: + case 181 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 207 /* EnumDeclaration */: - case 205 /* InterfaceDeclaration */: - case 208 /* ModuleDeclaration */: - case 206 /* TypeAliasDeclaration */: - case 204 /* ClassDeclaration */: - case 177 /* ClassExpression */: + case 214 /* EnumDeclaration */: + case 212 /* InterfaceDeclaration */: + case 215 /* ModuleDeclaration */: + case 213 /* TypeAliasDeclaration */: + case 211 /* ClassDeclaration */: + case 183 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. return; default: if (isFunctionLike(node)) { - var name_4 = node.name; - if (name_4 && name_4.kind === 129 /* ComputedPropertyName */) { + var name_5 = node.name; + if (name_5 && name_5.kind === 133 /* ComputedPropertyName */) { // Note that we will not include methods/accessors of a class because they would require // first descending into the class. This is by design. - traverse(name_4.expression); + traverse(name_5.expression); return; } } @@ -5167,14 +5366,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 155 /* BindingElement */: - case 229 /* EnumMember */: - case 131 /* Parameter */: - case 227 /* PropertyAssignment */: - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: - case 228 /* ShorthandPropertyAssignment */: - case 201 /* VariableDeclaration */: + case 160 /* BindingElement */: + case 244 /* EnumMember */: + case 135 /* Parameter */: + case 242 /* PropertyAssignment */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: + case 243 /* ShorthandPropertyAssignment */: + case 208 /* VariableDeclaration */: return true; } } @@ -5182,29 +5381,29 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 138 /* GetAccessor */ || node.kind === 139 /* SetAccessor */); + return node && (node.kind === 142 /* GetAccessor */ || node.kind === 143 /* SetAccessor */); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 204 /* ClassDeclaration */ || node.kind === 177 /* ClassExpression */); + return node && (node.kind === 211 /* ClassDeclaration */ || node.kind === 183 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 137 /* Constructor */: - case 165 /* FunctionExpression */: - case 203 /* FunctionDeclaration */: - case 166 /* ArrowFunction */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 140 /* CallSignature */: - case 141 /* ConstructSignature */: - case 142 /* IndexSignature */: - case 145 /* FunctionType */: - case 146 /* ConstructorType */: + case 141 /* Constructor */: + case 170 /* FunctionExpression */: + case 210 /* FunctionDeclaration */: + case 171 /* ArrowFunction */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 144 /* CallSignature */: + case 145 /* ConstructSignature */: + case 146 /* IndexSignature */: + case 149 /* FunctionType */: + case 150 /* ConstructorType */: return true; } } @@ -5212,11 +5411,11 @@ var ts; } ts.isFunctionLike = isFunctionLike; function isFunctionBlock(node) { - return node && node.kind === 182 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 189 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 136 /* MethodDeclaration */ && node.parent.kind === 157 /* ObjectLiteralExpression */; + return node && node.kind === 140 /* MethodDeclaration */ && node.parent.kind === 162 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -5244,7 +5443,7 @@ var ts; return undefined; } switch (node.kind) { - case 129 /* ComputedPropertyName */: + case 133 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'this' container. // A computed property name in a class needs to be a this container @@ -5259,9 +5458,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 132 /* Decorator */: - // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 131 /* Parameter */ && isClassElement(node.parent.parent)) { + case 136 /* Decorator */: + // Decorators are always applied outside of the body of a class or method. + if (node.parent.kind === 135 /* Parameter */ && isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -5272,23 +5471,23 @@ var ts; node = node.parent; } break; - case 166 /* ArrowFunction */: + case 171 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // Fall through - case 203 /* FunctionDeclaration */: - case 165 /* FunctionExpression */: - case 208 /* ModuleDeclaration */: - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 137 /* Constructor */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 207 /* EnumDeclaration */: - case 230 /* SourceFile */: + case 210 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: + case 215 /* ModuleDeclaration */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 141 /* Constructor */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 214 /* EnumDeclaration */: + case 245 /* SourceFile */: return node; } } @@ -5300,7 +5499,7 @@ var ts; if (!node) return node; switch (node.kind) { - case 129 /* ComputedPropertyName */: + case 133 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'super' container. // A computed property name in a class needs to be a super container @@ -5315,9 +5514,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 132 /* Decorator */: - // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 131 /* Parameter */ && isClassElement(node.parent.parent)) { + case 136 /* Decorator */: + // Decorators are always applied outside of the body of a class or method. + if (node.parent.kind === 135 /* Parameter */ && isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -5328,26 +5527,41 @@ var ts; node = node.parent; } break; - case 203 /* FunctionDeclaration */: - case 165 /* FunctionExpression */: - case 166 /* ArrowFunction */: + case 210 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: if (!includeFunctions) { continue; } - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 137 /* Constructor */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 141 /* Constructor */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: return node; } } } ts.getSuperContainer = getSuperContainer; + function getEntityNameFromTypeNode(node) { + if (node) { + switch (node.kind) { + case 148 /* TypeReference */: + return node.typeName; + case 185 /* ExpressionWithTypeArguments */: + return node.expression; + case 66 /* Identifier */: + case 132 /* QualifiedName */: + return node; + } + } + return undefined; + } + ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { - if (node.kind === 162 /* TaggedTemplateExpression */) { + if (node.kind === 167 /* TaggedTemplateExpression */) { return node.tag; } // Will either be a CallExpression, NewExpression, or Decorator. @@ -5356,44 +5570,44 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 204 /* ClassDeclaration */: + case 211 /* ClassDeclaration */: // classes are valid targets return true; - case 134 /* PropertyDeclaration */: + case 138 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 204 /* ClassDeclaration */; - case 131 /* Parameter */: + return node.parent.kind === 211 /* ClassDeclaration */; + case 135 /* Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; - return node.parent.body && node.parent.parent.kind === 204 /* ClassDeclaration */; - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 136 /* MethodDeclaration */: + return node.parent.body && node.parent.parent.kind === 211 /* ClassDeclaration */; + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 140 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. - return node.body && node.parent.kind === 204 /* ClassDeclaration */; + return node.body && node.parent.kind === 211 /* ClassDeclaration */; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 204 /* ClassDeclaration */: + case 211 /* ClassDeclaration */: if (node.decorators) { return true; } return false; - case 134 /* PropertyDeclaration */: - case 131 /* Parameter */: + case 138 /* PropertyDeclaration */: + case 135 /* Parameter */: if (node.decorators) { return true; } return false; - case 138 /* GetAccessor */: + case 142 /* GetAccessor */: if (node.body && node.decorators) { return true; } return false; - case 136 /* MethodDeclaration */: - case 139 /* SetAccessor */: + case 140 /* MethodDeclaration */: + case 143 /* SetAccessor */: if (node.body && node.decorators) { return true; } @@ -5404,10 +5618,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 204 /* ClassDeclaration */: + case 211 /* ClassDeclaration */: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 136 /* MethodDeclaration */: - case 139 /* SetAccessor */: + case 140 /* MethodDeclaration */: + case 143 /* SetAccessor */: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -5419,44 +5633,47 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function isExpression(node) { switch (node.kind) { - case 93 /* ThisKeyword */: - case 91 /* SuperKeyword */: - case 89 /* NullKeyword */: - case 95 /* TrueKeyword */: - case 80 /* FalseKeyword */: + case 94 /* ThisKeyword */: + case 92 /* SuperKeyword */: + case 90 /* NullKeyword */: + case 96 /* TrueKeyword */: + case 81 /* FalseKeyword */: case 9 /* RegularExpressionLiteral */: - case 156 /* ArrayLiteralExpression */: - case 157 /* ObjectLiteralExpression */: - case 158 /* PropertyAccessExpression */: - case 159 /* ElementAccessExpression */: - case 160 /* CallExpression */: - case 161 /* NewExpression */: - case 162 /* TaggedTemplateExpression */: - case 163 /* TypeAssertionExpression */: - case 164 /* ParenthesizedExpression */: - case 165 /* FunctionExpression */: - case 177 /* ClassExpression */: - case 166 /* ArrowFunction */: - case 169 /* VoidExpression */: - case 167 /* DeleteExpression */: - case 168 /* TypeOfExpression */: - case 170 /* PrefixUnaryExpression */: - case 171 /* PostfixUnaryExpression */: - case 172 /* BinaryExpression */: - case 173 /* ConditionalExpression */: - case 176 /* SpreadElementExpression */: - case 174 /* TemplateExpression */: + case 161 /* ArrayLiteralExpression */: + case 162 /* ObjectLiteralExpression */: + case 163 /* PropertyAccessExpression */: + case 164 /* ElementAccessExpression */: + case 165 /* CallExpression */: + case 166 /* NewExpression */: + case 167 /* TaggedTemplateExpression */: + case 186 /* AsExpression */: + case 168 /* TypeAssertionExpression */: + case 169 /* ParenthesizedExpression */: + case 170 /* FunctionExpression */: + case 183 /* ClassExpression */: + case 171 /* ArrowFunction */: + case 174 /* VoidExpression */: + case 172 /* DeleteExpression */: + case 173 /* TypeOfExpression */: + case 176 /* PrefixUnaryExpression */: + case 177 /* PostfixUnaryExpression */: + case 178 /* BinaryExpression */: + case 179 /* ConditionalExpression */: + case 182 /* SpreadElementExpression */: + case 180 /* TemplateExpression */: case 10 /* NoSubstitutionTemplateLiteral */: - case 178 /* OmittedExpression */: - case 175 /* YieldExpression */: + case 184 /* OmittedExpression */: + case 230 /* JsxElement */: + case 231 /* JsxSelfClosingElement */: + case 181 /* YieldExpression */: return true; - case 128 /* QualifiedName */: - while (node.parent.kind === 128 /* QualifiedName */) { + case 132 /* QualifiedName */: + while (node.parent.kind === 132 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 147 /* TypeQuery */; - case 65 /* Identifier */: - if (node.parent.kind === 147 /* TypeQuery */) { + return node.parent.kind === 151 /* TypeQuery */; + case 66 /* Identifier */: + if (node.parent.kind === 151 /* TypeQuery */) { return true; } // fall through @@ -5464,44 +5681,45 @@ var ts; case 8 /* StringLiteral */: var parent_2 = node.parent; switch (parent_2.kind) { - case 201 /* VariableDeclaration */: - case 131 /* Parameter */: - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: - case 229 /* EnumMember */: - case 227 /* PropertyAssignment */: - case 155 /* BindingElement */: + case 208 /* VariableDeclaration */: + case 135 /* Parameter */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: + case 244 /* EnumMember */: + case 242 /* PropertyAssignment */: + case 160 /* BindingElement */: return parent_2.initializer === node; - case 185 /* ExpressionStatement */: - case 186 /* IfStatement */: - case 187 /* DoStatement */: - case 188 /* WhileStatement */: - case 194 /* ReturnStatement */: - case 195 /* WithStatement */: - case 196 /* SwitchStatement */: - case 223 /* CaseClause */: - case 198 /* ThrowStatement */: - case 196 /* SwitchStatement */: + case 192 /* ExpressionStatement */: + case 193 /* IfStatement */: + case 194 /* DoStatement */: + case 195 /* WhileStatement */: + case 201 /* ReturnStatement */: + case 202 /* WithStatement */: + case 203 /* SwitchStatement */: + case 238 /* CaseClause */: + case 205 /* ThrowStatement */: + case 203 /* SwitchStatement */: return parent_2.expression === node; - case 189 /* ForStatement */: + case 196 /* ForStatement */: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 202 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 209 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 202 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 209 /* VariableDeclarationList */) || forInStatement.expression === node; - case 163 /* TypeAssertionExpression */: + case 168 /* TypeAssertionExpression */: + case 186 /* AsExpression */: return node === parent_2.expression; - case 180 /* TemplateSpan */: + case 187 /* TemplateSpan */: return node === parent_2.expression; - case 129 /* ComputedPropertyName */: + case 133 /* ComputedPropertyName */: return node === parent_2.expression; - case 132 /* Decorator */: + case 136 /* Decorator */: return true; - case 179 /* ExpressionWithTypeArguments */: + case 185 /* ExpressionWithTypeArguments */: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -5519,7 +5737,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 211 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 222 /* ExternalModuleReference */; + return node.kind === 218 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 229 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -5528,20 +5746,20 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 211 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 222 /* ExternalModuleReference */; + return node.kind === 218 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 229 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function getExternalModuleName(node) { - if (node.kind === 212 /* ImportDeclaration */) { + if (node.kind === 219 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 211 /* ImportEqualsDeclaration */) { + if (node.kind === 218 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 222 /* ExternalModuleReference */) { + if (reference.kind === 229 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 218 /* ExportDeclaration */) { + if (node.kind === 225 /* ExportDeclaration */) { return node.moduleSpecifier; } } @@ -5549,15 +5767,15 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 131 /* Parameter */: + case 135 /* Parameter */: return node.questionToken !== undefined; - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: return node.questionToken !== undefined; - case 228 /* ShorthandPropertyAssignment */: - case 227 /* PropertyAssignment */: - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: + case 243 /* ShorthandPropertyAssignment */: + case 242 /* PropertyAssignment */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -5565,9 +5783,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 243 /* JSDocFunctionType */ && + return node.kind === 258 /* JSDocFunctionType */ && node.parameters.length > 0 && - node.parameters[0].type.kind === 245 /* JSDocConstructorType */; + node.parameters[0].type.kind === 260 /* JSDocConstructorType */; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -5581,29 +5799,29 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 251 /* JSDocTypeTag */); + return getJSDocTag(node, 266 /* JSDocTypeTag */); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 250 /* JSDocReturnTag */); + return getJSDocTag(node, 265 /* JSDocReturnTag */); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 252 /* JSDocTemplateTag */); + return getJSDocTag(node, 267 /* JSDocTemplateTag */); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 65 /* Identifier */) { - // If it's a parameter, see if the parent has a jsdoc comment with an @param + if (parameter.name && parameter.name.kind === 66 /* Identifier */) { + // If it's a parameter, see if the parent has a jsdoc comment with an @param // annotation. var parameterName = parameter.name.text; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 249 /* JSDocParameterTag */) { + if (t.kind === 264 /* JSDocParameterTag */) { var parameterTag = t; - var name_5 = parameterTag.preParameterName || parameterTag.postParameterName; - if (name_5.text === parameterName) { + var name_6 = parameterTag.preParameterName || parameterTag.postParameterName; + if (name_6.text === parameterName) { return t; } } @@ -5618,13 +5836,13 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { if (node) { - if (node.parserContextFlags & 64 /* JavaScriptFile */) { - if (node.type && node.type.kind === 244 /* JSDocVariadicType */) { + if (node.parserContextFlags & 32 /* JavaScriptFile */) { + if (node.type && node.type.kind === 259 /* JSDocVariadicType */) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 244 /* JSDocVariadicType */; + return paramTag.typeExpression.type.kind === 259 /* JSDocVariadicType */; } } return node.dotDotDotToken !== undefined; @@ -5645,12 +5863,12 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 154 /* ArrayBindingPattern */ || node.kind === 153 /* ObjectBindingPattern */); + return !!node && (node.kind === 159 /* ArrayBindingPattern */ || node.kind === 158 /* ObjectBindingPattern */); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { while (node) { - if (node.flags & (2 /* Ambient */ | 2048 /* DeclarationFile */)) { + if (node.flags & (2 /* Ambient */ | 8192 /* DeclarationFile */)) { return true; } node = node.parent; @@ -5660,34 +5878,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 166 /* ArrowFunction */: - case 155 /* BindingElement */: - case 204 /* ClassDeclaration */: - case 177 /* ClassExpression */: - case 137 /* Constructor */: - case 207 /* EnumDeclaration */: - case 229 /* EnumMember */: - case 220 /* ExportSpecifier */: - case 203 /* FunctionDeclaration */: - case 165 /* FunctionExpression */: - case 138 /* GetAccessor */: - case 213 /* ImportClause */: - case 211 /* ImportEqualsDeclaration */: - case 216 /* ImportSpecifier */: - case 205 /* InterfaceDeclaration */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 208 /* ModuleDeclaration */: - case 214 /* NamespaceImport */: - case 131 /* Parameter */: - case 227 /* PropertyAssignment */: - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: - case 139 /* SetAccessor */: - case 228 /* ShorthandPropertyAssignment */: - case 206 /* TypeAliasDeclaration */: - case 130 /* TypeParameter */: - case 201 /* VariableDeclaration */: + case 171 /* ArrowFunction */: + case 160 /* BindingElement */: + case 211 /* ClassDeclaration */: + case 183 /* ClassExpression */: + case 141 /* Constructor */: + case 214 /* EnumDeclaration */: + case 244 /* EnumMember */: + case 227 /* ExportSpecifier */: + case 210 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: + case 142 /* GetAccessor */: + case 220 /* ImportClause */: + case 218 /* ImportEqualsDeclaration */: + case 223 /* ImportSpecifier */: + case 212 /* InterfaceDeclaration */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 215 /* ModuleDeclaration */: + case 221 /* NamespaceImport */: + case 135 /* Parameter */: + case 242 /* PropertyAssignment */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: + case 143 /* SetAccessor */: + case 243 /* ShorthandPropertyAssignment */: + case 213 /* TypeAliasDeclaration */: + case 134 /* TypeParameter */: + case 208 /* VariableDeclaration */: return true; } return false; @@ -5695,25 +5913,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 193 /* BreakStatement */: - case 192 /* ContinueStatement */: - case 200 /* DebuggerStatement */: - case 187 /* DoStatement */: - case 185 /* ExpressionStatement */: - case 184 /* EmptyStatement */: - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: - case 189 /* ForStatement */: - case 186 /* IfStatement */: - case 197 /* LabeledStatement */: - case 194 /* ReturnStatement */: - case 196 /* SwitchStatement */: - case 94 /* ThrowKeyword */: - case 199 /* TryStatement */: - case 183 /* VariableStatement */: - case 188 /* WhileStatement */: - case 195 /* WithStatement */: - case 217 /* ExportAssignment */: + case 200 /* BreakStatement */: + case 199 /* ContinueStatement */: + case 207 /* DebuggerStatement */: + case 194 /* DoStatement */: + case 192 /* ExpressionStatement */: + case 191 /* EmptyStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: + case 196 /* ForStatement */: + case 193 /* IfStatement */: + case 204 /* LabeledStatement */: + case 201 /* ReturnStatement */: + case 203 /* SwitchStatement */: + case 95 /* ThrowKeyword */: + case 206 /* TryStatement */: + case 190 /* VariableStatement */: + case 195 /* WhileStatement */: + case 202 /* WithStatement */: + case 224 /* ExportAssignment */: return true; default: return false; @@ -5722,13 +5940,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 137 /* Constructor */: - case 134 /* PropertyDeclaration */: - case 136 /* MethodDeclaration */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 135 /* MethodSignature */: - case 142 /* IndexSignature */: + case 141 /* Constructor */: + case 138 /* PropertyDeclaration */: + case 140 /* MethodDeclaration */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 139 /* MethodSignature */: + case 146 /* IndexSignature */: return true; default: return false; @@ -5737,11 +5955,11 @@ var ts; ts.isClassElement = isClassElement; // True if the given identifier, string literal, or number literal is the name of a declaration node function isDeclarationName(name) { - if (name.kind !== 65 /* Identifier */ && name.kind !== 8 /* StringLiteral */ && name.kind !== 7 /* NumericLiteral */) { + if (name.kind !== 66 /* Identifier */ && name.kind !== 8 /* StringLiteral */ && name.kind !== 7 /* NumericLiteral */) { return false; } var parent = name.parent; - if (parent.kind === 216 /* ImportSpecifier */ || parent.kind === 220 /* ExportSpecifier */) { + if (parent.kind === 223 /* ImportSpecifier */ || parent.kind === 227 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -5756,31 +5974,31 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 229 /* EnumMember */: - case 227 /* PropertyAssignment */: - case 158 /* PropertyAccessExpression */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 244 /* EnumMember */: + case 242 /* PropertyAssignment */: + case 163 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 128 /* QualifiedName */: + case 132 /* QualifiedName */: // Name on right hand side of dot in a type query if (parent.right === node) { - while (parent.kind === 128 /* QualifiedName */) { + while (parent.kind === 132 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 147 /* TypeQuery */; + return parent.kind === 151 /* TypeQuery */; } return false; - case 155 /* BindingElement */: - case 216 /* ImportSpecifier */: + case 160 /* BindingElement */: + case 223 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 220 /* ExportSpecifier */: + case 227 /* ExportSpecifier */: // Any name in an export specifier return true; } @@ -5796,26 +6014,26 @@ var ts; // export = ... // export default ... function isAliasSymbolDeclaration(node) { - return node.kind === 211 /* ImportEqualsDeclaration */ || - node.kind === 213 /* ImportClause */ && !!node.name || - node.kind === 214 /* NamespaceImport */ || - node.kind === 216 /* ImportSpecifier */ || - node.kind === 220 /* ExportSpecifier */ || - node.kind === 217 /* ExportAssignment */ && node.expression.kind === 65 /* Identifier */; + return node.kind === 218 /* ImportEqualsDeclaration */ || + node.kind === 220 /* ImportClause */ && !!node.name || + node.kind === 221 /* NamespaceImport */ || + node.kind === 223 /* ImportSpecifier */ || + node.kind === 227 /* ExportSpecifier */ || + node.kind === 224 /* ExportAssignment */ && node.expression.kind === 66 /* Identifier */; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 79 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 80 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 102 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 103 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 79 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 80 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -5884,13 +6102,17 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 66 /* FirstKeyword */ <= token && token <= 127 /* LastKeyword */; + return 67 /* FirstKeyword */ <= token && token <= 131 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { return 2 /* FirstTriviaToken */ <= token && token <= 6 /* LastTriviaToken */; } ts.isTrivia = isTrivia; + function isAsyncFunctionLike(node) { + return isFunctionLike(node) && (node.flags & 512 /* Async */) !== 0 && !isAccessor(node); + } + ts.isAsyncFunctionLike = isAsyncFunctionLike; /** * A declaration has a dynamic name if both of the following are true: * 1. The declaration has a computed property name @@ -5900,7 +6122,7 @@ var ts; */ function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 129 /* ComputedPropertyName */ && + declaration.name.kind === 133 /* ComputedPropertyName */ && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; @@ -5910,14 +6132,14 @@ var ts; * where Symbol is literally the word "Symbol", and name is any identifierName */ function isWellKnownSymbolSyntactically(node) { - return node.kind === 158 /* PropertyAccessExpression */ && isESSymbolIdentifier(node.expression); + return node.kind === 163 /* PropertyAccessExpression */ && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 65 /* Identifier */ || name.kind === 8 /* StringLiteral */ || name.kind === 7 /* NumericLiteral */) { + if (name.kind === 66 /* Identifier */ || name.kind === 8 /* StringLiteral */ || name.kind === 7 /* NumericLiteral */) { return name.text; } - if (name.kind === 129 /* ComputedPropertyName */) { + if (name.kind === 133 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -5935,19 +6157,21 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 65 /* Identifier */ && node.text === "Symbol"; + return node.kind === 66 /* Identifier */ && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isModifier(token) { switch (token) { - case 108 /* PublicKeyword */: - case 106 /* PrivateKeyword */: - case 107 /* ProtectedKeyword */: - case 109 /* StaticKeyword */: - case 78 /* ExportKeyword */: - case 115 /* DeclareKeyword */: - case 70 /* ConstKeyword */: - case 73 /* DefaultKeyword */: + case 112 /* AbstractKeyword */: + case 115 /* AsyncKeyword */: + case 71 /* ConstKeyword */: + case 119 /* DeclareKeyword */: + case 74 /* DefaultKeyword */: + case 79 /* ExportKeyword */: + case 109 /* PublicKeyword */: + case 107 /* PrivateKeyword */: + case 108 /* ProtectedKeyword */: + case 110 /* StaticKeyword */: return true; } return false; @@ -5955,18 +6179,18 @@ var ts; ts.isModifier = isModifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 131 /* Parameter */; + return root.kind === 135 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 155 /* BindingElement */) { + while (node.kind === 160 /* BindingElement */) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 208 /* ModuleDeclaration */ || n.kind === 230 /* SourceFile */; + return isFunctionLike(n) || n.kind === 215 /* ModuleDeclaration */ || n.kind === 245 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -5975,8 +6199,6 @@ var ts; ts.nodeIsSynthesized = nodeIsSynthesized; function createSynthesizedNode(kind, startsOnNewLine) { var node = ts.createNode(kind); - node.pos = -1; - node.end = -1; node.startsOnNewLine = startsOnNewLine; return node; } @@ -6086,6 +6308,11 @@ var ts; } } ts.escapeString = escapeString; + function isIntrinsicJsxName(name) { + var ch = name.substr(0, 1); + return ch.toLowerCase() === ch; + } + ts.isIntrinsicJsxName = isIntrinsicJsxName; function get16BitUnicodeEscapeSequence(charCode) { var hexCharCode = charCode.toString(16).toUpperCase(); var paddedHexCode = ("0000" + hexCharCode).slice(-4); @@ -6202,12 +6429,16 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 137 /* Constructor */ && nodeIsPresent(member.body)) { + if (member.kind === 141 /* Constructor */ && nodeIsPresent(member.body)) { return member; } }); } ts.getFirstConstructorWithBody = getFirstConstructorWithBody; + function getSetAccessorTypeAnnotationNode(accessor) { + return accessor && accessor.parameters.length > 0 && accessor.parameters[0].type; + } + ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; function shouldEmitToOwnFile(sourceFile, compilerOptions) { if (!isDeclarationFile(sourceFile)) { if ((isExternalModule(sourceFile) || !compilerOptions.out)) { @@ -6227,10 +6458,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 138 /* GetAccessor */) { + if (accessor.kind === 142 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 139 /* SetAccessor */) { + else if (accessor.kind === 143 /* SetAccessor */) { setAccessor = accessor; } else { @@ -6239,7 +6470,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 138 /* GetAccessor */ || member.kind === 139 /* SetAccessor */) + if ((member.kind === 142 /* GetAccessor */ || member.kind === 143 /* SetAccessor */) && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -6250,10 +6481,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 138 /* GetAccessor */ && !getAccessor) { + if (member.kind === 142 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 139 /* SetAccessor */ && !setAccessor) { + if (member.kind === 143 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -6386,14 +6617,16 @@ var ts; ts.writeCommentRange = writeCommentRange; function modifierToFlag(token) { switch (token) { - case 109 /* StaticKeyword */: return 128 /* Static */; - case 108 /* PublicKeyword */: return 16 /* Public */; - case 107 /* ProtectedKeyword */: return 64 /* Protected */; - case 106 /* PrivateKeyword */: return 32 /* Private */; - case 78 /* ExportKeyword */: return 1 /* Export */; - case 115 /* DeclareKeyword */: return 2 /* Ambient */; - case 70 /* ConstKeyword */: return 8192 /* Const */; - case 73 /* DefaultKeyword */: return 256 /* Default */; + case 110 /* StaticKeyword */: return 128 /* Static */; + case 109 /* PublicKeyword */: return 16 /* Public */; + case 108 /* ProtectedKeyword */: return 64 /* Protected */; + case 107 /* PrivateKeyword */: return 32 /* Private */; + case 112 /* AbstractKeyword */: return 256 /* Abstract */; + case 79 /* ExportKeyword */: return 1 /* Export */; + case 119 /* DeclareKeyword */: return 2 /* Ambient */; + case 71 /* ConstKeyword */: return 32768 /* Const */; + case 74 /* DefaultKeyword */: return 1024 /* Default */; + case 115 /* AsyncKeyword */: return 512 /* Async */; } return 0; } @@ -6401,27 +6634,29 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 158 /* PropertyAccessExpression */: - case 159 /* ElementAccessExpression */: - case 161 /* NewExpression */: - case 160 /* CallExpression */: - case 162 /* TaggedTemplateExpression */: - case 156 /* ArrayLiteralExpression */: - case 164 /* ParenthesizedExpression */: - case 157 /* ObjectLiteralExpression */: - case 177 /* ClassExpression */: - case 165 /* FunctionExpression */: - case 65 /* Identifier */: + case 163 /* PropertyAccessExpression */: + case 164 /* ElementAccessExpression */: + case 166 /* NewExpression */: + case 165 /* CallExpression */: + case 230 /* JsxElement */: + case 231 /* JsxSelfClosingElement */: + case 167 /* TaggedTemplateExpression */: + case 161 /* ArrayLiteralExpression */: + case 169 /* ParenthesizedExpression */: + case 162 /* ObjectLiteralExpression */: + case 183 /* ClassExpression */: + case 170 /* FunctionExpression */: + case 66 /* Identifier */: case 9 /* RegularExpressionLiteral */: case 7 /* NumericLiteral */: case 8 /* StringLiteral */: case 10 /* NoSubstitutionTemplateLiteral */: - case 174 /* TemplateExpression */: - case 80 /* FalseKeyword */: - case 89 /* NullKeyword */: - case 93 /* ThisKeyword */: - case 95 /* TrueKeyword */: - case 91 /* SuperKeyword */: + case 180 /* TemplateExpression */: + case 81 /* FalseKeyword */: + case 90 /* NullKeyword */: + case 94 /* ThisKeyword */: + case 96 /* TrueKeyword */: + case 92 /* SuperKeyword */: return true; } } @@ -6429,12 +6664,12 @@ var ts; } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isAssignmentOperator(token) { - return token >= 53 /* FirstAssignment */ && token <= 64 /* LastAssignment */; + return token >= 54 /* FirstAssignment */ && token <= 65 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 179 /* ExpressionWithTypeArguments */ && - node.parent.token === 79 /* ExtendsKeyword */ && + return node.kind === 185 /* ExpressionWithTypeArguments */ && + node.parent.token === 80 /* ExtendsKeyword */ && isClassLike(node.parent.parent); } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; @@ -6445,10 +6680,10 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 65 /* Identifier */) { + if (node.kind === 66 /* Identifier */) { return true; } - else if (node.kind === 158 /* PropertyAccessExpression */) { + else if (node.kind === 163 /* PropertyAccessExpression */) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { @@ -6456,18 +6691,22 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 128 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 158 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 132 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 163 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function getLocalSymbolForExportDefault(symbol) { - return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 256 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; + return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; function isJavaScript(fileName) { return ts.fileExtensionIs(fileName, ".js"); } ts.isJavaScript = isJavaScript; + function isTsx(fileName) { + return ts.fileExtensionIs(fileName, ".tsx"); + } + ts.isTsx = isTsx; /** * Replace each instance of non-ascii characters by one, two, three, or four escape sequences * representing the UTF-8 encoding of the character, and return the expanded char code list. @@ -6475,7 +6714,6 @@ var ts; function getExpandedCharCodes(input) { var output = []; var length = input.length; - var leadSurrogate = undefined; for (var i = 0; i < length; i++) { var charCode = input.charCodeAt(i); // handel utf8 @@ -6677,17 +6915,17 @@ var ts; // // 0 10 20 30 40 50 60 70 80 90 100 // ------------------------------------------------------------------------------------------------------- - // | / - // | /---- - // T1 | /---- - // | /---- - // | /---- + // | / + // | /---- + // T1 | /---- + // | /---- + // | /---- // ------------------------------------------------------------------------------------------------------- - // | \ - // | \ - // T2 | \ - // | \ - // | \ + // | \ + // | \ + // T2 | \ + // | \ + // | \ // ------------------------------------------------------------------------------------------------------- // // Merging these turns out to not be too difficult. First, determining the new start of the change is trivial @@ -6695,17 +6933,17 @@ var ts; // // 0 10 20 30 40 50 60 70 80 90 100 // ------------------------------------------------------------*------------------------------------------ - // | / - // | /---- - // T1 | /---- - // | /---- - // | /---- + // | / + // | /---- + // T1 | /---- + // | /---- + // | /---- // ----------------------------------------$-------------------$------------------------------------------ - // . | \ - // . | \ - // T2 . | \ - // . | \ - // . | \ + // . | \ + // . | \ + // T2 . | \ + // . | \ + // . | \ // ----------------------------------------------------------------------*-------------------------------- // // (Note the dots represent the newly inferrred start. @@ -6716,22 +6954,22 @@ var ts; // // 0 10 20 30 40 50 60 70 80 90 100 // --------------------------------------------------------------------------------*---------------------- - // | / - // | /---- - // T1 | /---- - // | /---- - // | /---- + // | / + // | /---- + // T1 | /---- + // | /---- + // | /---- // ------------------------------------------------------------$------------------------------------------ - // . | \ - // . | \ - // T2 . | \ - // . | \ - // . | \ + // . | \ + // . | \ + // T2 . | \ + // . | \ + // . | \ // ----------------------------------------------------------------------*-------------------------------- // // In other words (in this case), we're recognizing that the second edit happened after where the first edit // ended with a delta of 20 characters (60 - 40). Thus, if we go back in time to where the first edit started - // that's the same as if we started at char 80 instead of 60. + // that's the same as if we started at char 80 instead of 60. // // As it so happens, the same logic applies if the second edit precedes the first edit. In that case rahter // than pusing the first edit forward to match the second, we'll push the second edit forward to match the @@ -6741,7 +6979,7 @@ var ts; // semantics: { { start: 10, length: 70 }, newLength: 60 } // // The math then works out as follows. - // If we have { oldStart1, oldEnd1, newEnd1 } and { oldStart2, oldEnd2, newEnd2 } then we can compute the + // If we have { oldStart1, oldEnd1, newEnd1 } and { oldStart2, oldEnd2, newEnd2 } then we can compute the // final result like so: // // { @@ -6763,9 +7001,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 130 /* TypeParameter */) { + if (d && d.kind === 134 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 205 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 212 /* InterfaceDeclaration */) { return current; } } @@ -6777,7 +7015,7 @@ var ts; /// var ts; (function (ts) { - var nodeConstructors = new Array(254 /* Count */); + var nodeConstructors = new Array(269 /* Count */); /* @internal */ ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -6822,20 +7060,20 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 128 /* QualifiedName */: + case 132 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 130 /* TypeParameter */: + case 134 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 131 /* Parameter */: - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: - case 227 /* PropertyAssignment */: - case 228 /* ShorthandPropertyAssignment */: - case 201 /* VariableDeclaration */: - case 155 /* BindingElement */: + case 135 /* Parameter */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: + case 242 /* PropertyAssignment */: + case 243 /* ShorthandPropertyAssignment */: + case 208 /* VariableDeclaration */: + case 160 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -6844,24 +7082,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 145 /* FunctionType */: - case 146 /* ConstructorType */: - case 140 /* CallSignature */: - case 141 /* ConstructSignature */: - case 142 /* IndexSignature */: + case 149 /* FunctionType */: + case 150 /* ConstructorType */: + case 144 /* CallSignature */: + case 145 /* ConstructSignature */: + case 146 /* IndexSignature */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 137 /* Constructor */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 165 /* FunctionExpression */: - case 203 /* FunctionDeclaration */: - case 166 /* ArrowFunction */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 141 /* Constructor */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 170 /* FunctionExpression */: + case 210 /* FunctionDeclaration */: + case 171 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -6872,267 +7110,290 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 144 /* TypeReference */: + case 148 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 143 /* TypePredicate */: + case 147 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 147 /* TypeQuery */: + case 151 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 148 /* TypeLiteral */: + case 152 /* TypeLiteral */: return visitNodes(cbNodes, node.members); - case 149 /* ArrayType */: + case 153 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 150 /* TupleType */: + case 154 /* TupleType */: return visitNodes(cbNodes, node.elementTypes); - case 151 /* UnionType */: + case 155 /* UnionType */: + case 156 /* IntersectionType */: return visitNodes(cbNodes, node.types); - case 152 /* ParenthesizedType */: + case 157 /* ParenthesizedType */: return visitNode(cbNode, node.type); - case 153 /* ObjectBindingPattern */: - case 154 /* ArrayBindingPattern */: + case 158 /* ObjectBindingPattern */: + case 159 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 156 /* ArrayLiteralExpression */: + case 161 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 157 /* ObjectLiteralExpression */: + case 162 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 158 /* PropertyAccessExpression */: + case 163 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 159 /* ElementAccessExpression */: + case 164 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 160 /* CallExpression */: - case 161 /* NewExpression */: + case 165 /* CallExpression */: + case 166 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 162 /* TaggedTemplateExpression */: + case 167 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 163 /* TypeAssertionExpression */: + case 168 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 164 /* ParenthesizedExpression */: + case 169 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 167 /* DeleteExpression */: + case 172 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 168 /* TypeOfExpression */: + case 173 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 169 /* VoidExpression */: + case 174 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 170 /* PrefixUnaryExpression */: + case 176 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 175 /* YieldExpression */: + case 181 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 171 /* PostfixUnaryExpression */: + case 175 /* AwaitExpression */: + return visitNode(cbNode, node.expression); + case 177 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 172 /* BinaryExpression */: + case 178 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 173 /* ConditionalExpression */: + case 186 /* AsExpression */: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.type); + case 179 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 176 /* SpreadElementExpression */: + case 182 /* SpreadElementExpression */: return visitNode(cbNode, node.expression); - case 182 /* Block */: - case 209 /* ModuleBlock */: + case 189 /* Block */: + case 216 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 230 /* SourceFile */: + case 245 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 183 /* VariableStatement */: + case 190 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 202 /* VariableDeclarationList */: + case 209 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 185 /* ExpressionStatement */: + case 192 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 186 /* IfStatement */: + case 193 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 187 /* DoStatement */: + case 194 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 188 /* WhileStatement */: + case 195 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 189 /* ForStatement */: + case 196 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 190 /* ForInStatement */: + case 197 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 191 /* ForOfStatement */: + case 198 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 192 /* ContinueStatement */: - case 193 /* BreakStatement */: + case 199 /* ContinueStatement */: + case 200 /* BreakStatement */: return visitNode(cbNode, node.label); - case 194 /* ReturnStatement */: + case 201 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 195 /* WithStatement */: + case 202 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 196 /* SwitchStatement */: + case 203 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 210 /* CaseBlock */: + case 217 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 223 /* CaseClause */: + case 238 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 224 /* DefaultClause */: + case 239 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 197 /* LabeledStatement */: + case 204 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 198 /* ThrowStatement */: + case 205 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 199 /* TryStatement */: + case 206 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 226 /* CatchClause */: + case 241 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 132 /* Decorator */: + case 136 /* Decorator */: return visitNode(cbNode, node.expression); - case 204 /* ClassDeclaration */: - case 177 /* ClassExpression */: + case 211 /* ClassDeclaration */: + case 183 /* ClassExpression */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 205 /* InterfaceDeclaration */: + case 212 /* InterfaceDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 206 /* TypeAliasDeclaration */: + case 213 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 207 /* EnumDeclaration */: + case 214 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 229 /* EnumMember */: + case 244 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 211 /* ImportEqualsDeclaration */: + case 218 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 212 /* ImportDeclaration */: + case 219 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 213 /* ImportClause */: + case 220 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 214 /* NamespaceImport */: + case 221 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 215 /* NamedImports */: - case 219 /* NamedExports */: + case 222 /* NamedImports */: + case 226 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 218 /* ExportDeclaration */: + case 225 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 216 /* ImportSpecifier */: - case 220 /* ExportSpecifier */: + case 223 /* ImportSpecifier */: + case 227 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 217 /* ExportAssignment */: + case 224 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 174 /* TemplateExpression */: + case 180 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 180 /* TemplateSpan */: + case 187 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 129 /* ComputedPropertyName */: + case 133 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 225 /* HeritageClause */: + case 240 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 179 /* ExpressionWithTypeArguments */: + case 185 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 222 /* ExternalModuleReference */: + case 229 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 221 /* MissingDeclaration */: + case 228 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 231 /* JSDocTypeExpression */: + case 230 /* JsxElement */: + return visitNode(cbNode, node.openingElement) || + visitNodes(cbNodes, node.children) || + visitNode(cbNode, node.closingElement); + case 231 /* JsxSelfClosingElement */: + case 232 /* JsxOpeningElement */: + return visitNode(cbNode, node.tagName) || + visitNodes(cbNodes, node.attributes); + case 235 /* JsxAttribute */: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 236 /* JsxSpreadAttribute */: + return visitNode(cbNode, node.expression); + case 237 /* JsxExpression */: + return visitNode(cbNode, node.expression); + case 234 /* JsxClosingElement */: + return visitNode(cbNode, node.tagName); + case 246 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 235 /* JSDocUnionType */: + case 250 /* JSDocUnionType */: return visitNodes(cbNodes, node.types); - case 236 /* JSDocTupleType */: + case 251 /* JSDocTupleType */: return visitNodes(cbNodes, node.types); - case 234 /* JSDocArrayType */: + case 249 /* JSDocArrayType */: return visitNode(cbNode, node.elementType); - case 238 /* JSDocNonNullableType */: + case 253 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 237 /* JSDocNullableType */: + case 252 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 239 /* JSDocRecordType */: + case 254 /* JSDocRecordType */: return visitNodes(cbNodes, node.members); - case 241 /* JSDocTypeReference */: + case 256 /* JSDocTypeReference */: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 242 /* JSDocOptionalType */: + case 257 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 243 /* JSDocFunctionType */: + case 258 /* JSDocFunctionType */: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 244 /* JSDocVariadicType */: + case 259 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 245 /* JSDocConstructorType */: + case 260 /* JSDocConstructorType */: return visitNode(cbNode, node.type); - case 246 /* JSDocThisType */: + case 261 /* JSDocThisType */: return visitNode(cbNode, node.type); - case 240 /* JSDocRecordMember */: + case 255 /* JSDocRecordMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 247 /* JSDocComment */: + case 262 /* JSDocComment */: return visitNodes(cbNodes, node.tags); - case 249 /* JSDocParameterTag */: + case 264 /* JSDocParameterTag */: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 250 /* JSDocReturnTag */: + case 265 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 251 /* JSDocTypeTag */: + case 266 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 252 /* JSDocTemplateTag */: + case 267 /* JSDocTemplateTag */: return visitNodes(cbNodes, node.typeParameters); } } @@ -7177,7 +7438,7 @@ var ts; // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. var scanner = ts.createScanner(2 /* Latest */, true); - var disallowInAndDecoratorContext = 2 /* DisallowIn */ | 16 /* Decorator */; + var disallowInAndDecoratorContext = 1 /* DisallowIn */ | 4 /* Decorator */; var sourceFile; var parseDiagnostics; var syntaxCursor; @@ -7277,12 +7538,13 @@ var ts; identifiers = {}; identifierCount = 0; nodeCount = 0; - contextFlags = ts.isJavaScript(fileName) ? 64 /* JavaScriptFile */ : 0 /* None */; + contextFlags = ts.isJavaScript(fileName) ? 32 /* JavaScriptFile */ : 0 /* None */; parseErrorBeforeNextFinishedNode = false; // Initialize and prime the scanner before parsing the source elements. scanner.setText(sourceText); scanner.setOnError(scanError); scanner.setScriptTarget(languageVersion); + scanner.setLanguageVariant(ts.isTsx(fileName) ? 1 /* JSX */ : 0 /* Standard */); } function clearState() { // Clear out the text the scanner is pointing at, so it doesn't keep anything alive unnecessarily. @@ -7311,7 +7573,7 @@ var ts; if (setParentNodes) { fixupParentReferences(sourceFile); } - // If this is a javascript file, proactively see if we can get JSDoc comments for + // If this is a javascript file, proactively see if we can get JSDoc comments for // relevant nodes in the file. We'll use these to provide typing informaion if they're // available. if (ts.isJavaScript(fileName)) { @@ -7326,9 +7588,9 @@ var ts; // Add additional cases as necessary depending on how we see JSDoc comments used // in the wild. switch (node.kind) { - case 183 /* VariableStatement */: - case 203 /* FunctionDeclaration */: - case 131 /* Parameter */: + case 190 /* VariableStatement */: + case 210 /* FunctionDeclaration */: + case 135 /* Parameter */: addJSDocComment(node); } forEachChild(node, visit); @@ -7369,14 +7631,15 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(230 /* SourceFile */, 0); + var sourceFile = createNode(245 /* SourceFile */, 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; sourceFile.languageVersion = languageVersion; sourceFile.fileName = ts.normalizePath(fileName); - sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 2048 /* DeclarationFile */ : 0; + sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 8192 /* DeclarationFile */ : 0; + sourceFile.languageVariant = ts.isTsx(sourceFile.fileName) ? 1 /* JSX */ : 0 /* Standard */; return sourceFile; } function setContextFlag(val, flag) { @@ -7388,89 +7651,96 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 2 /* DisallowIn */); + setContextFlag(val, 1 /* DisallowIn */); } function setYieldContext(val) { - setContextFlag(val, 4 /* Yield */); - } - function setGeneratorParameterContext(val) { - setContextFlag(val, 8 /* GeneratorParameter */); + setContextFlag(val, 2 /* Yield */); } function setDecoratorContext(val) { - setContextFlag(val, 16 /* Decorator */); + setContextFlag(val, 4 /* Decorator */); } - function doOutsideOfContext(flags, func) { - var currentContextFlags = contextFlags & flags; - if (currentContextFlags) { - setContextFlag(false, currentContextFlags); + function setAwaitContext(val) { + setContextFlag(val, 8 /* Await */); + } + function doOutsideOfContext(context, func) { + // contextFlagsToClear will contain only the context flags that are + // currently set that we need to temporarily clear + // We don't just blindly reset to the previous flags to ensure + // that we do not mutate cached flags for the incremental + // parser (ThisNodeHasError, ThisNodeOrAnySubNodesHasError, and + // HasAggregatedChildData). + var contextFlagsToClear = context & contextFlags; + if (contextFlagsToClear) { + // clear the requested context flags + setContextFlag(false, contextFlagsToClear); var result = func(); - setContextFlag(true, currentContextFlags); + // restore the context flags we just cleared + setContextFlag(true, contextFlagsToClear); return result; } // no need to do anything special as we are not in any of the requested contexts return func(); } - function allowInAnd(func) { - if (contextFlags & 2 /* DisallowIn */) { - setDisallowInContext(false); + function doInsideOfContext(context, func) { + // contextFlagsToSet will contain only the context flags that + // are not currently set that we need to temporarily enable. + // We don't just blindly reset to the previous flags to ensure + // that we do not mutate cached flags for the incremental + // parser (ThisNodeHasError, ThisNodeOrAnySubNodesHasError, and + // HasAggregatedChildData). + var contextFlagsToSet = context & ~contextFlags; + if (contextFlagsToSet) { + // set the requested context flags + setContextFlag(true, contextFlagsToSet); var result = func(); - setDisallowInContext(true); + // reset the context flags we just set + setContextFlag(false, contextFlagsToSet); return result; } - // no need to do anything special if 'in' is already allowed. + // no need to do anything special as we are already in all of the requested contexts return func(); } + function allowInAnd(func) { + return doOutsideOfContext(1 /* DisallowIn */, func); + } function disallowInAnd(func) { - if (contextFlags & 2 /* DisallowIn */) { - // no need to do anything special if 'in' is already disallowed. - return func(); - } - setDisallowInContext(true); - var result = func(); - setDisallowInContext(false); - return result; + return doInsideOfContext(1 /* DisallowIn */, func); } function doInYieldContext(func) { - if (contextFlags & 4 /* Yield */) { - // no need to do anything special if we're already in the [Yield] context. - return func(); - } - setYieldContext(true); - var result = func(); - setYieldContext(false); - return result; + return doInsideOfContext(2 /* Yield */, func); } function doOutsideOfYieldContext(func) { - if (contextFlags & 4 /* Yield */) { - setYieldContext(false); - var result = func(); - setYieldContext(true); - return result; - } - // no need to do anything special if we're not in the [Yield] context. - return func(); + return doOutsideOfContext(2 /* Yield */, func); } function doInDecoratorContext(func) { - if (contextFlags & 16 /* Decorator */) { - // no need to do anything special if we're already in the [Decorator] context. - return func(); - } - setDecoratorContext(true); - var result = func(); - setDecoratorContext(false); - return result; + return doInsideOfContext(4 /* Decorator */, func); + } + function doInAwaitContext(func) { + return doInsideOfContext(8 /* Await */, func); + } + function doOutsideOfAwaitContext(func) { + return doOutsideOfContext(8 /* Await */, func); + } + function doInYieldAndAwaitContext(func) { + return doInsideOfContext(2 /* Yield */ | 8 /* Await */, func); + } + function doOutsideOfYieldAndAwaitContext(func) { + return doOutsideOfContext(2 /* Yield */ | 8 /* Await */, func); + } + function inContext(flags) { + return (contextFlags & flags) !== 0; } function inYieldContext() { - return (contextFlags & 4 /* Yield */) !== 0; - } - function inGeneratorParameterContext() { - return (contextFlags & 8 /* GeneratorParameter */) !== 0; + return inContext(2 /* Yield */); } function inDisallowInContext() { - return (contextFlags & 2 /* DisallowIn */) !== 0; + return inContext(1 /* DisallowIn */); } function inDecoratorContext() { - return (contextFlags & 16 /* Decorator */) !== 0; + return inContext(4 /* Decorator */); + } + function inAwaitContext() { + return inContext(8 /* Await */); } function parseErrorAtCurrentToken(message, arg0) { var start = scanner.getTokenPos(); @@ -7512,6 +7782,9 @@ var ts; function reScanTemplateToken() { return token = scanner.reScanTemplateToken(); } + function scanJsxIdentifier() { + return token = scanner.scanJsxIdentifier(); + } function speculationHelper(callback, isLookAhead) { // Keep track of the state we'll need to rollback to if lookahead fails (or if the // caller asked us to always reset our state). @@ -7554,15 +7827,20 @@ var ts; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token === 65 /* Identifier */) { + if (token === 66 /* Identifier */) { return true; } // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is // considered a keyword and is not an identifier. - if (token === 110 /* YieldKeyword */ && inYieldContext()) { + if (token === 111 /* YieldKeyword */ && inYieldContext()) { return false; } - return token > 101 /* LastReservedWord */; + // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is + // considered a keyword and is not an identifier. + if (token === 116 /* AwaitKeyword */ && inAwaitContext()) { + return false; + } + return token > 102 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage) { if (token === kind) { @@ -7640,7 +7918,7 @@ var ts; // flag so that we don't mark any subsequent nodes. if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.parserContextFlags |= 32 /* ThisNodeHasError */; + node.parserContextFlags |= 16 /* ThisNodeHasError */; } return node; } @@ -7665,16 +7943,16 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(65 /* Identifier */); + var node = createNode(66 /* Identifier */); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token !== 65 /* Identifier */) { + if (token !== 66 /* Identifier */) { node.originalKeywordKind = token; } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(65 /* Identifier */, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(66 /* Identifier */, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -7706,27 +7984,15 @@ var ts; return token === 8 /* StringLiteral */ || token === 7 /* NumericLiteral */ || isIdentifierOrKeyword(); } function parseComputedPropertyName() { - // PropertyName[Yield,GeneratorParameter] : - // LiteralPropertyName - // [+GeneratorParameter] ComputedPropertyName - // [~GeneratorParameter] ComputedPropertyName[?Yield] - // - // ComputedPropertyName[Yield] : - // [ AssignmentExpression[In, ?Yield] ] - // - var node = createNode(129 /* ComputedPropertyName */); + // PropertyName [Yield]: + // LiteralPropertyName + // ComputedPropertyName[?Yield] + var node = createNode(133 /* ComputedPropertyName */); parseExpected(18 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker // will error if it sees a comma expression. - var yieldContext = inYieldContext(); - if (inGeneratorParameterContext()) { - setYieldContext(false); - } node.expression = allowInAnd(parseExpression); - if (inGeneratorParameterContext()) { - setYieldContext(yieldContext); - } parseExpected(19 /* CloseBracketToken */); return finishNode(node); } @@ -7734,18 +8000,18 @@ var ts; return token === t && tryParse(nextTokenCanFollowModifier); } function nextTokenCanFollowModifier() { - if (token === 70 /* ConstKeyword */) { + if (token === 71 /* ConstKeyword */) { // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 77 /* EnumKeyword */; + return nextToken() === 78 /* EnumKeyword */; } - if (token === 78 /* ExportKeyword */) { + if (token === 79 /* ExportKeyword */) { nextToken(); - if (token === 73 /* DefaultKeyword */) { + if (token === 74 /* DefaultKeyword */) { return lookAhead(nextTokenIsClassOrFunction); } - return token !== 35 /* AsteriskToken */ && token !== 14 /* OpenBraceToken */ && canFollowModifier(); + return token !== 36 /* AsteriskToken */ && token !== 14 /* OpenBraceToken */ && canFollowModifier(); } - if (token === 73 /* DefaultKeyword */) { + if (token === 74 /* DefaultKeyword */) { return nextTokenIsClassOrFunction(); } nextToken(); @@ -7757,12 +8023,12 @@ var ts; function canFollowModifier() { return token === 18 /* OpenBracketToken */ || token === 14 /* OpenBraceToken */ - || token === 35 /* AsteriskToken */ + || token === 36 /* AsteriskToken */ || isLiteralPropertyName(); } function nextTokenIsClassOrFunction() { nextToken(); - return token === 69 /* ClassKeyword */ || token === 83 /* FunctionKeyword */; + return token === 70 /* ClassKeyword */ || token === 84 /* FunctionKeyword */; } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -7782,7 +8048,7 @@ var ts; // outer module. We just want to consume and move on. return !(token === 22 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token === 67 /* CaseKeyword */ || token === 73 /* DefaultKeyword */; + return token === 68 /* CaseKeyword */ || token === 74 /* DefaultKeyword */; case 4 /* TypeMembers */: return isStartOfTypeMember(); case 5 /* ClassMembers */: @@ -7796,7 +8062,7 @@ var ts; // which would be a candidate for improved error reporting. return token === 18 /* OpenBracketToken */ || isLiteralPropertyName(); case 12 /* ObjectLiteralMembers */: - return token === 18 /* OpenBracketToken */ || token === 35 /* AsteriskToken */ || isLiteralPropertyName(); + return token === 18 /* OpenBracketToken */ || token === 36 /* AsteriskToken */ || isLiteralPropertyName(); case 9 /* ObjectBindingElements */: return isLiteralPropertyName(); case 7 /* HeritageClauseElement */: @@ -7818,25 +8084,29 @@ var ts; return isIdentifierOrPattern(); case 10 /* ArrayBindingElements */: return token === 23 /* CommaToken */ || token === 21 /* DotDotDotToken */ || isIdentifierOrPattern(); - case 15 /* TypeParameters */: + case 17 /* TypeParameters */: return isIdentifier(); case 11 /* ArgumentExpressions */: - case 13 /* ArrayLiteralMembers */: + case 15 /* ArrayLiteralMembers */: return token === 23 /* CommaToken */ || token === 21 /* DotDotDotToken */ || isStartOfExpression(); - case 14 /* Parameters */: + case 16 /* Parameters */: return isStartOfParameter(); - case 16 /* TypeArguments */: - case 17 /* TupleElementTypes */: + case 18 /* TypeArguments */: + case 19 /* TupleElementTypes */: return token === 23 /* CommaToken */ || isStartOfType(); - case 18 /* HeritageClauses */: + case 20 /* HeritageClauses */: return isHeritageClause(); - case 19 /* ImportOrExportSpecifiers */: + case 21 /* ImportOrExportSpecifiers */: return isIdentifierOrKeyword(); - case 20 /* JSDocFunctionParameters */: - case 21 /* JSDocTypeArguments */: - case 23 /* JSDocTupleTypes */: + case 13 /* JsxAttributes */: + return isIdentifierOrKeyword() || token === 14 /* OpenBraceToken */; + case 14 /* JsxChildren */: + return true; + case 22 /* JSDocFunctionParameters */: + case 23 /* JSDocTypeArguments */: + case 25 /* JSDocTupleTypes */: return JSDocParser.isJSDocType(); - case 22 /* JSDocRecordMembers */: + case 24 /* JSDocRecordMembers */: return isSimplePropertyName(); } ts.Debug.fail("Non-exhaustive case in 'isListElement'."); @@ -7847,12 +8117,12 @@ var ts; // if we see "extends {}" then only treat the {} as what we're extending (and not // the class body) if we have: // - // extends {} { + // extends {} { // extends {}, // extends {} extends // extends {} implements var next = nextToken(); - return next === 23 /* CommaToken */ || next === 14 /* OpenBraceToken */ || next === 79 /* ExtendsKeyword */ || next === 102 /* ImplementsKeyword */; + return next === 23 /* CommaToken */ || next === 14 /* OpenBraceToken */ || next === 80 /* ExtendsKeyword */ || next === 103 /* ImplementsKeyword */; } return true; } @@ -7860,9 +8130,13 @@ var ts; nextToken(); return isIdentifier(); } + function nextTokenIsIdentifierOrKeyword() { + nextToken(); + return isIdentifierOrKeyword(); + } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token === 102 /* ImplementsKeyword */ || - token === 79 /* ExtendsKeyword */) { + if (token === 103 /* ImplementsKeyword */ || + token === 80 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -7885,39 +8159,43 @@ var ts; case 6 /* EnumMembers */: case 12 /* ObjectLiteralMembers */: case 9 /* ObjectBindingElements */: - case 19 /* ImportOrExportSpecifiers */: + case 21 /* ImportOrExportSpecifiers */: return token === 15 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token === 15 /* CloseBraceToken */ || token === 67 /* CaseKeyword */ || token === 73 /* DefaultKeyword */; + return token === 15 /* CloseBraceToken */ || token === 68 /* CaseKeyword */ || token === 74 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token === 14 /* OpenBraceToken */ || token === 79 /* ExtendsKeyword */ || token === 102 /* ImplementsKeyword */; + return token === 14 /* OpenBraceToken */ || token === 80 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); - case 15 /* TypeParameters */: + case 17 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token === 25 /* GreaterThanToken */ || token === 16 /* OpenParenToken */ || token === 14 /* OpenBraceToken */ || token === 79 /* ExtendsKeyword */ || token === 102 /* ImplementsKeyword */; + return token === 26 /* GreaterThanToken */ || token === 16 /* OpenParenToken */ || token === 14 /* OpenBraceToken */ || token === 80 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery return token === 17 /* CloseParenToken */ || token === 22 /* SemicolonToken */; - case 13 /* ArrayLiteralMembers */: - case 17 /* TupleElementTypes */: + case 15 /* ArrayLiteralMembers */: + case 19 /* TupleElementTypes */: case 10 /* ArrayBindingElements */: return token === 19 /* CloseBracketToken */; - case 14 /* Parameters */: + case 16 /* Parameters */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery return token === 17 /* CloseParenToken */ || token === 19 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; - case 16 /* TypeArguments */: + case 18 /* TypeArguments */: // Tokens other than '>' are here for better error recovery - return token === 25 /* GreaterThanToken */ || token === 16 /* OpenParenToken */; - case 18 /* HeritageClauses */: + return token === 26 /* GreaterThanToken */ || token === 16 /* OpenParenToken */; + case 20 /* HeritageClauses */: return token === 14 /* OpenBraceToken */ || token === 15 /* CloseBraceToken */; - case 20 /* JSDocFunctionParameters */: - return token === 17 /* CloseParenToken */ || token === 51 /* ColonToken */ || token === 15 /* CloseBraceToken */; - case 21 /* JSDocTypeArguments */: - return token === 25 /* GreaterThanToken */ || token === 15 /* CloseBraceToken */; - case 23 /* JSDocTupleTypes */: + case 13 /* JsxAttributes */: + return token === 26 /* GreaterThanToken */ || token === 37 /* SlashToken */; + case 14 /* JsxChildren */: + return token === 24 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + case 22 /* JSDocFunctionParameters */: + return token === 17 /* CloseParenToken */ || token === 52 /* ColonToken */ || token === 15 /* CloseBraceToken */; + case 23 /* JSDocTypeArguments */: + return token === 26 /* GreaterThanToken */ || token === 15 /* CloseBraceToken */; + case 25 /* JSDocTupleTypes */: return token === 19 /* CloseBracketToken */ || token === 15 /* CloseBraceToken */; - case 22 /* JSDocRecordMembers */: + case 24 /* JSDocRecordMembers */: return token === 15 /* CloseBraceToken */; } } @@ -7936,7 +8214,7 @@ var ts; // For better error recovery, if we see an '=>' then we just stop immediately. We've got an // arrow function here and it's going to be very unlikely that we'll resynchronize and get // another variable declaration. - if (token === 32 /* EqualsGreaterThanToken */) { + if (token === 33 /* EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -7944,7 +8222,7 @@ var ts; } // True if positioned at element or terminator of the current list or any enclosing list function isInSomeParsingContext() { - for (var kind = 0; kind < 24 /* Count */; kind++) { + for (var kind = 0; kind < 26 /* Count */; kind++) { if (parsingContext & (1 << kind)) { if (isListElement(kind, true) || isListTerminator(kind)) { return true; @@ -8020,7 +8298,7 @@ var ts; // differently depending on what mode it is in. // // This also applies to all our other context flags as well. - var nodeContextFlags = node.parserContextFlags & 62 /* ParserGeneratedFlags */; + var nodeContextFlags = node.parserContextFlags & 31 /* ParserGeneratedFlags */; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -8053,22 +8331,22 @@ var ts; return isReusableTypeMember(node); case 8 /* VariableDeclarations */: return isReusableVariableDeclaration(node); - case 14 /* Parameters */: + case 16 /* Parameters */: return isReusableParameter(node); // Any other lists we do not care about reusing nodes in. But feel free to add if // you can do so safely. Danger areas involve nodes that may involve speculative // parsing. If speculative parsing is involved with the node, then the range the // parser reached while looking ahead might be in the edited range (see the example // in canReuseVariableDeclaratorNode for a good case of this). - case 18 /* HeritageClauses */: + case 20 /* HeritageClauses */: // This would probably be safe to reuse. There is no speculative parsing with // heritage clauses. - case 15 /* TypeParameters */: + case 17 /* TypeParameters */: // This would probably be safe to reuse. There is no speculative parsing with // type parameters. Note that that's because type *parameters* only occur in // unambiguous *type* contexts. While type *arguments* occur in very ambiguous // *expression* contexts. - case 17 /* TupleElementTypes */: + case 19 /* TupleElementTypes */: // This would probably be safe to reuse. There is no speculative parsing with // tuple types. // Technically, type argument list types are probably safe to reuse. While @@ -8076,7 +8354,7 @@ var ts; // produced from speculative parsing a < as a type argument list), we only have // the types because speculative parsing succeeded. Thus, the lookahead never // went past the end of the list and rewound. - case 16 /* TypeArguments */: + case 18 /* TypeArguments */: // Note: these are almost certainly not safe to ever reuse. Expressions commonly // need a large amount of lookahead, and we should not reuse them as they may // have actually intersected the edit. @@ -8090,26 +8368,30 @@ var ts; // name list, and there can be left hand side expressions (which can have type // arguments.) case 7 /* HeritageClauseElement */: + // Perhaps safe to reuse, but it's unlikely we'd see more than a dozen attributes + // on any given element. Same for children. + case 13 /* JsxAttributes */: + case 14 /* JsxChildren */: } return false; } function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 137 /* Constructor */: - case 142 /* IndexSignature */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 134 /* PropertyDeclaration */: - case 181 /* SemicolonClassElement */: + case 141 /* Constructor */: + case 146 /* IndexSignature */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 138 /* PropertyDeclaration */: + case 188 /* SemicolonClassElement */: return true; - case 136 /* MethodDeclaration */: + case 140 /* MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal // may have a method calls "constructor(...)" and we must reparse that // into an actual .ConstructorDeclaration. var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 65 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 114 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 66 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 118 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -8118,8 +8400,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 223 /* CaseClause */: - case 224 /* DefaultClause */: + case 238 /* CaseClause */: + case 239 /* DefaultClause */: return true; } } @@ -8128,58 +8410,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 203 /* FunctionDeclaration */: - case 183 /* VariableStatement */: - case 182 /* Block */: - case 186 /* IfStatement */: - case 185 /* ExpressionStatement */: - case 198 /* ThrowStatement */: - case 194 /* ReturnStatement */: - case 196 /* SwitchStatement */: - case 193 /* BreakStatement */: - case 192 /* ContinueStatement */: - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: - case 189 /* ForStatement */: - case 188 /* WhileStatement */: - case 195 /* WithStatement */: - case 184 /* EmptyStatement */: - case 199 /* TryStatement */: - case 197 /* LabeledStatement */: - case 187 /* DoStatement */: - case 200 /* DebuggerStatement */: - case 212 /* ImportDeclaration */: - case 211 /* ImportEqualsDeclaration */: - case 218 /* ExportDeclaration */: - case 217 /* ExportAssignment */: - case 208 /* ModuleDeclaration */: - case 204 /* ClassDeclaration */: - case 205 /* InterfaceDeclaration */: - case 207 /* EnumDeclaration */: - case 206 /* TypeAliasDeclaration */: + case 210 /* FunctionDeclaration */: + case 190 /* VariableStatement */: + case 189 /* Block */: + case 193 /* IfStatement */: + case 192 /* ExpressionStatement */: + case 205 /* ThrowStatement */: + case 201 /* ReturnStatement */: + case 203 /* SwitchStatement */: + case 200 /* BreakStatement */: + case 199 /* ContinueStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: + case 196 /* ForStatement */: + case 195 /* WhileStatement */: + case 202 /* WithStatement */: + case 191 /* EmptyStatement */: + case 206 /* TryStatement */: + case 204 /* LabeledStatement */: + case 194 /* DoStatement */: + case 207 /* DebuggerStatement */: + case 219 /* ImportDeclaration */: + case 218 /* ImportEqualsDeclaration */: + case 225 /* ExportDeclaration */: + case 224 /* ExportAssignment */: + case 215 /* ModuleDeclaration */: + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: + case 214 /* EnumDeclaration */: + case 213 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 229 /* EnumMember */; + return node.kind === 244 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 141 /* ConstructSignature */: - case 135 /* MethodSignature */: - case 142 /* IndexSignature */: - case 133 /* PropertySignature */: - case 140 /* CallSignature */: + case 145 /* ConstructSignature */: + case 139 /* MethodSignature */: + case 146 /* IndexSignature */: + case 137 /* PropertySignature */: + case 144 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 201 /* VariableDeclaration */) { + if (node.kind !== 208 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -8200,7 +8482,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 131 /* Parameter */) { + if (node.kind !== 135 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -8231,17 +8513,19 @@ var ts; case 10 /* ArrayBindingElements */: return ts.Diagnostics.Array_element_destructuring_pattern_expected; case 11 /* ArgumentExpressions */: return ts.Diagnostics.Argument_expression_expected; case 12 /* ObjectLiteralMembers */: return ts.Diagnostics.Property_assignment_expected; - case 13 /* ArrayLiteralMembers */: return ts.Diagnostics.Expression_or_comma_expected; - case 14 /* Parameters */: return ts.Diagnostics.Parameter_declaration_expected; - case 15 /* TypeParameters */: return ts.Diagnostics.Type_parameter_declaration_expected; - case 16 /* TypeArguments */: return ts.Diagnostics.Type_argument_expected; - case 17 /* TupleElementTypes */: return ts.Diagnostics.Type_expected; - case 18 /* HeritageClauses */: return ts.Diagnostics.Unexpected_token_expected; - case 19 /* ImportOrExportSpecifiers */: return ts.Diagnostics.Identifier_expected; - case 20 /* JSDocFunctionParameters */: return ts.Diagnostics.Parameter_declaration_expected; - case 21 /* JSDocTypeArguments */: return ts.Diagnostics.Type_argument_expected; - case 23 /* JSDocTupleTypes */: return ts.Diagnostics.Type_expected; - case 22 /* JSDocRecordMembers */: return ts.Diagnostics.Property_assignment_expected; + case 15 /* ArrayLiteralMembers */: return ts.Diagnostics.Expression_or_comma_expected; + case 16 /* Parameters */: return ts.Diagnostics.Parameter_declaration_expected; + case 17 /* TypeParameters */: return ts.Diagnostics.Type_parameter_declaration_expected; + case 18 /* TypeArguments */: return ts.Diagnostics.Type_argument_expected; + case 19 /* TupleElementTypes */: return ts.Diagnostics.Type_expected; + case 20 /* HeritageClauses */: return ts.Diagnostics.Unexpected_token_expected; + case 21 /* ImportOrExportSpecifiers */: return ts.Diagnostics.Identifier_expected; + case 13 /* JsxAttributes */: return ts.Diagnostics.Identifier_expected; + case 14 /* JsxChildren */: return ts.Diagnostics.Identifier_expected; + case 22 /* JSDocFunctionParameters */: return ts.Diagnostics.Parameter_declaration_expected; + case 23 /* JSDocTypeArguments */: return ts.Diagnostics.Type_argument_expected; + case 25 /* JSDocTupleTypes */: return ts.Diagnostics.Type_expected; + case 24 /* JSDocRecordMembers */: return ts.Diagnostics.Property_assignment_expected; } } ; @@ -8315,7 +8599,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(20 /* DotToken */)) { - var node = createNode(128 /* QualifiedName */, entity.pos); + var node = createNode(132 /* QualifiedName */, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -8348,13 +8632,13 @@ var ts; // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(65 /* Identifier */, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(66 /* Identifier */, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(174 /* TemplateExpression */); + var template = createNode(180 /* TemplateExpression */); template.head = parseLiteralNode(); ts.Debug.assert(template.head.kind === 11 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = []; @@ -8367,7 +8651,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(180 /* TemplateSpan */); + var span = createNode(187 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token === 15 /* CloseBraceToken */) { @@ -8402,37 +8686,37 @@ var ts; if (node.kind === 7 /* NumericLiteral */ && sourceText.charCodeAt(tokenPos) === 48 /* _0 */ && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { - node.flags |= 16384 /* OctalLiteral */; + node.flags |= 65536 /* OctalLiteral */; } return node; } // TYPES function parseTypeReferenceOrTypePredicate() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - if (typeName.kind === 65 /* Identifier */ && token === 117 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (typeName.kind === 66 /* Identifier */ && token === 121 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var node_1 = createNode(143 /* TypePredicate */, typeName.pos); + var node_1 = createNode(147 /* TypePredicate */, typeName.pos); node_1.parameterName = typeName; node_1.type = parseType(); return finishNode(node_1); } - var node = createNode(144 /* TypeReference */, typeName.pos); + var node = createNode(148 /* TypeReference */, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token === 24 /* LessThanToken */) { - node.typeArguments = parseBracketedList(16 /* TypeArguments */, parseType, 24 /* LessThanToken */, 25 /* GreaterThanToken */); + node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 24 /* LessThanToken */, 26 /* GreaterThanToken */); } return finishNode(node); } function parseTypeQuery() { - var node = createNode(147 /* TypeQuery */); - parseExpected(97 /* TypeOfKeyword */); + var node = createNode(151 /* TypeQuery */); + parseExpected(98 /* TypeOfKeyword */); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(130 /* TypeParameter */); + var node = createNode(134 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(79 /* ExtendsKeyword */)) { + if (parseOptional(80 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the // user writes a constraint that is an expression and not an actual type, then parse // it out as an expression (so we can recover well), but report that a type is needed @@ -8455,11 +8739,11 @@ var ts; } function parseTypeParameters() { if (token === 24 /* LessThanToken */) { - return parseBracketedList(15 /* TypeParameters */, parseTypeParameter, 24 /* LessThanToken */, 25 /* GreaterThanToken */); + return parseBracketedList(17 /* TypeParameters */, parseTypeParameter, 24 /* LessThanToken */, 26 /* GreaterThanToken */); } } function parseParameterType() { - if (parseOptional(51 /* ColonToken */)) { + if (parseOptional(52 /* ColonToken */)) { return token === 8 /* StringLiteral */ ? parseLiteralNode(true) : parseType(); @@ -8467,7 +8751,7 @@ var ts; return undefined; } function isStartOfParameter() { - return token === 21 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifier(token) || token === 52 /* AtToken */; + return token === 21 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifier(token) || token === 53 /* AtToken */; } function setModifiers(node, modifiers) { if (modifiers) { @@ -8476,14 +8760,13 @@ var ts; } } function parseParameter() { - var node = createNode(131 /* Parameter */); + var node = createNode(135 /* Parameter */); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(21 /* DotDotDotToken */); - // SingleNameBinding[Yield,GeneratorParameter] : See 13.2.3 - // [+GeneratorParameter]BindingIdentifier[Yield]Initializer[In]opt - // [~GeneratorParameter]BindingIdentifier[?Yield]Initializer[In, ?Yield]opt - node.name = inGeneratorParameterContext() ? doInYieldContext(parseIdentifierOrPattern) : parseIdentifierOrPattern(); + // FormalParameter [Yield,Await]: + // BindingElement[?Yield,?Await] + node.name = parseIdentifierOrPattern(); if (ts.getFullWidth(node.name) === 0 && node.flags === 0 && ts.isModifier(token)) { // in cases like // 'use strict' @@ -8495,9 +8778,9 @@ var ts; // to avoid this we'll advance cursor to the next token. nextToken(); } - node.questionToken = parseOptionalToken(50 /* QuestionToken */); + node.questionToken = parseOptionalToken(51 /* QuestionToken */); node.type = parseParameterType(); - node.initializer = inGeneratorParameterContext() ? doOutsideOfYieldContext(parseParameterInitializer) : parseParameterInitializer(); + node.initializer = parseBindingElementInitializer(true); // Do not check for initializers in an ambient context for parameters. This is not // a grammar error because the grammar allows arbitrary call signatures in // an ambient context. @@ -8508,13 +8791,16 @@ var ts; // ambient contexts. return finishNode(node); } + function parseBindingElementInitializer(inParameter) { + return inParameter ? parseParameterInitializer() : parseNonParameterInitializer(); + } function parseParameterInitializer() { return parseInitializer(true); } - function fillSignature(returnToken, yieldAndGeneratorParameterContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 32 /* EqualsGreaterThanToken */; + function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { + var returnTokenRequired = returnToken === 33 /* EqualsGreaterThanToken */; signature.typeParameters = parseTypeParameters(); - signature.parameters = parseParameterList(yieldAndGeneratorParameterContext, requireCompleteParameterList); + signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { parseExpected(returnToken); signature.type = parseType(); @@ -8523,33 +8809,28 @@ var ts; signature.type = parseType(); } } - // Note: after careful analysis of the grammar, it does not appear to be possible to - // have 'Yield' And 'GeneratorParameter' not in sync. i.e. any production calling - // this FormalParameters production either always sets both to true, or always sets - // both to false. As such we only have a single parameter to represent both. - function parseParameterList(yieldAndGeneratorParameterContext, requireCompleteParameterList) { - // FormalParameters[Yield,GeneratorParameter] : - // ... + function parseParameterList(yieldContext, awaitContext, requireCompleteParameterList) { + // FormalParameters [Yield,Await]: (modified) + // [empty] + // FormalParameterList[?Yield,Await] // - // FormalParameter[Yield,GeneratorParameter] : - // BindingElement[?Yield, ?GeneratorParameter] + // FormalParameter[Yield,Await]: (modified) + // BindingElement[?Yield,Await] // - // BindingElement[Yield, GeneratorParameter ] : See 13.2.3 - // SingleNameBinding[?Yield, ?GeneratorParameter] - // [+GeneratorParameter]BindingPattern[?Yield, GeneratorParameter]Initializer[In]opt - // [~GeneratorParameter]BindingPattern[?Yield]Initializer[In, ?Yield]opt + // BindingElement [Yield,Await]: (modified) + // SingleNameBinding[?Yield,?Await] + // BindingPattern[?Yield,?Await]Initializer [In, ?Yield,?Await] opt // - // SingleNameBinding[Yield, GeneratorParameter] : See 13.2.3 - // [+GeneratorParameter]BindingIdentifier[Yield]Initializer[In]opt - // [~GeneratorParameter]BindingIdentifier[?Yield]Initializer[In, ?Yield]opt + // SingleNameBinding [Yield,Await]: + // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt if (parseExpected(16 /* OpenParenToken */)) { var savedYieldContext = inYieldContext(); - var savedGeneratorParameterContext = inGeneratorParameterContext(); - setYieldContext(yieldAndGeneratorParameterContext); - setGeneratorParameterContext(yieldAndGeneratorParameterContext); - var result = parseDelimitedList(14 /* Parameters */, parseParameter); + var savedAwaitContext = inAwaitContext(); + setYieldContext(yieldContext); + setAwaitContext(awaitContext); + var result = parseDelimitedList(16 /* Parameters */, parseParameter); setYieldContext(savedYieldContext); - setGeneratorParameterContext(savedGeneratorParameterContext); + setAwaitContext(savedAwaitContext); if (!parseExpected(17 /* CloseParenToken */) && requireCompleteParameterList) { // Caller insisted that we had to end with a ) We didn't. So just return // undefined here. @@ -8573,10 +8854,10 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 141 /* ConstructSignature */) { - parseExpected(88 /* NewKeyword */); + if (kind === 145 /* ConstructSignature */) { + parseExpected(89 /* NewKeyword */); } - fillSignature(51 /* ColonToken */, false, false, node); + fillSignature(52 /* ColonToken */, false, false, false, node); parseTypeMemberSemicolon(); return finishNode(node); } @@ -8623,24 +8904,24 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token === 51 /* ColonToken */ || token === 23 /* CommaToken */) { + if (token === 52 /* ColonToken */ || token === 23 /* CommaToken */) { return true; } // Question mark could be an indexer with an optional property, // or it could be a conditional expression in a computed property. - if (token !== 50 /* QuestionToken */) { + if (token !== 51 /* QuestionToken */) { return false; } // If any of the following tokens are after the question mark, it cannot // be a conditional expression, so treat it as an indexer. nextToken(); - return token === 51 /* ColonToken */ || token === 23 /* CommaToken */ || token === 19 /* CloseBracketToken */; + return token === 52 /* ColonToken */ || token === 23 /* CommaToken */ || token === 19 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(142 /* IndexSignature */, fullStart); + var node = createNode(146 /* IndexSignature */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.parameters = parseBracketedList(14 /* Parameters */, parseParameter, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); + node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); @@ -8648,19 +8929,19 @@ var ts; function parsePropertyOrMethodSignature() { var fullStart = scanner.getStartPos(); var name = parsePropertyName(); - var questionToken = parseOptionalToken(50 /* QuestionToken */); + var questionToken = parseOptionalToken(51 /* QuestionToken */); if (token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { - var method = createNode(135 /* MethodSignature */, fullStart); + var method = createNode(139 /* MethodSignature */, fullStart); method.name = name; method.questionToken = questionToken; // Method signatues don't exist in expression contexts. So they have neither - // [Yield] nor [GeneratorParameter] - fillSignature(51 /* ColonToken */, false, false, method); + // [Yield] nor [Await] + fillSignature(52 /* ColonToken */, false, false, false, method); parseTypeMemberSemicolon(); return finishNode(method); } else { - var property = createNode(133 /* PropertySignature */, fullStart); + var property = createNode(137 /* PropertySignature */, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -8694,23 +8975,23 @@ var ts; nextToken(); return token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */ || - token === 50 /* QuestionToken */ || - token === 51 /* ColonToken */ || + token === 51 /* QuestionToken */ || + token === 52 /* ColonToken */ || canParseSemicolon(); } function parseTypeMember() { switch (token) { case 16 /* OpenParenToken */: case 24 /* LessThanToken */: - return parseSignatureMember(140 /* CallSignature */); + return parseSignatureMember(144 /* CallSignature */); case 18 /* OpenBracketToken */: // Indexer or computed property return isIndexSignature() ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) : parsePropertyOrMethodSignature(); - case 88 /* NewKeyword */: + case 89 /* NewKeyword */: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(141 /* ConstructSignature */); + return parseSignatureMember(145 /* ConstructSignature */); } // fall through. case 8 /* StringLiteral */: @@ -8747,7 +9028,7 @@ var ts; return token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */; } function parseTypeLiteral() { - var node = createNode(148 /* TypeLiteral */); + var node = createNode(152 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -8763,12 +9044,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(150 /* TupleType */); - node.elementTypes = parseBracketedList(17 /* TupleElementTypes */, parseType, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); + var node = createNode(154 /* TupleType */); + node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(152 /* ParenthesizedType */); + var node = createNode(157 /* ParenthesizedType */); parseExpected(16 /* OpenParenToken */); node.type = parseType(); parseExpected(17 /* CloseParenToken */); @@ -8776,10 +9057,10 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 146 /* ConstructorType */) { - parseExpected(88 /* NewKeyword */); + if (kind === 150 /* ConstructorType */) { + parseExpected(89 /* NewKeyword */); } - fillSignature(32 /* EqualsGreaterThanToken */, false, false, node); + fillSignature(33 /* EqualsGreaterThanToken */, false, false, false, node); return finishNode(node); } function parseKeywordAndNoDot() { @@ -8788,17 +9069,17 @@ var ts; } function parseNonArrayType() { switch (token) { - case 112 /* AnyKeyword */: - case 123 /* StringKeyword */: - case 121 /* NumberKeyword */: - case 113 /* BooleanKeyword */: - case 124 /* SymbolKeyword */: + case 114 /* AnyKeyword */: + case 127 /* StringKeyword */: + case 125 /* NumberKeyword */: + case 117 /* BooleanKeyword */: + case 128 /* SymbolKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReferenceOrTypePredicate(); - case 99 /* VoidKeyword */: + case 100 /* VoidKeyword */: return parseTokenNode(); - case 97 /* TypeOfKeyword */: + case 98 /* TypeOfKeyword */: return parseTypeQuery(); case 14 /* OpenBraceToken */: return parseTypeLiteral(); @@ -8812,17 +9093,17 @@ var ts; } function isStartOfType() { switch (token) { - case 112 /* AnyKeyword */: - case 123 /* StringKeyword */: - case 121 /* NumberKeyword */: - case 113 /* BooleanKeyword */: - case 124 /* SymbolKeyword */: - case 99 /* VoidKeyword */: - case 97 /* TypeOfKeyword */: + case 114 /* AnyKeyword */: + case 127 /* StringKeyword */: + case 125 /* NumberKeyword */: + case 117 /* BooleanKeyword */: + case 128 /* SymbolKeyword */: + case 100 /* VoidKeyword */: + case 98 /* TypeOfKeyword */: case 14 /* OpenBraceToken */: case 18 /* OpenBracketToken */: case 24 /* LessThanToken */: - case 88 /* NewKeyword */: + case 89 /* NewKeyword */: return true; case 16 /* OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, @@ -8840,27 +9121,33 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(18 /* OpenBracketToken */)) { parseExpected(19 /* CloseBracketToken */); - var node = createNode(149 /* ArrayType */, type.pos); + var node = createNode(153 /* ArrayType */, type.pos); node.elementType = type; type = finishNode(node); } return type; } - function parseUnionTypeOrHigher() { - var type = parseArrayTypeOrHigher(); - if (token === 44 /* BarToken */) { + function parseUnionOrIntersectionType(kind, parseConstituentType, operator) { + var type = parseConstituentType(); + if (token === operator) { var types = [type]; types.pos = type.pos; - while (parseOptional(44 /* BarToken */)) { - types.push(parseArrayTypeOrHigher()); + while (parseOptional(operator)) { + types.push(parseConstituentType()); } types.end = getNodeEnd(); - var node = createNode(151 /* UnionType */, type.pos); + var node = createNode(kind, type.pos); node.types = types; type = finishNode(node); } return type; } + function parseIntersectionTypeOrHigher() { + return parseUnionOrIntersectionType(156 /* IntersectionType */, parseArrayTypeOrHigher, 44 /* AmpersandToken */); + } + function parseUnionTypeOrHigher() { + return parseUnionOrIntersectionType(155 /* UnionType */, parseIntersectionTypeOrHigher, 45 /* BarToken */); + } function isStartOfFunctionType() { if (token === 24 /* LessThanToken */) { return true; @@ -8876,8 +9163,8 @@ var ts; } if (isIdentifier() || ts.isModifier(token)) { nextToken(); - if (token === 51 /* ColonToken */ || token === 23 /* CommaToken */ || - token === 50 /* QuestionToken */ || token === 53 /* EqualsToken */ || + if (token === 52 /* ColonToken */ || token === 23 /* CommaToken */ || + token === 51 /* QuestionToken */ || token === 54 /* EqualsToken */ || isIdentifier() || ts.isModifier(token)) { // ( id : // ( id , @@ -8888,7 +9175,7 @@ var ts; } if (token === 17 /* CloseParenToken */) { nextToken(); - if (token === 32 /* EqualsGreaterThanToken */) { + if (token === 33 /* EqualsGreaterThanToken */) { // ( id ) => return true; } @@ -8899,35 +9186,28 @@ var ts; function parseType() { // The rules about 'yield' only apply to actual code/expression contexts. They don't // apply to 'type' contexts. So we disable these parameters here before moving on. - var savedYieldContext = inYieldContext(); - var savedGeneratorParameterContext = inGeneratorParameterContext(); - setYieldContext(false); - setGeneratorParameterContext(false); - var result = parseTypeWorker(); - setYieldContext(savedYieldContext); - setGeneratorParameterContext(savedGeneratorParameterContext); - return result; + return doOutsideOfContext(10 /* TypeExcludesFlags */, parseTypeWorker); } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(145 /* FunctionType */); + return parseFunctionOrConstructorType(149 /* FunctionType */); } - if (token === 88 /* NewKeyword */) { - return parseFunctionOrConstructorType(146 /* ConstructorType */); + if (token === 89 /* NewKeyword */) { + return parseFunctionOrConstructorType(150 /* ConstructorType */); } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(51 /* ColonToken */) ? parseType() : undefined; + return parseOptional(52 /* ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token) { - case 93 /* ThisKeyword */: - case 91 /* SuperKeyword */: - case 89 /* NullKeyword */: - case 95 /* TrueKeyword */: - case 80 /* FalseKeyword */: + case 94 /* ThisKeyword */: + case 92 /* SuperKeyword */: + case 90 /* NullKeyword */: + case 96 /* TrueKeyword */: + case 81 /* FalseKeyword */: case 7 /* NumericLiteral */: case 8 /* StringLiteral */: case 10 /* NoSubstitutionTemplateLiteral */: @@ -8935,12 +9215,12 @@ var ts; case 16 /* OpenParenToken */: case 18 /* OpenBracketToken */: case 14 /* OpenBraceToken */: - case 83 /* FunctionKeyword */: - case 69 /* ClassKeyword */: - case 88 /* NewKeyword */: - case 36 /* SlashToken */: - case 57 /* SlashEqualsToken */: - case 65 /* Identifier */: + case 84 /* FunctionKeyword */: + case 70 /* ClassKeyword */: + case 89 /* NewKeyword */: + case 37 /* SlashToken */: + case 58 /* SlashEqualsToken */: + case 66 /* Identifier */: return true; default: return isIdentifier(); @@ -8951,20 +9231,21 @@ var ts; return true; } switch (token) { - case 33 /* PlusToken */: - case 34 /* MinusToken */: - case 47 /* TildeToken */: - case 46 /* ExclamationToken */: - case 74 /* DeleteKeyword */: - case 97 /* TypeOfKeyword */: - case 99 /* VoidKeyword */: - case 38 /* PlusPlusToken */: - case 39 /* MinusMinusToken */: + case 34 /* PlusToken */: + case 35 /* MinusToken */: + case 48 /* TildeToken */: + case 47 /* ExclamationToken */: + case 75 /* DeleteKeyword */: + case 98 /* TypeOfKeyword */: + case 100 /* VoidKeyword */: + case 39 /* PlusPlusToken */: + case 40 /* MinusMinusToken */: case 24 /* LessThanToken */: - case 110 /* YieldKeyword */: - // Yield always starts an expression. Either it is an identifier (in which case + case 116 /* AwaitKeyword */: + case 111 /* YieldKeyword */: + // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in - // a generator, or in strict mode (or both)) and it started a yield expression. + // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. return true; default: // Error tolerance. If we see the start of some binary operator, we consider @@ -8980,11 +9261,14 @@ var ts; function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. return token !== 14 /* OpenBraceToken */ && - token !== 83 /* FunctionKeyword */ && - token !== 69 /* ClassKeyword */ && - token !== 52 /* AtToken */ && + token !== 84 /* FunctionKeyword */ && + token !== 70 /* ClassKeyword */ && + token !== 53 /* AtToken */ && isStartOfExpression(); } + function allowInAndParseExpression() { + return allowInAnd(parseExpression); + } function parseExpression() { // Expression[in]: // AssignmentExpression[in] @@ -9005,7 +9289,7 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token !== 53 /* EqualsToken */) { + if (token !== 54 /* EqualsToken */) { // It's not uncommon during typing for the user to miss writing the '=' token. Check if // there is no newline after the last token and if we're on an expression. If so, parse // this as an equals-value clause with a missing equals. @@ -9022,7 +9306,7 @@ var ts; } // Initializer[In, Yield] : // = AssignmentExpression[?In, ?Yield] - parseExpected(53 /* EqualsToken */); + parseExpected(54 /* EqualsToken */); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -9060,7 +9344,7 @@ var ts; // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 65 /* Identifier */ && token === 32 /* EqualsGreaterThanToken */) { + if (expr.kind === 66 /* Identifier */ && token === 33 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } // Now see if we might be in cases '2' or '3'. @@ -9076,7 +9360,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token === 110 /* YieldKeyword */) { + if (token === 111 /* YieldKeyword */) { // If we have a 'yield' keyword, and htis is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { @@ -9105,15 +9389,15 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(175 /* YieldExpression */); + var node = createNode(181 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token === 35 /* AsteriskToken */ || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(35 /* AsteriskToken */); + (token === 36 /* AsteriskToken */ || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(36 /* AsteriskToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -9124,16 +9408,16 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier) { - ts.Debug.assert(token === 32 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(166 /* ArrowFunction */, identifier.pos); - var parameter = createNode(131 /* Parameter */, identifier.pos); + ts.Debug.assert(token === 33 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + var node = createNode(171 /* ArrowFunction */, identifier.pos); + var parameter = createNode(135 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; node.parameters.pos = parameter.pos; node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(32 /* EqualsGreaterThanToken */, false, ts.Diagnostics._0_expected, "=>"); - node.body = parseArrowFunctionExpressionBody(); + node.equalsGreaterThanToken = parseExpectedToken(33 /* EqualsGreaterThanToken */, false, ts.Diagnostics._0_expected, "=>"); + node.body = parseArrowFunctionExpressionBody(false); return finishNode(node); } function tryParseParenthesizedArrowFunctionExpression() { @@ -9153,12 +9437,13 @@ var ts; // Didn't appear to actually be a parenthesized arrow function. Just bail out. return undefined; } + var isAsync = !!(arrowFunction.flags & 512 /* Async */); // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token; - arrowFunction.equalsGreaterThanToken = parseExpectedToken(32 /* EqualsGreaterThanToken */, false, ts.Diagnostics._0_expected, "=>"); - arrowFunction.body = (lastToken === 32 /* EqualsGreaterThanToken */ || lastToken === 14 /* OpenBraceToken */) - ? parseArrowFunctionExpressionBody() + arrowFunction.equalsGreaterThanToken = parseExpectedToken(33 /* EqualsGreaterThanToken */, false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 33 /* EqualsGreaterThanToken */ || lastToken === 14 /* OpenBraceToken */) + ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); } @@ -9167,10 +9452,10 @@ var ts; // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { + if (token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */ || token === 115 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token === 32 /* EqualsGreaterThanToken */) { + if (token === 33 /* EqualsGreaterThanToken */) { // ERROR RECOVERY TWEAK: // If we see a standalone => try to parse it as an arrow function expression as that's // likely what the user intended to write. @@ -9180,6 +9465,15 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { + if (token === 115 /* AsyncKeyword */) { + nextToken(); + if (scanner.hasPrecedingLineBreak()) { + return 0 /* False */; + } + if (token !== 16 /* OpenParenToken */ && token !== 24 /* LessThanToken */) { + return 0 /* False */; + } + } var first = token; var second = nextToken(); if (first === 16 /* OpenParenToken */) { @@ -9190,8 +9484,8 @@ var ts; // but this is probably what the user intended. var third = nextToken(); switch (third) { - case 32 /* EqualsGreaterThanToken */: - case 51 /* ColonToken */: + case 33 /* EqualsGreaterThanToken */: + case 52 /* ColonToken */: case 14 /* OpenBraceToken */: return 1 /* True */; default: @@ -9222,7 +9516,7 @@ var ts; } // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. - if (nextToken() === 51 /* ColonToken */) { + if (nextToken() === 52 /* ColonToken */) { return 1 /* True */; } // This *could* be a parenthesized arrow function. @@ -9236,6 +9530,30 @@ var ts; if (!isIdentifier()) { return 0 /* False */; } + // JSX overrides + if (sourceFile.languageVariant === 1 /* JSX */) { + var isArrowFunctionInJsx = lookAhead(function () { + var third = nextToken(); + if (third === 80 /* ExtendsKeyword */) { + var fourth = nextToken(); + switch (fourth) { + case 54 /* EqualsToken */: + case 26 /* GreaterThanToken */: + return false; + default: + return true; + } + } + else if (third === 23 /* CommaToken */) { + return true; + } + return false; + }); + if (isArrowFunctionInJsx) { + return 1 /* True */; + } + return 0 /* False */; + } // This *could* be a parenthesized arrow function. return 2 /* Unknown */; } @@ -9244,7 +9562,9 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(166 /* ArrowFunction */); + var node = createNode(171 /* ArrowFunction */); + setModifiers(node, parseModifiersForArrowFunction()); + var isAsync = !!(node.flags & 512 /* Async */); // Arrow functions are never generators. // // If we're speculatively parsing a signature for a parenthesized arrow function, then @@ -9252,7 +9572,7 @@ var ts; // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - fillSignature(51 /* ColonToken */, false, !allowAmbiguity, node); + fillSignature(52 /* ColonToken */, false, isAsync, !allowAmbiguity, node); // If we couldn't get parameters, we definitely could not parse out an arrow function. if (!node.parameters) { return undefined; @@ -9265,19 +9585,19 @@ var ts; // - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation. // // So we need just a bit of lookahead to ensure that it can only be a signature. - if (!allowAmbiguity && token !== 32 /* EqualsGreaterThanToken */ && token !== 14 /* OpenBraceToken */) { + if (!allowAmbiguity && token !== 33 /* EqualsGreaterThanToken */ && token !== 14 /* OpenBraceToken */) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } return node; } - function parseArrowFunctionExpressionBody() { + function parseArrowFunctionExpressionBody(isAsync) { if (token === 14 /* OpenBraceToken */) { - return parseFunctionBlock(false, false); + return parseFunctionBlock(false, isAsync, false); } if (token !== 22 /* SemicolonToken */ && - token !== 83 /* FunctionKeyword */ && - token !== 69 /* ClassKeyword */ && + token !== 84 /* FunctionKeyword */ && + token !== 70 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -9294,23 +9614,25 @@ var ts; // up preemptively closing the containing construct. // // Note: even when 'ignoreMissingOpenBrace' is passed as true, parseBody will still error. - return parseFunctionBlock(false, true); + return parseFunctionBlock(false, isAsync, true); } - return parseAssignmentExpressionOrHigher(); + return isAsync + ? doInAwaitContext(parseAssignmentExpressionOrHigher) + : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); } function parseConditionalExpressionRest(leftOperand) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(50 /* QuestionToken */); + var questionToken = parseOptionalToken(51 /* QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(173 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(179 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(51 /* ColonToken */, false, ts.Diagnostics._0_expected, ts.tokenToString(51 /* ColonToken */)); + node.colonToken = parseExpectedToken(52 /* ColonToken */, false, ts.Diagnostics._0_expected, ts.tokenToString(52 /* ColonToken */)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -9319,7 +9641,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 86 /* InKeyword */ || t === 127 /* OfKeyword */; + return t === 87 /* InKeyword */ || t === 131 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -9331,53 +9653,70 @@ var ts; if (newPrecedence <= precedence) { break; } - if (token === 86 /* InKeyword */ && inDisallowInContext()) { + if (token === 87 /* InKeyword */ && inDisallowInContext()) { break; } - leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence)); + if (token === 113 /* AsKeyword */) { + // Make sure we *do* perform ASI for constructs like this: + // var x = foo + // as (Bar) + // This should be parsed as an initialized variable, followed + // by a function call to 'as' with the argument 'Bar' + if (scanner.hasPrecedingLineBreak()) { + break; + } + else { + nextToken(); + leftOperand = makeAsExpression(leftOperand, parseType()); + } + } + else { + leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence)); + } } return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token === 86 /* InKeyword */) { + if (inDisallowInContext() && token === 87 /* InKeyword */) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token) { - case 49 /* BarBarToken */: + case 50 /* BarBarToken */: return 1; - case 48 /* AmpersandAmpersandToken */: + case 49 /* AmpersandAmpersandToken */: return 2; - case 44 /* BarToken */: + case 45 /* BarToken */: return 3; - case 45 /* CaretToken */: + case 46 /* CaretToken */: return 4; - case 43 /* AmpersandToken */: + case 44 /* AmpersandToken */: return 5; - case 28 /* EqualsEqualsToken */: - case 29 /* ExclamationEqualsToken */: - case 30 /* EqualsEqualsEqualsToken */: - case 31 /* ExclamationEqualsEqualsToken */: + case 29 /* EqualsEqualsToken */: + case 30 /* ExclamationEqualsToken */: + case 31 /* EqualsEqualsEqualsToken */: + case 32 /* ExclamationEqualsEqualsToken */: return 6; case 24 /* LessThanToken */: - case 25 /* GreaterThanToken */: - case 26 /* LessThanEqualsToken */: - case 27 /* GreaterThanEqualsToken */: - case 87 /* InstanceOfKeyword */: - case 86 /* InKeyword */: + case 26 /* GreaterThanToken */: + case 27 /* LessThanEqualsToken */: + case 28 /* GreaterThanEqualsToken */: + case 88 /* InstanceOfKeyword */: + case 87 /* InKeyword */: + case 113 /* AsKeyword */: return 7; - case 40 /* LessThanLessThanToken */: - case 41 /* GreaterThanGreaterThanToken */: - case 42 /* GreaterThanGreaterThanGreaterThanToken */: + case 41 /* LessThanLessThanToken */: + case 42 /* GreaterThanGreaterThanToken */: + case 43 /* GreaterThanGreaterThanGreaterThanToken */: return 8; - case 33 /* PlusToken */: - case 34 /* MinusToken */: + case 34 /* PlusToken */: + case 35 /* MinusToken */: return 9; - case 35 /* AsteriskToken */: - case 36 /* SlashToken */: - case 37 /* PercentToken */: + case 36 /* AsteriskToken */: + case 37 /* SlashToken */: + case 38 /* PercentToken */: return 10; } // -1 is lower than all other precedences. Returning it will cause binary expression @@ -9385,54 +9724,85 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(172 /* BinaryExpression */, left.pos); + var node = createNode(178 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } + function makeAsExpression(left, right) { + var node = createNode(186 /* AsExpression */, left.pos); + node.expression = left; + node.type = right; + return finishNode(node); + } function parsePrefixUnaryExpression() { - var node = createNode(170 /* PrefixUnaryExpression */); + var node = createNode(176 /* PrefixUnaryExpression */); node.operator = token; nextToken(); node.operand = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(167 /* DeleteExpression */); + var node = createNode(172 /* DeleteExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(168 /* TypeOfExpression */); + var node = createNode(173 /* TypeOfExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(169 /* VoidExpression */); + var node = createNode(174 /* VoidExpression */); + nextToken(); + node.expression = parseUnaryExpressionOrHigher(); + return finishNode(node); + } + function isAwaitExpression() { + if (token === 116 /* AwaitKeyword */) { + if (inAwaitContext()) { + return true; + } + // here we are using similar heuristics as 'isYieldExpression' + return lookAhead(nextTokenIsIdentifierOnSameLine); + } + return false; + } + function parseAwaitExpression() { + var node = createNode(175 /* AwaitExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseUnaryExpressionOrHigher() { + if (isAwaitExpression()) { + return parseAwaitExpression(); + } switch (token) { - case 33 /* PlusToken */: - case 34 /* MinusToken */: - case 47 /* TildeToken */: - case 46 /* ExclamationToken */: - case 38 /* PlusPlusToken */: - case 39 /* MinusMinusToken */: + case 34 /* PlusToken */: + case 35 /* MinusToken */: + case 48 /* TildeToken */: + case 47 /* ExclamationToken */: + case 39 /* PlusPlusToken */: + case 40 /* MinusMinusToken */: return parsePrefixUnaryExpression(); - case 74 /* DeleteKeyword */: + case 75 /* DeleteKeyword */: return parseDeleteExpression(); - case 97 /* TypeOfKeyword */: + case 98 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 99 /* VoidKeyword */: + case 100 /* VoidKeyword */: return parseVoidExpression(); case 24 /* LessThanToken */: - return parseTypeAssertion(); + if (sourceFile.languageVariant !== 1 /* JSX */) { + return parseTypeAssertion(); + } + if (lookAhead(nextTokenIsIdentifierOrKeyword)) { + return parseJsxElementOrSelfClosingElement(); + } + // Fall through default: return parsePostfixExpressionOrHigher(); } @@ -9440,8 +9810,8 @@ var ts; function parsePostfixExpressionOrHigher() { var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token === 38 /* PlusPlusToken */ || token === 39 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(171 /* PostfixUnaryExpression */, expression.pos); + if ((token === 39 /* PlusPlusToken */ || token === 40 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(177 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -9480,7 +9850,7 @@ var ts; // the last two CallExpression productions. Or we have a MemberExpression which either // completes the LeftHandSideExpression, or starts the beginning of the first four // CallExpression productions. - var expression = token === 91 /* SuperKeyword */ + var expression = token === 92 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); // Now, we *may* be complete. However, we might have consumed the start of a @@ -9545,17 +9915,141 @@ var ts; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(158 /* PropertyAccessExpression */, expression.pos); + var node = createNode(163 /* PropertyAccessExpression */, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(20 /* DotToken */, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } + function parseJsxElementOrSelfClosingElement() { + var opening = parseJsxOpeningOrSelfClosingElement(); + if (opening.kind === 232 /* JsxOpeningElement */) { + var node = createNode(230 /* JsxElement */, opening.pos); + node.openingElement = opening; + node.children = parseJsxChildren(node.openingElement.tagName); + node.closingElement = parseJsxClosingElement(); + return finishNode(node); + } + else { + ts.Debug.assert(opening.kind === 231 /* JsxSelfClosingElement */); + // Nothing else to do for self-closing elements + return opening; + } + } + function parseJsxText() { + var node = createNode(233 /* JsxText */, scanner.getStartPos()); + token = scanner.scanJsxToken(); + return finishNode(node); + } + function parseJsxChild() { + switch (token) { + case 233 /* JsxText */: + return parseJsxText(); + case 14 /* OpenBraceToken */: + return parseJsxExpression(); + case 24 /* LessThanToken */: + return parseJsxElementOrSelfClosingElement(); + } + ts.Debug.fail('Unknown JSX child kind ' + token); + } + function parseJsxChildren(openingTagName) { + var result = []; + result.pos = scanner.getStartPos(); + var saveParsingContext = parsingContext; + parsingContext |= 1 << 14 /* JsxChildren */; + while (true) { + token = scanner.reScanJsxToken(); + if (token === 25 /* LessThanSlashToken */) { + break; + } + else if (token === 1 /* EndOfFileToken */) { + parseErrorAtCurrentToken(ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNodeFromSourceText(sourceText, openingTagName)); + break; + } + result.push(parseJsxChild()); + } + result.end = scanner.getTokenPos(); + parsingContext = saveParsingContext; + return result; + } + function parseJsxOpeningOrSelfClosingElement() { + var fullStart = scanner.getStartPos(); + parseExpected(24 /* LessThanToken */); + var tagName = parseJsxElementName(); + var attributes = parseList(13 /* JsxAttributes */, parseJsxAttribute); + var node; + if (parseOptional(26 /* GreaterThanToken */)) { + node = createNode(232 /* JsxOpeningElement */, fullStart); + } + else { + parseExpected(37 /* SlashToken */); + parseExpected(26 /* GreaterThanToken */); + node = createNode(231 /* JsxSelfClosingElement */, fullStart); + } + node.tagName = tagName; + node.attributes = attributes; + return finishNode(node); + } + function parseJsxElementName() { + scanJsxIdentifier(); + var elementName = parseIdentifierName(); + while (parseOptional(20 /* DotToken */)) { + scanJsxIdentifier(); + var node = createNode(132 /* QualifiedName */, elementName.pos); + node.left = elementName; + node.right = parseIdentifierName(); + elementName = finishNode(node); + } + return elementName; + } + function parseJsxExpression() { + var node = createNode(237 /* JsxExpression */); + parseExpected(14 /* OpenBraceToken */); + if (token !== 15 /* CloseBraceToken */) { + node.expression = parseExpression(); + } + parseExpected(15 /* CloseBraceToken */); + return finishNode(node); + } + function parseJsxAttribute() { + if (token === 14 /* OpenBraceToken */) { + return parseJsxSpreadAttribute(); + } + scanJsxIdentifier(); + var node = createNode(235 /* JsxAttribute */); + node.name = parseIdentifierName(); + if (parseOptional(54 /* EqualsToken */)) { + switch (token) { + case 8 /* StringLiteral */: + node.initializer = parseLiteralNode(); + break; + default: + node.initializer = parseJsxExpression(); + break; + } + } + return finishNode(node); + } + function parseJsxSpreadAttribute() { + var node = createNode(236 /* JsxSpreadAttribute */); + parseExpected(14 /* OpenBraceToken */); + parseExpected(21 /* DotDotDotToken */); + node.expression = parseExpression(); + parseExpected(15 /* CloseBraceToken */); + return finishNode(node); + } + function parseJsxClosingElement() { + var node = createNode(234 /* JsxClosingElement */); + parseExpected(25 /* LessThanSlashToken */); + node.tagName = parseJsxElementName(); + parseExpected(26 /* GreaterThanToken */); + return finishNode(node); + } function parseTypeAssertion() { - var node = createNode(163 /* TypeAssertionExpression */); + var node = createNode(168 /* TypeAssertionExpression */); parseExpected(24 /* LessThanToken */); node.type = parseType(); - parseExpected(25 /* GreaterThanToken */); + parseExpected(26 /* GreaterThanToken */); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } @@ -9563,16 +10057,16 @@ var ts; while (true) { var dotToken = parseOptionalToken(20 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(158 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(163 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); continue; } - // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName + // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName if (!inDecoratorContext() && parseOptional(18 /* OpenBracketToken */)) { - var indexedAccess = createNode(159 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(164 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; // It's not uncommon for a user to write: "new Type[]". // Check for that common pattern and report a better error message. @@ -9588,7 +10082,7 @@ var ts; continue; } if (token === 10 /* NoSubstitutionTemplateLiteral */ || token === 11 /* TemplateHead */) { - var tagExpression = createNode(162 /* TaggedTemplateExpression */, expression.pos); + var tagExpression = createNode(167 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 10 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() @@ -9611,7 +10105,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(160 /* CallExpression */, expression.pos); + var callExpr = createNode(165 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -9619,7 +10113,7 @@ var ts; continue; } else if (token === 16 /* OpenParenToken */) { - var callExpr = createNode(160 /* CallExpression */, expression.pos); + var callExpr = createNode(165 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -9638,8 +10132,8 @@ var ts; if (!parseOptional(24 /* LessThanToken */)) { return undefined; } - var typeArguments = parseDelimitedList(16 /* TypeArguments */, parseType); - if (!parseExpected(25 /* GreaterThanToken */)) { + var typeArguments = parseDelimitedList(18 /* TypeArguments */, parseType); + if (!parseExpected(26 /* GreaterThanToken */)) { // If it doesn't have the closing > then it's definitely not an type argument list. return undefined; } @@ -9657,18 +10151,18 @@ var ts; case 20 /* DotToken */: // foo. case 17 /* CloseParenToken */: // foo) case 19 /* CloseBracketToken */: // foo] - case 51 /* ColonToken */: // foo: + case 52 /* ColonToken */: // foo: case 22 /* SemicolonToken */: // foo; - case 50 /* QuestionToken */: // foo? - case 28 /* EqualsEqualsToken */: // foo == - case 30 /* EqualsEqualsEqualsToken */: // foo === - case 29 /* ExclamationEqualsToken */: // foo != - case 31 /* ExclamationEqualsEqualsToken */: // foo !== - case 48 /* AmpersandAmpersandToken */: // foo && - case 49 /* BarBarToken */: // foo || - case 45 /* CaretToken */: // foo ^ - case 43 /* AmpersandToken */: // foo & - case 44 /* BarToken */: // foo | + case 51 /* QuestionToken */: // foo? + case 29 /* EqualsEqualsToken */: // foo == + case 31 /* EqualsEqualsEqualsToken */: // foo === + case 30 /* ExclamationEqualsToken */: // foo != + case 32 /* ExclamationEqualsEqualsToken */: // foo !== + case 49 /* AmpersandAmpersandToken */: // foo && + case 50 /* BarBarToken */: // foo || + case 46 /* CaretToken */: // foo ^ + case 44 /* AmpersandToken */: // foo & + case 45 /* BarToken */: // foo | case 15 /* CloseBraceToken */: // foo } case 1 /* EndOfFileToken */: // these cases can't legally follow a type arg list. However, they're not legal @@ -9678,7 +10172,7 @@ var ts; case 23 /* CommaToken */: // foo, case 14 /* OpenBraceToken */: // foo { // We don't want to treat these as type arguments. Otherwise we'll parse this - // as an invocation expression. Instead, we want to parse out the expression + // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. default: // Anything else treat as an expression. @@ -9691,11 +10185,11 @@ var ts; case 8 /* StringLiteral */: case 10 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 93 /* ThisKeyword */: - case 91 /* SuperKeyword */: - case 89 /* NullKeyword */: - case 95 /* TrueKeyword */: - case 80 /* FalseKeyword */: + case 94 /* ThisKeyword */: + case 92 /* SuperKeyword */: + case 90 /* NullKeyword */: + case 96 /* TrueKeyword */: + case 81 /* FalseKeyword */: return parseTokenNode(); case 16 /* OpenParenToken */: return parseParenthesizedExpression(); @@ -9703,14 +10197,22 @@ var ts; return parseArrayLiteralExpression(); case 14 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 69 /* ClassKeyword */: - return parseClassExpression(); - case 83 /* FunctionKeyword */: + case 115 /* AsyncKeyword */: + // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. + // If we encounter `async [no LineTerminator here] function` then this is an async + // function; otherwise, its an identifier. + if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { + break; + } return parseFunctionExpression(); - case 88 /* NewKeyword */: + case 70 /* ClassKeyword */: + return parseClassExpression(); + case 84 /* FunctionKeyword */: + return parseFunctionExpression(); + case 89 /* NewKeyword */: return parseNewExpression(); - case 36 /* SlashToken */: - case 57 /* SlashEqualsToken */: + case 37 /* SlashToken */: + case 58 /* SlashEqualsToken */: if (reScanSlashToken() === 9 /* RegularExpressionLiteral */) { return parseLiteralNode(); } @@ -9721,41 +10223,41 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(164 /* ParenthesizedExpression */); + var node = createNode(169 /* ParenthesizedExpression */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(17 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(176 /* SpreadElementExpression */); + var node = createNode(182 /* SpreadElementExpression */); parseExpected(21 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 21 /* DotDotDotToken */ ? parseSpreadElement() : - token === 23 /* CommaToken */ ? createNode(178 /* OmittedExpression */) : + token === 23 /* CommaToken */ ? createNode(184 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(156 /* ArrayLiteralExpression */); + var node = createNode(161 /* ArrayLiteralExpression */); parseExpected(18 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) - node.flags |= 512 /* MultiLine */; - node.elements = parseDelimitedList(13 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); + node.flags |= 2048 /* MultiLine */; + node.elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); parseExpected(19 /* CloseBracketToken */); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(116 /* GetKeyword */)) { - return parseAccessorDeclaration(138 /* GetAccessor */, fullStart, decorators, modifiers); + if (parseContextualModifier(120 /* GetKeyword */)) { + return parseAccessorDeclaration(142 /* GetAccessor */, fullStart, decorators, modifiers); } - else if (parseContextualModifier(122 /* SetKeyword */)) { - return parseAccessorDeclaration(139 /* SetAccessor */, fullStart, decorators, modifiers); + else if (parseContextualModifier(126 /* SetKeyword */)) { + return parseAccessorDeclaration(143 /* SetAccessor */, fullStart, decorators, modifiers); } return undefined; } @@ -9767,56 +10269,64 @@ var ts; if (accessor) { return accessor; } - var asteriskToken = parseOptionalToken(35 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(36 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); var nameToken = token; var propertyName = parsePropertyName(); // Disallowing of optional property assignments happens in the grammar checker. - var questionToken = parseOptionalToken(50 /* QuestionToken */); + var questionToken = parseOptionalToken(51 /* QuestionToken */); if (asteriskToken || token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } // Parse to check if it is short-hand property assignment or normal property assignment if ((token === 23 /* CommaToken */ || token === 15 /* CloseBraceToken */) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(228 /* ShorthandPropertyAssignment */, fullStart); + var shorthandDeclaration = createNode(243 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(227 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(242 /* PropertyAssignment */, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(51 /* ColonToken */); + parseExpected(52 /* ColonToken */); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return finishNode(propertyAssignment); } } function parseObjectLiteralExpression() { - var node = createNode(157 /* ObjectLiteralExpression */); + var node = createNode(162 /* ObjectLiteralExpression */); parseExpected(14 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { - node.flags |= 512 /* MultiLine */; + node.flags |= 2048 /* MultiLine */; } node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, true); parseExpected(15 /* CloseBraceToken */); return finishNode(node); } function parseFunctionExpression() { - // GeneratorExpression : - // function * BindingIdentifier[Yield]opt (FormalParameters[Yield, GeneratorParameter]) { GeneratorBody[Yield] } + // GeneratorExpression: + // function* BindingIdentifier [Yield][opt](FormalParameters[Yield]){ GeneratorBody } + // // FunctionExpression: - // function BindingIdentifieropt(FormalParameters) { FunctionBody } + // function BindingIdentifier[opt](FormalParameters){ FunctionBody } var saveDecoratorContext = inDecoratorContext(); if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(165 /* FunctionExpression */); - parseExpected(83 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(35 /* AsteriskToken */); - node.name = node.asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(51 /* ColonToken */, !!node.asteriskToken, false, node); - node.body = parseFunctionBlock(!!node.asteriskToken, false); + var node = createNode(170 /* FunctionExpression */); + setModifiers(node, parseModifiers()); + parseExpected(84 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(36 /* AsteriskToken */); + var isGenerator = !!node.asteriskToken; + var isAsync = !!(node.flags & 512 /* Async */); + node.name = + isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : + isGenerator ? doInYieldContext(parseOptionalIdentifier) : + isAsync ? doInAwaitContext(parseOptionalIdentifier) : + parseOptionalIdentifier(); + fillSignature(52 /* ColonToken */, isGenerator, isAsync, false, node); + node.body = parseFunctionBlock(isGenerator, isAsync, false); if (saveDecoratorContext) { setDecoratorContext(true); } @@ -9826,8 +10336,8 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(161 /* NewExpression */); - parseExpected(88 /* NewKeyword */); + var node = createNode(166 /* NewExpression */); + parseExpected(89 /* NewKeyword */); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token === 16 /* OpenParenToken */) { @@ -9837,7 +10347,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(182 /* Block */); + var node = createNode(189 /* Block */); if (parseExpected(14 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(15 /* CloseBraceToken */); @@ -9847,10 +10357,12 @@ var ts; } return finishNode(node); } - function parseFunctionBlock(allowYield, ignoreMissingOpenBrace, diagnosticMessage) { + function parseFunctionBlock(allowYield, allowAwait, ignoreMissingOpenBrace, diagnosticMessage) { var savedYieldContext = inYieldContext(); setYieldContext(allowYield); - // We may be in a [Decorator] context when parsing a function expression or + var savedAwaitContext = inAwaitContext(); + setAwaitContext(allowAwait); + // We may be in a [Decorator] context when parsing a function expression or // arrow function. The body of the function is not in [Decorator] context. var saveDecoratorContext = inDecoratorContext(); if (saveDecoratorContext) { @@ -9861,28 +10373,29 @@ var ts; setDecoratorContext(true); } setYieldContext(savedYieldContext); + setAwaitContext(savedAwaitContext); return block; } function parseEmptyStatement() { - var node = createNode(184 /* EmptyStatement */); + var node = createNode(191 /* EmptyStatement */); parseExpected(22 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(186 /* IfStatement */); - parseExpected(84 /* IfKeyword */); + var node = createNode(193 /* IfStatement */); + parseExpected(85 /* IfKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(17 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(76 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(77 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(187 /* DoStatement */); - parseExpected(75 /* DoKeyword */); + var node = createNode(194 /* DoStatement */); + parseExpected(76 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(100 /* WhileKeyword */); + parseExpected(101 /* WhileKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(17 /* CloseParenToken */); @@ -9894,8 +10407,8 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(188 /* WhileStatement */); - parseExpected(100 /* WhileKeyword */); + var node = createNode(195 /* WhileStatement */); + parseExpected(101 /* WhileKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(17 /* CloseParenToken */); @@ -9904,11 +10417,11 @@ var ts; } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(82 /* ForKeyword */); + parseExpected(83 /* ForKeyword */); parseExpected(16 /* OpenParenToken */); var initializer = undefined; if (token !== 22 /* SemicolonToken */) { - if (token === 98 /* VarKeyword */ || token === 104 /* LetKeyword */ || token === 70 /* ConstKeyword */) { + if (token === 99 /* VarKeyword */ || token === 105 /* LetKeyword */ || token === 71 /* ConstKeyword */) { initializer = parseVariableDeclarationList(true); } else { @@ -9916,22 +10429,22 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(86 /* InKeyword */)) { - var forInStatement = createNode(190 /* ForInStatement */, pos); + if (parseOptional(87 /* InKeyword */)) { + var forInStatement = createNode(197 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(17 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(127 /* OfKeyword */)) { - var forOfStatement = createNode(191 /* ForOfStatement */, pos); + else if (parseOptional(131 /* OfKeyword */)) { + var forOfStatement = createNode(198 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(17 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(189 /* ForStatement */, pos); + var forStatement = createNode(196 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(22 /* SemicolonToken */); if (token !== 22 /* SemicolonToken */ && token !== 17 /* CloseParenToken */) { @@ -9949,7 +10462,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 193 /* BreakStatement */ ? 66 /* BreakKeyword */ : 71 /* ContinueKeyword */); + parseExpected(kind === 200 /* BreakStatement */ ? 67 /* BreakKeyword */ : 72 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -9957,8 +10470,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(194 /* ReturnStatement */); - parseExpected(90 /* ReturnKeyword */); + var node = createNode(201 /* ReturnStatement */); + parseExpected(91 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -9966,8 +10479,8 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(195 /* WithStatement */); - parseExpected(101 /* WithKeyword */); + var node = createNode(202 /* WithStatement */); + parseExpected(102 /* WithKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(17 /* CloseParenToken */); @@ -9975,30 +10488,30 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(223 /* CaseClause */); - parseExpected(67 /* CaseKeyword */); + var node = createNode(238 /* CaseClause */); + parseExpected(68 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(51 /* ColonToken */); + parseExpected(52 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(224 /* DefaultClause */); - parseExpected(73 /* DefaultKeyword */); - parseExpected(51 /* ColonToken */); + var node = createNode(239 /* DefaultClause */); + parseExpected(74 /* DefaultKeyword */); + parseExpected(52 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token === 67 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token === 68 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(196 /* SwitchStatement */); - parseExpected(92 /* SwitchKeyword */); + var node = createNode(203 /* SwitchStatement */); + parseExpected(93 /* SwitchKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(17 /* CloseParenToken */); - var caseBlock = createNode(210 /* CaseBlock */, scanner.getStartPos()); + var caseBlock = createNode(217 /* CaseBlock */, scanner.getStartPos()); parseExpected(14 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(15 /* CloseBraceToken */); @@ -10013,29 +10526,29 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(198 /* ThrowStatement */); - parseExpected(94 /* ThrowKeyword */); + var node = createNode(205 /* ThrowStatement */); + parseExpected(95 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(199 /* TryStatement */); - parseExpected(96 /* TryKeyword */); + var node = createNode(206 /* TryStatement */); + parseExpected(97 /* TryKeyword */); node.tryBlock = parseBlock(false); - node.catchClause = token === 68 /* CatchKeyword */ ? parseCatchClause() : undefined; + node.catchClause = token === 69 /* CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. - if (!node.catchClause || token === 81 /* FinallyKeyword */) { - parseExpected(81 /* FinallyKeyword */); + if (!node.catchClause || token === 82 /* FinallyKeyword */) { + parseExpected(82 /* FinallyKeyword */); node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(226 /* CatchClause */); - parseExpected(68 /* CatchKeyword */); + var result = createNode(241 /* CatchClause */); + parseExpected(69 /* CatchKeyword */); if (parseExpected(16 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); } @@ -10044,8 +10557,8 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(200 /* DebuggerStatement */); - parseExpected(72 /* DebuggerKeyword */); + var node = createNode(207 /* DebuggerStatement */); + parseExpected(73 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } @@ -10055,26 +10568,30 @@ var ts; // a colon. var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 65 /* Identifier */ && parseOptional(51 /* ColonToken */)) { - var labeledStatement = createNode(197 /* LabeledStatement */, fullStart); + if (expression.kind === 66 /* Identifier */ && parseOptional(52 /* ColonToken */)) { + var labeledStatement = createNode(204 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(185 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(192 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); } } function isIdentifierOrKeyword() { - return token >= 65 /* Identifier */; + return token >= 66 /* Identifier */; } function nextTokenIsIdentifierOrKeywordOnSameLine() { nextToken(); return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak(); } + function nextTokenIsFunctionKeywordOnSameLine() { + nextToken(); + return token === 84 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); return (isIdentifierOrKeyword() || token === 7 /* NumericLiteral */) && !scanner.hasPrecedingLineBreak(); @@ -10082,12 +10599,12 @@ var ts; function isDeclaration() { while (true) { switch (token) { - case 98 /* VarKeyword */: - case 104 /* LetKeyword */: - case 70 /* ConstKeyword */: - case 83 /* FunctionKeyword */: - case 69 /* ClassKeyword */: - case 77 /* EnumKeyword */: + case 99 /* VarKeyword */: + case 105 /* LetKeyword */: + case 71 /* ConstKeyword */: + case 84 /* FunctionKeyword */: + case 70 /* ClassKeyword */: + case 78 /* EnumKeyword */: return true; // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; // however, an identifier cannot be followed by another identifier on the same line. This is what we @@ -10110,34 +10627,36 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 103 /* InterfaceKeyword */: - case 125 /* TypeKeyword */: + case 104 /* InterfaceKeyword */: + case 129 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 118 /* ModuleKeyword */: - case 119 /* NamespaceKeyword */: + case 122 /* ModuleKeyword */: + case 123 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 115 /* DeclareKeyword */: + case 115 /* AsyncKeyword */: + case 119 /* DeclareKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 85 /* ImportKeyword */: + case 86 /* ImportKeyword */: nextToken(); - return token === 8 /* StringLiteral */ || token === 35 /* AsteriskToken */ || + return token === 8 /* StringLiteral */ || token === 36 /* AsteriskToken */ || token === 14 /* OpenBraceToken */ || isIdentifierOrKeyword(); - case 78 /* ExportKeyword */: + case 79 /* ExportKeyword */: nextToken(); - if (token === 53 /* EqualsToken */ || token === 35 /* AsteriskToken */ || - token === 14 /* OpenBraceToken */ || token === 73 /* DefaultKeyword */) { + if (token === 54 /* EqualsToken */ || token === 36 /* AsteriskToken */ || + token === 14 /* OpenBraceToken */ || token === 74 /* DefaultKeyword */) { return true; } continue; - case 108 /* PublicKeyword */: - case 106 /* PrivateKeyword */: - case 107 /* ProtectedKeyword */: - case 109 /* StaticKeyword */: + case 109 /* PublicKeyword */: + case 107 /* PrivateKeyword */: + case 108 /* ProtectedKeyword */: + case 110 /* StaticKeyword */: + case 112 /* AbstractKeyword */: nextToken(); continue; default: @@ -10150,46 +10669,47 @@ var ts; } function isStartOfStatement() { switch (token) { - case 52 /* AtToken */: + case 53 /* AtToken */: case 22 /* SemicolonToken */: case 14 /* OpenBraceToken */: - case 98 /* VarKeyword */: - case 104 /* LetKeyword */: - case 83 /* FunctionKeyword */: - case 69 /* ClassKeyword */: - case 77 /* EnumKeyword */: - case 84 /* IfKeyword */: - case 75 /* DoKeyword */: - case 100 /* WhileKeyword */: - case 82 /* ForKeyword */: - case 71 /* ContinueKeyword */: - case 66 /* BreakKeyword */: - case 90 /* ReturnKeyword */: - case 101 /* WithKeyword */: - case 92 /* SwitchKeyword */: - case 94 /* ThrowKeyword */: - case 96 /* TryKeyword */: - case 72 /* DebuggerKeyword */: + case 99 /* VarKeyword */: + case 105 /* LetKeyword */: + case 84 /* FunctionKeyword */: + case 70 /* ClassKeyword */: + case 78 /* EnumKeyword */: + case 85 /* IfKeyword */: + case 76 /* DoKeyword */: + case 101 /* WhileKeyword */: + case 83 /* ForKeyword */: + case 72 /* ContinueKeyword */: + case 67 /* BreakKeyword */: + case 91 /* ReturnKeyword */: + case 102 /* WithKeyword */: + case 93 /* SwitchKeyword */: + case 95 /* ThrowKeyword */: + case 97 /* TryKeyword */: + case 73 /* DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. - case 68 /* CatchKeyword */: - case 81 /* FinallyKeyword */: + case 69 /* CatchKeyword */: + case 82 /* FinallyKeyword */: return true; - case 70 /* ConstKeyword */: - case 78 /* ExportKeyword */: - case 85 /* ImportKeyword */: + case 71 /* ConstKeyword */: + case 79 /* ExportKeyword */: + case 86 /* ImportKeyword */: return isStartOfDeclaration(); - case 115 /* DeclareKeyword */: - case 103 /* InterfaceKeyword */: - case 118 /* ModuleKeyword */: - case 119 /* NamespaceKeyword */: - case 125 /* TypeKeyword */: + case 115 /* AsyncKeyword */: + case 119 /* DeclareKeyword */: + case 104 /* InterfaceKeyword */: + case 122 /* ModuleKeyword */: + case 123 /* NamespaceKeyword */: + case 129 /* TypeKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 108 /* PublicKeyword */: - case 106 /* PrivateKeyword */: - case 107 /* ProtectedKeyword */: - case 109 /* StaticKeyword */: + case 109 /* PublicKeyword */: + case 107 /* PrivateKeyword */: + case 108 /* ProtectedKeyword */: + case 110 /* StaticKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); @@ -10202,7 +10722,7 @@ var ts; return isIdentifier() || token === 14 /* OpenBraceToken */ || token === 18 /* OpenBracketToken */; } function isLetDeclaration() { - // In ES6 'let' always starts a lexical declaration if followed by an identifier or { + // In ES6 'let' always starts a lexical declaration if followed by an identifier or { // or [. return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); } @@ -10212,59 +10732,61 @@ var ts; return parseEmptyStatement(); case 14 /* OpenBraceToken */: return parseBlock(false); - case 98 /* VarKeyword */: + case 99 /* VarKeyword */: return parseVariableStatement(scanner.getStartPos(), undefined, undefined); - case 104 /* LetKeyword */: + case 105 /* LetKeyword */: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), undefined, undefined); } break; - case 83 /* FunctionKeyword */: + case 84 /* FunctionKeyword */: return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); - case 69 /* ClassKeyword */: + case 70 /* ClassKeyword */: return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); - case 84 /* IfKeyword */: + case 85 /* IfKeyword */: return parseIfStatement(); - case 75 /* DoKeyword */: + case 76 /* DoKeyword */: return parseDoStatement(); - case 100 /* WhileKeyword */: + case 101 /* WhileKeyword */: return parseWhileStatement(); - case 82 /* ForKeyword */: + case 83 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 71 /* ContinueKeyword */: - return parseBreakOrContinueStatement(192 /* ContinueStatement */); - case 66 /* BreakKeyword */: - return parseBreakOrContinueStatement(193 /* BreakStatement */); - case 90 /* ReturnKeyword */: + case 72 /* ContinueKeyword */: + return parseBreakOrContinueStatement(199 /* ContinueStatement */); + case 67 /* BreakKeyword */: + return parseBreakOrContinueStatement(200 /* BreakStatement */); + case 91 /* ReturnKeyword */: return parseReturnStatement(); - case 101 /* WithKeyword */: + case 102 /* WithKeyword */: return parseWithStatement(); - case 92 /* SwitchKeyword */: + case 93 /* SwitchKeyword */: return parseSwitchStatement(); - case 94 /* ThrowKeyword */: + case 95 /* ThrowKeyword */: return parseThrowStatement(); - case 96 /* TryKeyword */: + case 97 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. - case 68 /* CatchKeyword */: - case 81 /* FinallyKeyword */: + case 69 /* CatchKeyword */: + case 82 /* FinallyKeyword */: return parseTryStatement(); - case 72 /* DebuggerKeyword */: + case 73 /* DebuggerKeyword */: return parseDebuggerStatement(); - case 52 /* AtToken */: + case 53 /* AtToken */: return parseDeclaration(); - case 103 /* InterfaceKeyword */: - case 125 /* TypeKeyword */: - case 118 /* ModuleKeyword */: - case 119 /* NamespaceKeyword */: - case 115 /* DeclareKeyword */: - case 70 /* ConstKeyword */: - case 77 /* EnumKeyword */: - case 78 /* ExportKeyword */: - case 85 /* ImportKeyword */: - case 106 /* PrivateKeyword */: - case 107 /* ProtectedKeyword */: - case 108 /* PublicKeyword */: - case 109 /* StaticKeyword */: + case 115 /* AsyncKeyword */: + case 104 /* InterfaceKeyword */: + case 129 /* TypeKeyword */: + case 122 /* ModuleKeyword */: + case 123 /* NamespaceKeyword */: + case 119 /* DeclareKeyword */: + case 71 /* ConstKeyword */: + case 78 /* EnumKeyword */: + case 79 /* ExportKeyword */: + case 86 /* ImportKeyword */: + case 107 /* PrivateKeyword */: + case 108 /* ProtectedKeyword */: + case 109 /* PublicKeyword */: + case 112 /* AbstractKeyword */: + case 110 /* StaticKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -10277,35 +10799,35 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token) { - case 98 /* VarKeyword */: - case 104 /* LetKeyword */: - case 70 /* ConstKeyword */: + case 99 /* VarKeyword */: + case 105 /* LetKeyword */: + case 71 /* ConstKeyword */: return parseVariableStatement(fullStart, decorators, modifiers); - case 83 /* FunctionKeyword */: + case 84 /* FunctionKeyword */: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 69 /* ClassKeyword */: + case 70 /* ClassKeyword */: return parseClassDeclaration(fullStart, decorators, modifiers); - case 103 /* InterfaceKeyword */: + case 104 /* InterfaceKeyword */: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 125 /* TypeKeyword */: + case 129 /* TypeKeyword */: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 77 /* EnumKeyword */: + case 78 /* EnumKeyword */: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 118 /* ModuleKeyword */: - case 119 /* NamespaceKeyword */: + case 122 /* ModuleKeyword */: + case 123 /* NamespaceKeyword */: return parseModuleDeclaration(fullStart, decorators, modifiers); - case 85 /* ImportKeyword */: + case 86 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); - case 78 /* ExportKeyword */: + case 79 /* ExportKeyword */: nextToken(); - return token === 73 /* DefaultKeyword */ || token === 53 /* EqualsToken */ ? + return token === 74 /* DefaultKeyword */ || token === 54 /* EqualsToken */ ? parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration - // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var node = createMissingNode(221 /* MissingDeclaration */, true, ts.Diagnostics.Declaration_expected); + // would follow. For recovery and error reporting purposes, return an incomplete declaration. + var node = createMissingNode(228 /* MissingDeclaration */, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -10317,49 +10839,49 @@ var ts; nextToken(); return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 8 /* StringLiteral */); } - function parseFunctionBlockOrSemicolon(isGenerator, diagnosticMessage) { + function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { if (token !== 14 /* OpenBraceToken */ && canParseSemicolon()) { parseSemicolon(); return; } - return parseFunctionBlock(isGenerator, false, diagnosticMessage); + return parseFunctionBlock(isGenerator, isAsync, false, diagnosticMessage); } // DECLARATIONS function parseArrayBindingElement() { if (token === 23 /* CommaToken */) { - return createNode(178 /* OmittedExpression */); + return createNode(184 /* OmittedExpression */); } - var node = createNode(155 /* BindingElement */); + var node = createNode(160 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(21 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); - node.initializer = parseInitializer(false); + node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(155 /* BindingElement */); + var node = createNode(160 /* BindingElement */); // TODO(andersh): Handle computed properties var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token !== 51 /* ColonToken */) { + if (tokenIsIdentifier && token !== 52 /* ColonToken */) { node.name = propertyName; } else { - parseExpected(51 /* ColonToken */); + parseExpected(52 /* ColonToken */); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } - node.initializer = parseInitializer(false); + node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(153 /* ObjectBindingPattern */); + var node = createNode(158 /* ObjectBindingPattern */); parseExpected(14 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(15 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(154 /* ArrayBindingPattern */); + var node = createNode(159 /* ArrayBindingPattern */); parseExpected(18 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(19 /* CloseBracketToken */); @@ -10378,7 +10900,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(201 /* VariableDeclaration */); + var node = createNode(208 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -10387,15 +10909,15 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(202 /* VariableDeclarationList */); + var node = createNode(209 /* VariableDeclarationList */); switch (token) { - case 98 /* VarKeyword */: + case 99 /* VarKeyword */: break; - case 104 /* LetKeyword */: - node.flags |= 4096 /* Let */; + case 105 /* LetKeyword */: + node.flags |= 16384 /* Let */; break; - case 70 /* ConstKeyword */: - node.flags |= 8192 /* Const */; + case 71 /* ConstKeyword */: + node.flags |= 32768 /* Const */; break; default: ts.Debug.fail(); @@ -10410,7 +10932,7 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token === 127 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token === 131 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -10425,7 +10947,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 17 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(183 /* VariableStatement */, fullStart); + var node = createNode(190 /* VariableStatement */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); @@ -10433,38 +10955,42 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(203 /* FunctionDeclaration */, fullStart); + var node = createNode(210 /* FunctionDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(83 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(35 /* AsteriskToken */); - node.name = node.flags & 256 /* Default */ ? parseOptionalIdentifier() : parseIdentifier(); - fillSignature(51 /* ColonToken */, !!node.asteriskToken, false, node); - node.body = parseFunctionBlockOrSemicolon(!!node.asteriskToken, ts.Diagnostics.or_expected); + parseExpected(84 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(36 /* AsteriskToken */); + node.name = node.flags & 1024 /* Default */ ? parseOptionalIdentifier() : parseIdentifier(); + var isGenerator = !!node.asteriskToken; + var isAsync = !!(node.flags & 512 /* Async */); + fillSignature(52 /* ColonToken */, isGenerator, isAsync, false, node); + node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(137 /* Constructor */, pos); + var node = createNode(141 /* Constructor */, pos); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(114 /* ConstructorKeyword */); - fillSignature(51 /* ColonToken */, false, false, node); - node.body = parseFunctionBlockOrSemicolon(false, ts.Diagnostics.or_expected); + parseExpected(118 /* ConstructorKeyword */); + fillSignature(52 /* ColonToken */, 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(136 /* MethodDeclaration */, fullStart); + var method = createNode(140 /* MethodDeclaration */, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; method.name = name; method.questionToken = questionToken; - fillSignature(51 /* ColonToken */, !!asteriskToken, false, method); - method.body = parseFunctionBlockOrSemicolon(!!asteriskToken, diagnosticMessage); + var isGenerator = !!asteriskToken; + var isAsync = !!(method.flags & 512 /* Async */); + fillSignature(52 /* ColonToken */, isGenerator, isAsync, false, method); + method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(134 /* PropertyDeclaration */, fullStart); + var property = createNode(138 /* PropertyDeclaration */, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -10481,16 +11007,16 @@ var ts; // The checker may still error in the static case to explicitly disallow the yield expression. property.initializer = modifiers && modifiers.flags & 128 /* Static */ ? allowInAnd(parseNonParameterInitializer) - : doOutsideOfContext(4 /* Yield */ | 2 /* DisallowIn */, parseNonParameterInitializer); + : doOutsideOfContext(2 /* Yield */ | 1 /* DisallowIn */, parseNonParameterInitializer); parseSemicolon(); return finishNode(property); } function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(35 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(36 /* AsteriskToken */); var name = parsePropertyName(); // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. - var questionToken = parseOptionalToken(50 /* QuestionToken */); + var questionToken = parseOptionalToken(51 /* QuestionToken */); if (asteriskToken || token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } @@ -10506,16 +11032,16 @@ var ts; node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(51 /* ColonToken */, false, false, node); - node.body = parseFunctionBlockOrSemicolon(false); + fillSignature(52 /* ColonToken */, false, false, false, node); + node.body = parseFunctionBlockOrSemicolon(false, false); return finishNode(node); } function isClassMemberModifier(idToken) { switch (idToken) { - case 108 /* PublicKeyword */: - case 106 /* PrivateKeyword */: - case 107 /* ProtectedKeyword */: - case 109 /* StaticKeyword */: + case 109 /* PublicKeyword */: + case 107 /* PrivateKeyword */: + case 108 /* ProtectedKeyword */: + case 110 /* StaticKeyword */: return true; default: return false; @@ -10523,7 +11049,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token === 52 /* AtToken */) { + if (token === 53 /* AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -10540,7 +11066,7 @@ var ts; } nextToken(); } - if (token === 35 /* AsteriskToken */) { + if (token === 36 /* AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -10556,7 +11082,7 @@ var ts; // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 122 /* SetKeyword */ || idToken === 116 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 126 /* SetKeyword */ || idToken === 120 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along @@ -10564,9 +11090,9 @@ var ts; switch (token) { case 16 /* OpenParenToken */: // Method declaration case 24 /* LessThanToken */: // Generic Method declaration - case 51 /* ColonToken */: // Type Annotation for declaration - case 53 /* EqualsToken */: // Initializer for declaration - case 50 /* QuestionToken */: + case 52 /* ColonToken */: // Type Annotation for declaration + case 54 /* EqualsToken */: // Initializer for declaration + case 51 /* QuestionToken */: return true; default: // Covers @@ -10583,14 +11109,14 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(52 /* AtToken */)) { + if (!parseOptional(53 /* AtToken */)) { break; } if (!decorators) { decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(132 /* Decorator */, decoratorStart); + var decorator = createNode(136 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -10621,9 +11147,25 @@ var ts; } return modifiers; } + function parseModifiersForArrowFunction() { + var flags = 0; + var modifiers; + if (token === 115 /* AsyncKeyword */) { + var modifierStart = scanner.getStartPos(); + var modifierKind = token; + nextToken(); + modifiers = []; + modifiers.pos = modifierStart; + flags |= ts.modifierToFlag(modifierKind); + modifiers.push(finishNode(createNode(modifierKind, modifierStart))); + modifiers.flags = flags; + modifiers.end = scanner.getStartPos(); + } + return modifiers; + } function parseClassElement() { if (token === 22 /* SemicolonToken */) { - var result = createNode(181 /* SemicolonClassElement */); + var result = createNode(188 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -10634,7 +11176,7 @@ var ts; if (accessor) { return accessor; } - if (token === 114 /* ConstructorKeyword */) { + if (token === 118 /* ConstructorKeyword */) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -10645,14 +11187,14 @@ var ts; if (isIdentifierOrKeyword() || token === 8 /* StringLiteral */ || token === 7 /* NumericLiteral */ || - token === 35 /* AsteriskToken */ || + token === 36 /* AsteriskToken */ || token === 18 /* OpenBracketToken */) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name_6 = createMissingNode(65 /* Identifier */, true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_6, undefined); + var name_7 = createMissingNode(66 /* Identifier */, true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name_7, undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. ts.Debug.fail("Should not have attempted to parse class member declaration."); @@ -10661,26 +11203,23 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart*/ scanner.getStartPos(), /*decorators*/ undefined, - /*modifiers*/ undefined, 177 /* ClassExpression */); + /*modifiers*/ undefined, 183 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 204 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 211 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(69 /* ClassKeyword */); + parseExpected(70 /* ClassKeyword */); node.name = parseOptionalIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(true); if (parseExpected(14 /* OpenBraceToken */)) { - // ClassTail[Yield,GeneratorParameter] : See 14.5 - // [~GeneratorParameter]ClassHeritage[?Yield]opt { ClassBody[?Yield]opt } - // [+GeneratorParameter] ClassHeritageopt { ClassBodyopt } - node.members = inGeneratorParameterContext() - ? doOutsideOfYieldContext(parseClassMembers) - : parseClassMembers(); + // ClassTail[Yield,Await] : (Modified) See 14.5 + // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } + node.members = parseClassMembers(); parseExpected(15 /* CloseBraceToken */); } else { @@ -10689,22 +11228,19 @@ var ts; return finishNode(node); } function parseHeritageClauses(isClassHeritageClause) { - // ClassTail[Yield,GeneratorParameter] : See 14.5 - // [~GeneratorParameter]ClassHeritage[?Yield]opt { ClassBody[?Yield]opt } - // [+GeneratorParameter] ClassHeritageopt { ClassBodyopt } + // ClassTail[Yield,Await] : (Modified) See 14.5 + // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } if (isHeritageClause()) { - return isClassHeritageClause && inGeneratorParameterContext() - ? doOutsideOfYieldContext(parseHeritageClausesWorker) - : parseHeritageClausesWorker(); + return parseList(20 /* HeritageClauses */, parseHeritageClause); } return undefined; } function parseHeritageClausesWorker() { - return parseList(18 /* HeritageClauses */, parseHeritageClause); + return parseList(20 /* HeritageClauses */, parseHeritageClause); } function parseHeritageClause() { - if (token === 79 /* ExtendsKeyword */ || token === 102 /* ImplementsKeyword */) { - var node = createNode(225 /* HeritageClause */); + if (token === 80 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */) { + var node = createNode(240 /* HeritageClause */); node.token = token; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); @@ -10713,24 +11249,24 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(179 /* ExpressionWithTypeArguments */); + var node = createNode(185 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === 24 /* LessThanToken */) { - node.typeArguments = parseBracketedList(16 /* TypeArguments */, parseType, 24 /* LessThanToken */, 25 /* GreaterThanToken */); + node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 24 /* LessThanToken */, 26 /* GreaterThanToken */); } return finishNode(node); } function isHeritageClause() { - return token === 79 /* ExtendsKeyword */ || token === 102 /* ImplementsKeyword */; + return token === 80 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(205 /* InterfaceDeclaration */, fullStart); + var node = createNode(212 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(103 /* InterfaceKeyword */); + parseExpected(104 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(false); @@ -10738,13 +11274,13 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(206 /* TypeAliasDeclaration */, fullStart); + var node = createNode(213 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(125 /* TypeKeyword */); + parseExpected(129 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(53 /* EqualsToken */); + parseExpected(54 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return finishNode(node); @@ -10754,16 +11290,16 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNode(229 /* EnumMember */, scanner.getStartPos()); + var node = createNode(244 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(207 /* EnumDeclaration */, fullStart); + var node = createNode(214 /* EnumDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(77 /* EnumKeyword */); + parseExpected(78 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(14 /* OpenBraceToken */)) { node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); @@ -10775,7 +11311,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(209 /* ModuleBlock */, scanner.getStartPos()); + var node = createNode(216 /* ModuleBlock */, scanner.getStartPos()); if (parseExpected(14 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(15 /* CloseBraceToken */); @@ -10786,7 +11322,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(208 /* ModuleDeclaration */, fullStart); + var node = createNode(215 /* ModuleDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; @@ -10797,7 +11333,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(208 /* ModuleDeclaration */, fullStart); + var node = createNode(215 /* ModuleDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(true); @@ -10806,11 +11342,11 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(119 /* NamespaceKeyword */)) { - flags |= 32768 /* Namespace */; + if (parseOptional(123 /* NamespaceKeyword */)) { + flags |= 131072 /* Namespace */; } else { - parseExpected(118 /* ModuleKeyword */); + parseExpected(122 /* ModuleKeyword */); if (token === 8 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -10818,62 +11354,65 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 120 /* RequireKeyword */ && + return token === 124 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { return nextToken() === 16 /* OpenParenToken */; } + function nextTokenIsSlash() { + return nextToken() === 37 /* SlashToken */; + } function nextTokenIsCommaOrFromKeyword() { nextToken(); return token === 23 /* CommaToken */ || - token === 126 /* FromKeyword */; + token === 130 /* FromKeyword */; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(85 /* ImportKeyword */); + parseExpected(86 /* ImportKeyword */); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 23 /* CommaToken */ && token !== 126 /* FromKeyword */) { + if (token !== 23 /* CommaToken */ && token !== 130 /* FromKeyword */) { // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(211 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(218 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; - parseExpected(53 /* EqualsToken */); + parseExpected(54 /* EqualsToken */); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(importEqualsDeclaration); } } // Import statement - var importDeclaration = createNode(212 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(219 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; if (identifier || - token === 35 /* AsteriskToken */ || + token === 36 /* AsteriskToken */ || token === 14 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(126 /* FromKeyword */); + parseExpected(130 /* FromKeyword */); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - //ImportClause: + // ImportClause: // ImportedDefaultBinding // NameSpaceImport // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(213 /* ImportClause */, fullStart); + var importClause = createNode(220 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -10883,7 +11422,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(23 /* CommaToken */)) { - importClause.namedBindings = token === 35 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(215 /* NamedImports */); + importClause.namedBindings = token === 36 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(222 /* NamedImports */); } return finishNode(importClause); } @@ -10893,8 +11432,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(222 /* ExternalModuleReference */); - parseExpected(120 /* RequireKeyword */); + var node = createNode(229 /* ExternalModuleReference */); + parseExpected(124 /* RequireKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = parseModuleSpecifier(); parseExpected(17 /* CloseParenToken */); @@ -10915,9 +11454,9 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(214 /* NamespaceImport */); - parseExpected(35 /* AsteriskToken */); - parseExpected(111 /* AsKeyword */); + var namespaceImport = createNode(221 /* NamespaceImport */); + parseExpected(36 /* AsteriskToken */); + parseExpected(113 /* AsKeyword */); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } @@ -10930,14 +11469,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(19 /* ImportOrExportSpecifiers */, kind === 215 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 14 /* OpenBraceToken */, 15 /* CloseBraceToken */); + node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 222 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 14 /* OpenBraceToken */, 15 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(220 /* ExportSpecifier */); + return parseImportOrExportSpecifier(227 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(216 /* ImportSpecifier */); + return parseImportOrExportSpecifier(223 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -10951,9 +11490,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token === 111 /* AsKeyword */) { + if (token === 113 /* AsKeyword */) { node.propertyName = identifierName; - parseExpected(111 /* AsKeyword */); + parseExpected(113 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -10962,23 +11501,23 @@ var ts; else { node.name = identifierName; } - if (kind === 216 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 223 /* ImportSpecifier */ && checkIdentifierIsKeyword) { // Report error identifier expected parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(218 /* ExportDeclaration */, fullStart); + var node = createNode(225 /* ExportDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(35 /* AsteriskToken */)) { - parseExpected(126 /* FromKeyword */); + if (parseOptional(36 /* AsteriskToken */)) { + parseExpected(130 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(219 /* NamedExports */); - if (parseOptional(126 /* FromKeyword */)) { + node.exportClause = parseNamedImportsOrExports(226 /* NamedExports */); + if (parseOptional(130 /* FromKeyword */)) { node.moduleSpecifier = parseModuleSpecifier(); } } @@ -10986,21 +11525,21 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(217 /* ExportAssignment */, fullStart); + var node = createNode(224 /* ExportAssignment */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(53 /* EqualsToken */)) { + if (parseOptional(54 /* EqualsToken */)) { node.isExportEquals = true; } else { - parseExpected(73 /* DefaultKeyword */); + parseExpected(74 /* DefaultKeyword */); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); return finishNode(node); } function processReferenceComments(sourceFile) { - var triviaScanner = ts.createScanner(sourceFile.languageVersion, false, sourceText); + var triviaScanner = ts.createScanner(sourceFile.languageVersion, false, 0 /* Standard */, sourceText); var referencedFiles = []; var amdDependencies = []; var amdModuleName; @@ -11059,10 +11598,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 /* Export */ - || node.kind === 211 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 222 /* ExternalModuleReference */ - || node.kind === 212 /* ImportDeclaration */ - || node.kind === 217 /* ExportAssignment */ - || node.kind === 218 /* ExportDeclaration */ + || node.kind === 218 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 229 /* ExternalModuleReference */ + || node.kind === 219 /* ImportDeclaration */ + || node.kind === 224 /* ExportAssignment */ + || node.kind === 225 /* ExportDeclaration */ ? node : undefined; }); @@ -11082,18 +11621,20 @@ var ts; ParsingContext[ParsingContext["ArrayBindingElements"] = 10] = "ArrayBindingElements"; ParsingContext[ParsingContext["ArgumentExpressions"] = 11] = "ArgumentExpressions"; ParsingContext[ParsingContext["ObjectLiteralMembers"] = 12] = "ObjectLiteralMembers"; - ParsingContext[ParsingContext["ArrayLiteralMembers"] = 13] = "ArrayLiteralMembers"; - ParsingContext[ParsingContext["Parameters"] = 14] = "Parameters"; - ParsingContext[ParsingContext["TypeParameters"] = 15] = "TypeParameters"; - ParsingContext[ParsingContext["TypeArguments"] = 16] = "TypeArguments"; - ParsingContext[ParsingContext["TupleElementTypes"] = 17] = "TupleElementTypes"; - ParsingContext[ParsingContext["HeritageClauses"] = 18] = "HeritageClauses"; - ParsingContext[ParsingContext["ImportOrExportSpecifiers"] = 19] = "ImportOrExportSpecifiers"; - ParsingContext[ParsingContext["JSDocFunctionParameters"] = 20] = "JSDocFunctionParameters"; - ParsingContext[ParsingContext["JSDocTypeArguments"] = 21] = "JSDocTypeArguments"; - ParsingContext[ParsingContext["JSDocRecordMembers"] = 22] = "JSDocRecordMembers"; - ParsingContext[ParsingContext["JSDocTupleTypes"] = 23] = "JSDocTupleTypes"; - ParsingContext[ParsingContext["Count"] = 24] = "Count"; // Number of parsing contexts + ParsingContext[ParsingContext["JsxAttributes"] = 13] = "JsxAttributes"; + ParsingContext[ParsingContext["JsxChildren"] = 14] = "JsxChildren"; + ParsingContext[ParsingContext["ArrayLiteralMembers"] = 15] = "ArrayLiteralMembers"; + ParsingContext[ParsingContext["Parameters"] = 16] = "Parameters"; + ParsingContext[ParsingContext["TypeParameters"] = 17] = "TypeParameters"; + ParsingContext[ParsingContext["TypeArguments"] = 18] = "TypeArguments"; + ParsingContext[ParsingContext["TupleElementTypes"] = 19] = "TupleElementTypes"; + ParsingContext[ParsingContext["HeritageClauses"] = 20] = "HeritageClauses"; + ParsingContext[ParsingContext["ImportOrExportSpecifiers"] = 21] = "ImportOrExportSpecifiers"; + ParsingContext[ParsingContext["JSDocFunctionParameters"] = 22] = "JSDocFunctionParameters"; + ParsingContext[ParsingContext["JSDocTypeArguments"] = 23] = "JSDocTypeArguments"; + ParsingContext[ParsingContext["JSDocRecordMembers"] = 24] = "JSDocRecordMembers"; + ParsingContext[ParsingContext["JSDocTupleTypes"] = 25] = "JSDocTupleTypes"; + ParsingContext[ParsingContext["Count"] = 26] = "Count"; // Number of parsing contexts })(ParsingContext || (ParsingContext = {})); var Tristate; (function (Tristate) { @@ -11105,16 +11646,16 @@ var ts; (function (JSDocParser) { function isJSDocType() { switch (token) { - case 35 /* AsteriskToken */: - case 50 /* QuestionToken */: + case 36 /* AsteriskToken */: + case 51 /* QuestionToken */: case 16 /* OpenParenToken */: case 18 /* OpenBracketToken */: - case 46 /* ExclamationToken */: + case 47 /* ExclamationToken */: case 14 /* OpenBraceToken */: - case 83 /* FunctionKeyword */: + case 84 /* FunctionKeyword */: case 21 /* DotDotDotToken */: - case 88 /* NewKeyword */: - case 93 /* ThisKeyword */: + case 89 /* NewKeyword */: + case 94 /* ThisKeyword */: return true; } return isIdentifierOrKeyword(); @@ -11135,7 +11676,7 @@ var ts; scanner.setText(sourceText, start, length); // Prime the first token for us to start processing. token = nextToken(); - var result = createNode(231 /* JSDocTypeExpression */); + var result = createNode(246 /* JSDocTypeExpression */); parseExpected(14 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); parseExpected(15 /* CloseBraceToken */); @@ -11145,13 +11686,13 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token === 44 /* BarToken */) { - var unionType = createNode(235 /* JSDocUnionType */, type.pos); + if (token === 45 /* BarToken */) { + var unionType = createNode(250 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token === 53 /* EqualsToken */) { - var optionalType = createNode(242 /* JSDocOptionalType */, type.pos); + if (token === 54 /* EqualsToken */) { + var optionalType = createNode(257 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -11162,20 +11703,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token === 18 /* OpenBracketToken */) { - var arrayType = createNode(234 /* JSDocArrayType */, type.pos); + var arrayType = createNode(249 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); parseExpected(19 /* CloseBracketToken */); type = finishNode(arrayType); } - else if (token === 50 /* QuestionToken */) { - var nullableType = createNode(237 /* JSDocNullableType */, type.pos); + else if (token === 51 /* QuestionToken */) { + var nullableType = createNode(252 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token === 46 /* ExclamationToken */) { - var nonNullableType = createNode(238 /* JSDocNonNullableType */, type.pos); + else if (token === 47 /* ExclamationToken */) { + var nonNullableType = createNode(253 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -11188,82 +11729,82 @@ var ts; } function parseBasicTypeExpression() { switch (token) { - case 35 /* AsteriskToken */: + case 36 /* AsteriskToken */: return parseJSDocAllType(); - case 50 /* QuestionToken */: + case 51 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); case 16 /* OpenParenToken */: return parseJSDocUnionType(); case 18 /* OpenBracketToken */: return parseJSDocTupleType(); - case 46 /* ExclamationToken */: + case 47 /* ExclamationToken */: return parseJSDocNonNullableType(); case 14 /* OpenBraceToken */: return parseJSDocRecordType(); - case 83 /* FunctionKeyword */: + case 84 /* FunctionKeyword */: return parseJSDocFunctionType(); case 21 /* DotDotDotToken */: return parseJSDocVariadicType(); - case 88 /* NewKeyword */: + case 89 /* NewKeyword */: return parseJSDocConstructorType(); - case 93 /* ThisKeyword */: + case 94 /* ThisKeyword */: return parseJSDocThisType(); - case 112 /* AnyKeyword */: - case 123 /* StringKeyword */: - case 121 /* NumberKeyword */: - case 113 /* BooleanKeyword */: - case 124 /* SymbolKeyword */: - case 99 /* VoidKeyword */: + case 114 /* AnyKeyword */: + case 127 /* StringKeyword */: + case 125 /* NumberKeyword */: + case 117 /* BooleanKeyword */: + case 128 /* SymbolKeyword */: + case 100 /* VoidKeyword */: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(246 /* JSDocThisType */); + var result = createNode(261 /* JSDocThisType */); nextToken(); - parseExpected(51 /* ColonToken */); + parseExpected(52 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(245 /* JSDocConstructorType */); + var result = createNode(260 /* JSDocConstructorType */); nextToken(); - parseExpected(51 /* ColonToken */); + parseExpected(52 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(244 /* JSDocVariadicType */); + var result = createNode(259 /* JSDocVariadicType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(243 /* JSDocFunctionType */); + var result = createNode(258 /* JSDocFunctionType */); nextToken(); parseExpected(16 /* OpenParenToken */); - result.parameters = parseDelimitedList(20 /* JSDocFunctionParameters */, parseJSDocParameter); + result.parameters = parseDelimitedList(22 /* JSDocFunctionParameters */, parseJSDocParameter); checkForTrailingComma(result.parameters); parseExpected(17 /* CloseParenToken */); - if (token === 51 /* ColonToken */) { + if (token === 52 /* ColonToken */) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(131 /* Parameter */); + var parameter = createNode(135 /* Parameter */); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type) { - var result = createNode(242 /* JSDocOptionalType */, type.pos); + var result = createNode(257 /* JSDocOptionalType */, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference() { - var result = createNode(241 /* JSDocTypeReference */); + var result = createNode(256 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); while (parseOptional(20 /* DotToken */)) { if (token === 24 /* LessThanToken */) { @@ -11279,10 +11820,10 @@ var ts; function parseTypeArguments() { // Move past the < nextToken(); - var typeArguments = parseDelimitedList(21 /* JSDocTypeArguments */, parseJSDocType); + var typeArguments = parseDelimitedList(23 /* JSDocTypeArguments */, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); - parseExpected(25 /* GreaterThanToken */); + parseExpected(26 /* GreaterThanToken */); return typeArguments; } function checkForEmptyTypeArgumentList(typeArguments) { @@ -11293,38 +11834,38 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(128 /* QualifiedName */, left.pos); + var result = createNode(132 /* QualifiedName */, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(239 /* JSDocRecordType */); + var result = createNode(254 /* JSDocRecordType */); nextToken(); - result.members = parseDelimitedList(22 /* JSDocRecordMembers */, parseJSDocRecordMember); + result.members = parseDelimitedList(24 /* JSDocRecordMembers */, parseJSDocRecordMember); checkForTrailingComma(result.members); parseExpected(15 /* CloseBraceToken */); return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(240 /* JSDocRecordMember */); + var result = createNode(255 /* JSDocRecordMember */); result.name = parseSimplePropertyName(); - if (token === 51 /* ColonToken */) { + if (token === 52 /* ColonToken */) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(238 /* JSDocNonNullableType */); + var result = createNode(253 /* JSDocNonNullableType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(236 /* JSDocTupleType */); + var result = createNode(251 /* JSDocTupleType */); nextToken(); - result.types = parseDelimitedList(23 /* JSDocTupleTypes */, parseJSDocType); + result.types = parseDelimitedList(25 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); parseExpected(19 /* CloseBracketToken */); return finishNode(result); @@ -11336,7 +11877,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(235 /* JSDocUnionType */); + var result = createNode(250 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(17 /* CloseParenToken */); @@ -11347,14 +11888,14 @@ var ts; var types = []; types.pos = firstType.pos; types.push(firstType); - while (parseOptional(44 /* BarToken */)) { + while (parseOptional(45 /* BarToken */)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); return types; } function parseJSDocAllType() { - var result = createNode(232 /* JSDocAllType */); + var result = createNode(247 /* JSDocAllType */); nextToken(); return finishNode(result); } @@ -11374,14 +11915,14 @@ var ts; if (token === 23 /* CommaToken */ || token === 15 /* CloseBraceToken */ || token === 17 /* CloseParenToken */ || - token === 25 /* GreaterThanToken */ || - token === 53 /* EqualsToken */ || - token === 44 /* BarToken */) { - var result = createNode(233 /* JSDocUnknownType */, pos); + token === 26 /* GreaterThanToken */ || + token === 54 /* EqualsToken */ || + token === 45 /* BarToken */) { + var result = createNode(248 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(237 /* JSDocNullableType */, pos); + var result = createNode(252 /* JSDocNullableType */, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -11413,8 +11954,8 @@ var ts; ts.Debug.assert(end <= content.length); var tags; var pos; - // NOTE(cyrusn): This is essentially a handwritten scanner for JSDocComments. I - // considered using an actual Scanner, but this would complicate things. The + // NOTE(cyrusn): This is essentially a handwritten scanner for JSDocComments. I + // considered using an actual Scanner, but this would complicate things. The // scanner would need to know it was in a Doc Comment. Otherwise, it would then // produce comments *inside* the doc comment. In the end it was just easier to // write a simple scanner rather than go that route. @@ -11469,7 +12010,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(247 /* JSDocComment */, start); + var result = createNode(262 /* JSDocComment */, start); result.tags = tags; return finishNode(result, end); } @@ -11480,9 +12021,8 @@ var ts; } function parseTag() { ts.Debug.assert(content.charCodeAt(pos - 1) === 64 /* at */); - var atToken = createNode(52 /* AtToken */, pos - 1); + var atToken = createNode(53 /* AtToken */, pos - 1); atToken.end = pos; - var startPos = pos; var tagName = scanIdentifier(); if (!tagName) { return; @@ -11507,7 +12047,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(248 /* JSDocTag */, atToken.pos); + var result = createNode(263 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -11559,7 +12099,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(249 /* JSDocParameterTag */, atToken.pos); + var result = createNode(264 /* JSDocParameterTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -11569,27 +12109,27 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 250 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 265 /* JSDocReturnTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(250 /* JSDocReturnTag */, atToken.pos); + var result = createNode(265 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 251 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 266 /* JSDocTypeTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(251 /* JSDocTypeTag */, atToken.pos); + var result = createNode(266 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 252 /* JSDocTemplateTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 267 /* JSDocTemplateTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = []; @@ -11597,13 +12137,13 @@ var ts; while (true) { skipWhitespace(); var startPos = pos; - var name_7 = scanIdentifier(); - if (!name_7) { + var name_8 = scanIdentifier(); + if (!name_8) { parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(130 /* TypeParameter */, name_7.pos); - typeParameter.name = name_7; + var typeParameter = createNode(134 /* TypeParameter */, name_8.pos); + typeParameter.name = name_8; finishNode(typeParameter, pos); typeParameters.push(typeParameter); skipWhitespace(); @@ -11613,7 +12153,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(252 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(267 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -11634,7 +12174,7 @@ var ts; if (startPos === pos) { return undefined; } - var result = createNode(65 /* Identifier */, startPos); + var result = createNode(66 /* Identifier */, startPos); result.text = content.substring(startPos, pos); return finishNode(result, pos); } @@ -11723,8 +12263,9 @@ var ts; } return; function visitNode(node) { + var text = ''; if (aggressiveChecks && shouldCheckNode(node)) { - var text = oldText.substring(node.pos, node.end); + text = oldText.substring(node.pos, node.end); } // Ditch any existing LS children we may have created. This way we can avoid // moving them forward. @@ -11756,7 +12297,7 @@ var ts; switch (node.kind) { case 8 /* StringLiteral */: case 7 /* NumericLiteral */: - case 65 /* Identifier */: + case 66 /* Identifier */: return true; } return false; @@ -12135,6 +12676,16 @@ var ts; } ts.getSymbolId = getSymbolId; function createTypeChecker(host, produceDiagnostics) { + // Cancellation that controls whether or not we can cancel in the middle of type checking. + // In general cancelling is *not* safe for the type checker. We might be in the middle of + // computing something, and we will leave our internals in an inconsistent state. Callers + // who set the cancellation token should catch if a cancellation exception occurs, and + // should throw away and create a new TypeChecker. + // + // Currently we only support setting the cancellation token when getting diagnostics. This + // is because diagnostics can be quite expensive, and we want to allow hosts to bail out if + // they no longer need the information (for example, if the user started editing again). + var cancellationToken; var Symbol = ts.objectAllocator.getSymbolConstructor(); var Type = ts.objectAllocator.getTypeConstructor(); var Signature = ts.objectAllocator.getSignatureConstructor(); @@ -12180,7 +12731,9 @@ var ts; isImplementationOfOverload: isImplementationOfOverload, getAliasedSymbol: resolveAlias, getEmitResolver: getEmitResolver, - getExportsOfModule: getExportsOfModuleAsArray + getExportsOfModule: getExportsOfModuleAsArray, + getJsxElementAttributesType: getJsxElementAttributesType, + getJsxIntrinsicTagNames: getJsxIntrinsicTagNames }; var unknownSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "unknown"); var resolvingSymbol = createSymbol(67108864 /* Transient */, "__resolving__"); @@ -12188,10 +12741,10 @@ var ts; var stringType = createIntrinsicType(2 /* String */, "string"); var numberType = createIntrinsicType(4 /* Number */, "number"); var booleanType = createIntrinsicType(8 /* Boolean */, "boolean"); - var esSymbolType = createIntrinsicType(2097152 /* ESSymbol */, "symbol"); + var esSymbolType = createIntrinsicType(4194304 /* ESSymbol */, "symbol"); var voidType = createIntrinsicType(16 /* Void */, "void"); - var undefinedType = createIntrinsicType(32 /* Undefined */ | 524288 /* ContainsUndefinedOrNull */, "undefined"); - var nullType = createIntrinsicType(64 /* Null */ | 524288 /* ContainsUndefinedOrNull */, "null"); + var undefinedType = createIntrinsicType(32 /* Undefined */ | 1048576 /* ContainsUndefinedOrNull */, "undefined"); + var nullType = createIntrinsicType(64 /* Null */ | 1048576 /* ContainsUndefinedOrNull */, "null"); var unknownType = createIntrinsicType(1 /* Any */, "unknown"); var circularType = createIntrinsicType(1 /* Any */, "__circular__"); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); @@ -12203,6 +12756,7 @@ var ts; var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); var globals = {}; var globalESSymbolConstructorSymbol; + var getGlobalPromiseConstructorSymbol; var globalObjectType; var globalFunctionType; var globalArrayType; @@ -12212,23 +12766,40 @@ var ts; var globalRegExpType; var globalTemplateStringsArrayType; var globalESSymbolType; + var jsxElementType; + /** Lazily loaded, use getJsxIntrinsicElementType() */ + var jsxIntrinsicElementsType; var globalIterableType; var globalIteratorType; var globalIterableIteratorType; var anyArrayType; + var getGlobalClassDecoratorType; + var getGlobalParameterDecoratorType; + var getGlobalPropertyDecoratorType; + var getGlobalMethodDecoratorType; var getGlobalTypedPropertyDescriptorType; + var getGlobalPromiseType; + var tryGetGlobalPromiseType; + var getGlobalPromiseLikeType; + var getInstantiatedGlobalPromiseLikeType; + var getGlobalPromiseConstructorLikeType; + var getGlobalThenableType; var tupleTypes = {}; var unionTypes = {}; + var intersectionTypes = {}; var stringLiteralTypes = {}; var emitExtends = false; var emitDecorate = false; var emitParam = false; + var emitAwaiter = false; + var emitGenerator = false; var resolutionTargets = []; var resolutionResults = []; var mergedSymbols = []; var symbolLinks = []; var nodeLinks = []; var potentialThisCollisions = []; + var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); var primitiveTypeInfo = { "string": { @@ -12245,18 +12816,25 @@ var ts; }, "symbol": { type: esSymbolType, - flags: 2097152 /* ESSymbol */ + flags: 4194304 /* ESSymbol */ } }; + var JsxNames = { + JSX: "JSX", + IntrinsicElements: "IntrinsicElements", + ElementClass: "ElementClass", + ElementAttributesPropertyNameContainer: "ElementAttributesProperty", + Element: "Element" + }; var subtypeRelation = {}; var assignableRelation = {}; var identityRelation = {}; initializeTypeChecker(); return checker; - function getEmitResolver(sourceFile) { + function getEmitResolver(sourceFile, cancellationToken) { // Ensure we have all the type information in place for this file so that all the // emitter questions of this resolver will return the right information. - getDiagnostics(sourceFile); + getDiagnostics(sourceFile, cancellationToken); return emitResolver; } function error(location, message, arg0, arg1, arg2) { @@ -12281,9 +12859,9 @@ var ts; if (flags & 16 /* Function */) result |= 106927 /* FunctionExcludes */; if (flags & 32 /* Class */) - result |= 899583 /* ClassExcludes */; + result |= 899519 /* ClassExcludes */; if (flags & 64 /* Interface */) - result |= 792992 /* InterfaceExcludes */; + result |= 792960 /* InterfaceExcludes */; if (flags & 256 /* RegularEnum */) result |= 899327 /* RegularEnumExcludes */; if (flags & 128 /* ConstEnum */) @@ -12395,10 +12973,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 230 /* SourceFile */); + return ts.getAncestor(node, 245 /* SourceFile */); } function isGlobalSourceFile(node) { - return node.kind === 230 /* SourceFile */ && !ts.isExternalModule(node); + return node.kind === 245 /* SourceFile */ && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -12455,13 +13033,13 @@ var ts; } } switch (location.kind) { - case 230 /* SourceFile */: + case 245 /* SourceFile */: if (!ts.isExternalModule(location)) break; - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 230 /* SourceFile */ || - (location.kind === 208 /* ModuleDeclaration */ && location.name.kind === 8 /* StringLiteral */)) { + if (location.kind === 245 /* SourceFile */ || + (location.kind === 215 /* ModuleDeclaration */ && location.name.kind === 8 /* StringLiteral */)) { // It's an external module. Because of module/namespace merging, a module's exports are in scope, // yet we never want to treat an export specifier as putting a member in scope. Therefore, // if the name we find is purely an export specifier, it is not actually considered in scope. @@ -12475,7 +13053,7 @@ var ts; // which is not the desired behavior. if (ts.hasProperty(moduleExports, name) && moduleExports[name].flags === 8388608 /* Alias */ && - ts.getDeclarationOfKind(moduleExports[name], 220 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExports[name], 227 /* ExportSpecifier */)) { break; } result = moduleExports["default"]; @@ -12489,13 +13067,13 @@ var ts; break loop; } break; - case 207 /* EnumDeclaration */: + case 214 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -12512,9 +13090,9 @@ var ts; } } break; - case 204 /* ClassDeclaration */: - case 177 /* ClassExpression */: - case 205 /* InterfaceDeclaration */: + case 211 /* ClassDeclaration */: + case 183 /* ClassExpression */: + case 212 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056 /* Type */)) { if (lastLocation && lastLocation.flags & 128 /* Static */) { // TypeScript 1.0 spec (April 2014): 3.4.1 @@ -12525,7 +13103,7 @@ var ts; } break loop; } - if (location.kind === 177 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 183 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -12541,9 +13119,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 129 /* ComputedPropertyName */: + case 133 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 205 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 212 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -12551,19 +13129,19 @@ var ts; } } break; - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 137 /* Constructor */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 203 /* FunctionDeclaration */: - case 166 /* ArrowFunction */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 141 /* Constructor */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 210 /* FunctionDeclaration */: + case 171 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 165 /* FunctionExpression */: + case 170 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -12576,8 +13154,8 @@ var ts; } } break; - case 132 /* Decorator */: - // Decorators are resolved at the class declaration. Resolving at the parameter + case 136 /* Decorator */: + // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // // function y() {} @@ -12585,7 +13163,7 @@ var ts; // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. // } // - if (location.parent && location.parent.kind === 131 /* Parameter */) { + if (location.parent && location.parent.kind === 135 /* Parameter */) { location = location.parent; } // @@ -12641,16 +13219,16 @@ var ts; // for (let x in x) // for (let x of x) // climb up to the variable declaration skipping binding patterns - var variableDeclaration = ts.getAncestor(declaration, 201 /* VariableDeclaration */); + var variableDeclaration = ts.getAncestor(declaration, 208 /* VariableDeclaration */); var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 183 /* VariableStatement */ || - variableDeclaration.parent.parent.kind === 189 /* ForStatement */) { + if (variableDeclaration.parent.parent.kind === 190 /* VariableStatement */ || + variableDeclaration.parent.parent.kind === 196 /* ForStatement */) { // variable statement/for statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); } - else if (variableDeclaration.parent.parent.kind === 191 /* ForOfStatement */ || - variableDeclaration.parent.parent.kind === 190 /* ForInStatement */) { + else if (variableDeclaration.parent.parent.kind === 198 /* ForOfStatement */ || + variableDeclaration.parent.parent.kind === 197 /* ForInStatement */) { // ForIn/ForOf case - use site should not be used in expression part var expression = variableDeclaration.parent.parent.expression; isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); @@ -12677,10 +13255,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 211 /* ImportEqualsDeclaration */) { + if (node.kind === 218 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 212 /* ImportDeclaration */) { + while (node && node.kind !== 219 /* ImportDeclaration */) { node = node.parent; } return node; @@ -12690,7 +13268,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 222 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 229 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -12770,15 +13348,15 @@ var ts; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); if (targetSymbol) { - var name_8 = specifier.propertyName || specifier.name; - if (name_8.text) { - var symbolFromModule = getExportOfModule(targetSymbol, name_8.text); - var symbolFromVariable = getPropertyOfVariable(targetSymbol, name_8.text); + var name_9 = specifier.propertyName || specifier.name; + if (name_9.text) { + var symbolFromModule = getExportOfModule(targetSymbol, name_9.text); + var symbolFromVariable = getPropertyOfVariable(targetSymbol, name_9.text); var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable; if (!symbol) { - error(name_8, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_8)); + error(name_9, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_9)); } return symbol; } @@ -12797,17 +13375,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 211 /* ImportEqualsDeclaration */: + case 218 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 213 /* ImportClause */: + case 220 /* ImportClause */: return getTargetOfImportClause(node); - case 214 /* NamespaceImport */: + case 221 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 216 /* ImportSpecifier */: + case 223 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 220 /* ExportSpecifier */: + case 227 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 217 /* ExportAssignment */: + case 224 /* ExportAssignment */: return getTargetOfExportAssignment(node); } } @@ -12852,11 +13430,11 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 217 /* ExportAssignment */) { + if (node.kind === 224 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 220 /* ExportSpecifier */) { + else if (node.kind === 227 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -12869,7 +13447,7 @@ var ts; // This function is only for imports with entity names function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 211 /* ImportEqualsDeclaration */); + importDeclaration = ts.getAncestor(entityName, 218 /* ImportEqualsDeclaration */); ts.Debug.assert(importDeclaration !== undefined); } // There are three things we might try to look for. In the following examples, @@ -12878,17 +13456,17 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 65 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 66 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 65 /* Identifier */ || entityName.parent.kind === 128 /* QualifiedName */) { + if (entityName.kind === 66 /* Identifier */ || entityName.parent.kind === 132 /* QualifiedName */) { return resolveEntityName(entityName, 1536 /* Namespace */); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 211 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 218 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); } } @@ -12896,28 +13474,30 @@ var ts; return symbol.parent ? getFullyQualifiedName(symbol.parent) + "." + symbolToString(symbol) : symbolToString(symbol); } // Resolves a qualified name and any involved aliases - function resolveEntityName(name, meaning) { + function resolveEntityName(name, meaning, ignoreErrors) { if (ts.nodeIsMissing(name)) { return undefined; } var symbol; - if (name.kind === 65 /* Identifier */) { + if (name.kind === 66 /* Identifier */) { var message = meaning === 1536 /* Namespace */ ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; - symbol = resolveName(name, name.text, meaning, message, name); + symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 128 /* QualifiedName */ || name.kind === 158 /* PropertyAccessExpression */) { - var left = name.kind === 128 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 128 /* QualifiedName */ ? name.right : name.name; - var namespace = resolveEntityName(left, 1536 /* Namespace */); + else if (name.kind === 132 /* QualifiedName */ || name.kind === 163 /* PropertyAccessExpression */) { + var left = name.kind === 132 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 132 /* QualifiedName */ ? name.right : name.name; + var namespace = resolveEntityName(left, 1536 /* Namespace */, ignoreErrors); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; } symbol = getSymbol(getExportsOfSymbol(namespace), right.text, meaning); if (!symbol) { - error(right, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(namespace), ts.declarationNameToString(right)); + if (!ignoreErrors) { + error(right, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(namespace), ts.declarationNameToString(right)); + } return undefined; } } @@ -13071,7 +13651,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 137 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 141 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -13129,7 +13709,7 @@ var ts; return type; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { - return setObjectTypeMembers(createObjectType(32768 /* Anonymous */, symbol), members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + return setObjectTypeMembers(createObjectType(65536 /* Anonymous */, symbol), members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; @@ -13141,17 +13721,17 @@ var ts; } } switch (location_1.kind) { - case 230 /* SourceFile */: + case 245 /* SourceFile */: if (!ts.isExternalModule(location_1)) { break; } - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 204 /* ClassDeclaration */: - case 205 /* InterfaceDeclaration */: + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -13190,7 +13770,9 @@ var ts; } // Check if symbol is any of the alias return ts.forEachValue(symbols, function (symbolFromSymbolTable) { - if (symbolFromSymbolTable.flags & 8388608 /* Alias */ && symbolFromSymbolTable.name !== "export=") { + if (symbolFromSymbolTable.flags & 8388608 /* Alias */ + && symbolFromSymbolTable.name !== "export=" + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 227 /* ExportSpecifier */)) { if (!useOnlyExternalAliasing || // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { @@ -13227,7 +13809,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 227 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -13300,8 +13882,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 208 /* ModuleDeclaration */ && declaration.name.kind === 8 /* StringLiteral */) || - (declaration.kind === 230 /* SourceFile */ && ts.isExternalModule(declaration)); + return (declaration.kind === 215 /* ModuleDeclaration */ && declaration.name.kind === 8 /* StringLiteral */) || + (declaration.kind === 245 /* SourceFile */ && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -13337,12 +13919,12 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 147 /* TypeQuery */) { + if (entityName.parent.kind === 151 /* TypeQuery */) { // Typeof value meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 128 /* QualifiedName */ || entityName.kind === 158 /* PropertyAccessExpression */ || - entityName.parent.kind === 211 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 132 /* QualifiedName */ || entityName.kind === 163 /* PropertyAccessExpression */ || + entityName.parent.kind === 218 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1536 /* Namespace */; @@ -13397,10 +13979,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 152 /* ParenthesizedType */) { + while (node.kind === 157 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 206 /* TypeAliasDeclaration */) { + if (node.kind === 213 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -13416,10 +13998,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 177 /* ClassExpression */: + case 183 /* ClassExpression */: return "(Anonymous class)"; - case 165 /* FunctionExpression */: - case 166 /* ArrowFunction */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: return "(Anonymous function)"; } } @@ -13505,7 +14087,7 @@ var ts; return writeType(type, globalFlags); function writeType(type, flags) { // Write undefined/null type as any - if (type.flags & 2097279 /* Intrinsic */) { + if (type.flags & 4194431 /* Intrinsic */) { // Special handling for unknown / resolving types, they should show up as any and not unknown or __resolving writer.writeKeyword(!(globalFlags & 16 /* WriteOwnNameForAnyLike */) && isTypeAny(type) ? "any" @@ -13521,10 +14103,10 @@ var ts; else if (type.flags & 8192 /* Tuple */) { writeTupleType(type); } - else if (type.flags & 16384 /* Union */) { - writeUnionType(type, flags); + else if (type.flags & 49152 /* UnionOrIntersection */) { + writeUnionOrIntersectionType(type, flags); } - else if (type.flags & 32768 /* Anonymous */) { + else if (type.flags & 65536 /* Anonymous */) { writeAnonymousType(type, flags); } else if (type.flags & 256 /* StringLiteral */) { @@ -13540,16 +14122,16 @@ var ts; writePunctuation(writer, 15 /* CloseBraceToken */); } } - function writeTypeList(types, union) { + function writeTypeList(types, delimiter) { for (var i = 0; i < types.length; i++) { if (i > 0) { - if (union) { + if (delimiter !== 23 /* CommaToken */) { writeSpace(writer); } - writePunctuation(writer, union ? 44 /* BarToken */ : 23 /* CommaToken */); + writePunctuation(writer, delimiter); writeSpace(writer); } - writeType(types[i], union ? 64 /* InElementType */ : 0 /* None */); + writeType(types[i], delimiter === 23 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */); } } function writeSymbolTypeReference(symbol, typeArguments, pos, end) { @@ -13566,7 +14148,7 @@ var ts; writeSpace(writer); writeType(typeArguments[pos++], 0 /* None */); } - writePunctuation(writer, 25 /* GreaterThanToken */); + writePunctuation(writer, 26 /* GreaterThanToken */); } } function writeTypeReference(type, flags) { @@ -13604,14 +14186,14 @@ var ts; } function writeTupleType(type) { writePunctuation(writer, 18 /* OpenBracketToken */); - writeTypeList(type.elementTypes, false); + writeTypeList(type.elementTypes, 23 /* CommaToken */); writePunctuation(writer, 19 /* CloseBracketToken */); } - function writeUnionType(type, flags) { + function writeUnionOrIntersectionType(type, flags) { if (flags & 64 /* InElementType */) { writePunctuation(writer, 16 /* OpenParenToken */); } - writeTypeList(type.types, true); + writeTypeList(type.types, type.flags & 16384 /* Union */ ? 45 /* BarToken */ : 44 /* AmpersandToken */); if (flags & 64 /* InElementType */) { writePunctuation(writer, 17 /* CloseParenToken */); } @@ -13635,7 +14217,7 @@ var ts; } else { // Recursive usage, use any - writeKeyword(writer, 112 /* AnyKeyword */); + writeKeyword(writer, 114 /* AnyKeyword */); } } else { @@ -13659,7 +14241,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 230 /* SourceFile */ || declaration.parent.kind === 209 /* ModuleBlock */; + return declaration.parent.kind === 245 /* SourceFile */ || declaration.parent.kind === 216 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -13669,7 +14251,7 @@ var ts; } } function writeTypeofSymbol(type, typeFormatFlags) { - writeKeyword(writer, 97 /* TypeOfKeyword */); + writeKeyword(writer, 98 /* TypeOfKeyword */); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */, 0 /* None */, typeFormatFlags); } @@ -13684,7 +14266,7 @@ var ts; return ts.declarationNameToString(declaration.parameters[0].name); } function writeLiteralType(type, flags) { - var resolved = resolveObjectOrUnionTypeMembers(type); + var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { writePunctuation(writer, 14 /* OpenBraceToken */); @@ -13705,7 +14287,7 @@ var ts; if (flags & 64 /* InElementType */) { writePunctuation(writer, 16 /* OpenParenToken */); } - writeKeyword(writer, 88 /* NewKeyword */); + writeKeyword(writer, 89 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, symbolStack); if (flags & 64 /* InElementType */) { @@ -13725,7 +14307,7 @@ var ts; } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - writeKeyword(writer, 88 /* NewKeyword */); + writeKeyword(writer, 89 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); writePunctuation(writer, 22 /* SemicolonToken */); @@ -13735,11 +14317,11 @@ var ts; // [x: string]: writePunctuation(writer, 18 /* OpenBracketToken */); writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, "x")); - writePunctuation(writer, 51 /* ColonToken */); + writePunctuation(writer, 52 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 123 /* StringKeyword */); + writeKeyword(writer, 127 /* StringKeyword */); writePunctuation(writer, 19 /* CloseBracketToken */); - writePunctuation(writer, 51 /* ColonToken */); + writePunctuation(writer, 52 /* ColonToken */); writeSpace(writer); writeType(resolved.stringIndexType, 0 /* None */); writePunctuation(writer, 22 /* SemicolonToken */); @@ -13749,11 +14331,11 @@ var ts; // [x: number]: writePunctuation(writer, 18 /* OpenBracketToken */); writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, "x")); - writePunctuation(writer, 51 /* ColonToken */); + writePunctuation(writer, 52 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 121 /* NumberKeyword */); + writeKeyword(writer, 125 /* NumberKeyword */); writePunctuation(writer, 19 /* CloseBracketToken */); - writePunctuation(writer, 51 /* ColonToken */); + writePunctuation(writer, 52 /* ColonToken */); writeSpace(writer); writeType(resolved.numberIndexType, 0 /* None */); writePunctuation(writer, 22 /* SemicolonToken */); @@ -13768,7 +14350,7 @@ var ts; var signature = signatures[_f]; buildSymbolDisplay(p, writer); if (p.flags & 536870912 /* Optional */) { - writePunctuation(writer, 50 /* QuestionToken */); + writePunctuation(writer, 51 /* QuestionToken */); } buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); writePunctuation(writer, 22 /* SemicolonToken */); @@ -13778,9 +14360,9 @@ var ts; else { buildSymbolDisplay(p, writer); if (p.flags & 536870912 /* Optional */) { - writePunctuation(writer, 50 /* QuestionToken */); + writePunctuation(writer, 51 /* QuestionToken */); } - writePunctuation(writer, 51 /* ColonToken */); + writePunctuation(writer, 52 /* ColonToken */); writeSpace(writer); writeType(t, 0 /* None */); writePunctuation(writer, 22 /* SemicolonToken */); @@ -13802,7 +14384,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 79 /* ExtendsKeyword */); + writeKeyword(writer, 80 /* ExtendsKeyword */); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -13814,9 +14396,9 @@ var ts; } appendSymbolNameOnly(p, writer); if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 50 /* QuestionToken */); + writePunctuation(writer, 51 /* QuestionToken */); } - writePunctuation(writer, 51 /* ColonToken */); + writePunctuation(writer, 52 /* ColonToken */); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } @@ -13830,7 +14412,7 @@ var ts; } buildTypeParameterDisplay(typeParameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 25 /* GreaterThanToken */); + writePunctuation(writer, 26 /* GreaterThanToken */); } } function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, symbolStack) { @@ -13843,7 +14425,7 @@ var ts; } buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, 0 /* None */); } - writePunctuation(writer, 25 /* GreaterThanToken */); + writePunctuation(writer, 26 /* GreaterThanToken */); } } function buildDisplayForParametersAndDelimiters(parameters, writer, enclosingDeclaration, flags, symbolStack) { @@ -13860,13 +14442,24 @@ var ts; function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { if (flags & 8 /* WriteArrowStyleSignature */) { writeSpace(writer); - writePunctuation(writer, 32 /* EqualsGreaterThanToken */); + writePunctuation(writer, 33 /* EqualsGreaterThanToken */); } else { - writePunctuation(writer, 51 /* ColonToken */); + writePunctuation(writer, 52 /* ColonToken */); } writeSpace(writer); - buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags, symbolStack); + var returnType; + if (signature.typePredicate) { + writer.writeParameter(signature.typePredicate.parameterName); + writeSpace(writer); + writeKeyword(writer, 121 /* IsKeyword */); + writeSpace(writer); + returnType = signature.typePredicate.type; + } + else { + returnType = getReturnTypeOfSignature(signature); + } + buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); } function buildSignatureDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { if (signature.target && (flags & 32 /* WriteTypeArgumentsOfSignature */)) { @@ -13898,12 +14491,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 208 /* ModuleDeclaration */) { + if (node.kind === 215 /* ModuleDeclaration */) { if (node.name.kind === 8 /* StringLiteral */) { return node; } } - else if (node.kind === 230 /* SourceFile */) { + else if (node.kind === 245 /* SourceFile */) { return ts.isExternalModule(node) ? node : undefined; } } @@ -13952,69 +14545,70 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 155 /* BindingElement */: + case 160 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 201 /* VariableDeclaration */: + case 208 /* VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // Otherwise fall through - case 208 /* ModuleDeclaration */: - case 204 /* ClassDeclaration */: - case 205 /* InterfaceDeclaration */: - case 206 /* TypeAliasDeclaration */: - case 203 /* FunctionDeclaration */: - case 207 /* EnumDeclaration */: - case 211 /* ImportEqualsDeclaration */: + case 215 /* ModuleDeclaration */: + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: + case 213 /* TypeAliasDeclaration */: + case 210 /* FunctionDeclaration */: + case 214 /* EnumDeclaration */: + case 218 /* ImportEqualsDeclaration */: var parent_4 = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedNodeFlags(node) & 1 /* Export */) && - !(node.kind !== 211 /* ImportEqualsDeclaration */ && parent_4.kind !== 230 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 218 /* ImportEqualsDeclaration */ && parent_4.kind !== 245 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent_4); - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: if (node.flags & (32 /* Private */ | 64 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so let it fall into next case statement - case 137 /* Constructor */: - case 141 /* ConstructSignature */: - case 140 /* CallSignature */: - case 142 /* IndexSignature */: - case 131 /* Parameter */: - case 209 /* ModuleBlock */: - case 145 /* FunctionType */: - case 146 /* ConstructorType */: - case 148 /* TypeLiteral */: - case 144 /* TypeReference */: - case 149 /* ArrayType */: - case 150 /* TupleType */: - case 151 /* UnionType */: - case 152 /* ParenthesizedType */: + case 141 /* Constructor */: + case 145 /* ConstructSignature */: + case 144 /* CallSignature */: + case 146 /* IndexSignature */: + case 135 /* Parameter */: + case 216 /* ModuleBlock */: + case 149 /* FunctionType */: + case 150 /* ConstructorType */: + case 152 /* TypeLiteral */: + case 148 /* TypeReference */: + case 153 /* ArrayType */: + case 154 /* TupleType */: + case 155 /* UnionType */: + case 156 /* IntersectionType */: + case 157 /* ParenthesizedType */: return isDeclarationVisible(node.parent); - // Default binding, import specifier and namespace import is visible + // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 213 /* ImportClause */: - case 214 /* NamespaceImport */: - case 216 /* ImportSpecifier */: + case 220 /* ImportClause */: + case 221 /* NamespaceImport */: + case 223 /* ImportSpecifier */: return false; // Type parameters are always visible - case 130 /* TypeParameter */: + case 134 /* TypeParameter */: // Source file is always visible - case 230 /* SourceFile */: + case 245 /* SourceFile */: return true; // Export assignements do not create name bindings outside the module - case 217 /* ExportAssignment */: + case 224 /* ExportAssignment */: return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -14030,10 +14624,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 217 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 224 /* ExportAssignment */) { exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 220 /* ExportSpecifier */) { + else if (node.parent.kind === 227 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent); } var result = []; @@ -14091,7 +14685,7 @@ var ts; node = ts.getRootDeclaration(node); // Parent chain: // VaribleDeclaration -> VariableDeclarationList -> VariableStatement -> 'Declaration Container' - return node.kind === 201 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; + return node.kind === 208 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { // TypeScript 1.0 spec (April 2014): 8.4 @@ -14127,16 +14721,16 @@ var ts; return parentType; } var type; - if (pattern.kind === 153 /* ObjectBindingPattern */) { + if (pattern.kind === 158 /* ObjectBindingPattern */) { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) - var name_9 = declaration.propertyName || declaration.name; + var name_10 = declaration.propertyName || declaration.name; // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, // or otherwise the type of the string index signature. - type = getTypeOfPropertyOfType(parentType, name_9.text) || - isNumericLiteralName(name_9.text) && getIndexTypeOfType(parentType, 1 /* Number */) || + type = getTypeOfPropertyOfType(parentType, name_10.text) || + isNumericLiteralName(name_10.text) && getIndexTypeOfType(parentType, 1 /* Number */) || getIndexTypeOfType(parentType, 0 /* String */); if (!type) { - error(name_9, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_9)); + error(name_10, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_10)); return unknownType; } } @@ -14174,10 +14768,10 @@ var ts; // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration) { // A variable declared in a for..in statement is always of type any - if (declaration.parent.parent.kind === 190 /* ForInStatement */) { + if (declaration.parent.parent.kind === 197 /* ForInStatement */) { return anyType; } - if (declaration.parent.parent.kind === 191 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 198 /* ForOfStatement */) { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like // [Symbol.iterator] or next). This may be because we accessed properties from anyType, @@ -14191,11 +14785,11 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 131 /* Parameter */) { + if (declaration.kind === 135 /* Parameter */) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 139 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 138 /* GetAccessor */); + if (func.kind === 143 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 142 /* GetAccessor */); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -14211,7 +14805,7 @@ var ts; return checkExpressionCached(declaration.initializer); } // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 228 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 243 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } // No type specified and nothing can be inferred @@ -14246,7 +14840,7 @@ var ts; var hasSpreadElement = false; var elementTypes = []; ts.forEach(pattern.elements, function (e) { - elementTypes.push(e.kind === 178 /* OmittedExpression */ || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); + elementTypes.push(e.kind === 184 /* OmittedExpression */ || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); if (e.dotDotDotToken) { hasSpreadElement = true; } @@ -14269,7 +14863,7 @@ var ts; // parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of // the parameter. function getTypeFromBindingPattern(pattern) { - return pattern.kind === 153 /* ObjectBindingPattern */ + return pattern.kind === 158 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern) : getTypeFromArrayBindingPattern(pattern); } @@ -14291,7 +14885,7 @@ var ts; // During a normal type check we'll never get to here with a property assignment (the check of the containing // object literal uses a different path). We exclude widening only so that language services and type verification // tools see the actual type. - return declaration.kind !== 227 /* PropertyAssignment */ ? getWidenedType(type) : type; + return declaration.kind !== 242 /* PropertyAssignment */ ? getWidenedType(type) : type; } // If no type was specified and nothing could be inferred, and if the declaration specifies a binding pattern, use // the type implied by the binding pattern @@ -14303,7 +14897,7 @@ var ts; // Report implicit any errors unless this is a private property within an ambient declaration if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 131 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 135 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -14318,11 +14912,11 @@ var ts; } // Handle catch clause variables var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 226 /* CatchClause */) { + if (declaration.parent.kind === 241 /* CatchClause */) { return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 217 /* ExportAssignment */) { + if (declaration.kind === 224 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } // Handle variable, parameter or property @@ -14348,16 +14942,13 @@ var ts; } return links.type; } - function getSetAccessorTypeAnnotationNode(accessor) { - return accessor && accessor.parameters.length > 0 && accessor.parameters[0].type; - } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 138 /* GetAccessor */) { + if (accessor.kind === 142 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { - var setterTypeAnnotation = getSetAccessorTypeAnnotationNode(accessor); + var setterTypeAnnotation = ts.getSetAccessorTypeAnnotationNode(accessor); return setterTypeAnnotation && getTypeFromTypeNode(setterTypeAnnotation); } } @@ -14369,8 +14960,8 @@ var ts; if (!pushTypeResolution(symbol)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 138 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 139 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 142 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 143 /* SetAccessor */); var type; // First try to see if the user specified a return type on the get-accessor. var getterReturnType = getAnnotatedAccessorType(getter); @@ -14399,7 +14990,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 138 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 142 /* GetAccessor */); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -14410,7 +15001,7 @@ var ts; function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - links.type = createObjectType(32768 /* Anonymous */, symbol); + links.type = createObjectType(65536 /* Anonymous */, symbol); } return links.type; } @@ -14499,9 +15090,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 204 /* ClassDeclaration */ || node.kind === 177 /* ClassExpression */ || - node.kind === 203 /* FunctionDeclaration */ || node.kind === 165 /* FunctionExpression */ || - node.kind === 136 /* MethodDeclaration */ || node.kind === 166 /* ArrowFunction */) { + if (node.kind === 211 /* ClassDeclaration */ || node.kind === 183 /* ClassExpression */ || + node.kind === 210 /* FunctionDeclaration */ || node.kind === 170 /* FunctionExpression */ || + node.kind === 140 /* MethodDeclaration */ || node.kind === 171 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -14511,7 +15102,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 205 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 212 /* InterfaceDeclaration */); return appendOuterTypeParameters(undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -14520,8 +15111,8 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 205 /* InterfaceDeclaration */ || node.kind === 204 /* ClassDeclaration */ || - node.kind === 177 /* ClassExpression */ || node.kind === 206 /* TypeAliasDeclaration */) { + if (node.kind === 212 /* InterfaceDeclaration */ || node.kind === 211 /* ClassDeclaration */ || + node.kind === 183 /* ClassExpression */ || node.kind === 213 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -14536,7 +15127,7 @@ var ts; return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); } function isConstructorType(type) { - return type.flags & 48128 /* ObjectType */ && getSignaturesOfType(type, 1 /* Construct */).length > 0; + return type.flags & 80896 /* ObjectType */ && getSignaturesOfType(type, 1 /* Construct */).length > 0; } function getBaseTypeNodeOfClass(type) { return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); @@ -14568,10 +15159,10 @@ var ts; return unknownType; } var baseConstructorType = checkExpression(baseTypeNode.expression); - if (baseConstructorType.flags & 48128 /* ObjectType */) { + if (baseConstructorType.flags & 80896 /* ObjectType */) { // Resolving the members of a class requires us to resolve the base class of that class. // We force resolution here such that we catch circularities now. - resolveObjectOrUnionTypeMembers(baseConstructorType); + resolveStructuredTypeMembers(baseConstructorType); } if (!popTypeResolution()) { error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); @@ -14602,7 +15193,7 @@ var ts; function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = emptyArray; var baseContructorType = getBaseConstructorTypeOfClass(type); - if (!(baseContructorType.flags & 48128 /* ObjectType */)) { + if (!(baseContructorType.flags & 80896 /* ObjectType */)) { return; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -14641,7 +15232,7 @@ var ts; type.resolvedBaseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 205 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 212 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -14690,7 +15281,7 @@ var ts; if (!pushTypeResolution(links)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 206 /* TypeAliasDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 213 /* TypeAliasDeclaration */); var type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -14723,7 +15314,7 @@ var ts; if (!links.declaredType) { var type = createType(512 /* TypeParameter */); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 130 /* TypeParameter */).constraint) { + if (!ts.getDeclarationOfKind(symbol, 134 /* TypeParameter */).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -14885,7 +15476,7 @@ var ts; return members; } function resolveTupleTypeMembers(type) { - var arrayType = resolveObjectOrUnionTypeMembers(createArrayType(getUnionType(type.elementTypes))); + var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes))); var members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); @@ -14948,6 +15539,25 @@ var ts; var numberIndexType = getUnionIndexType(type.types, 1 /* Number */); setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); } + function intersectTypes(type1, type2) { + return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); + } + function resolveIntersectionTypeMembers(type) { + // The members and properties collections are empty for intersection types. To get all properties of an + // intersection type use getPropertiesOfType (only the language service uses this). + var callSignatures = emptyArray; + var constructSignatures = emptyArray; + var stringIndexType = undefined; + var numberIndexType = undefined; + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(t, 0 /* Call */)); + constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(t, 1 /* Construct */)); + stringIndexType = intersectTypes(stringIndexType, getIndexTypeOfType(t, 0 /* String */)); + numberIndexType = intersectTypes(numberIndexType, getIndexTypeOfType(t, 1 /* Number */)); + } + setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); + } function resolveAnonymousTypeMembers(type) { var symbol = type.symbol; var members; @@ -14980,7 +15590,7 @@ var ts; constructSignatures = getDefaultConstructSignatures(classType); } var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & 48128 /* ObjectType */) { + if (baseConstructorType.flags & 80896 /* ObjectType */) { members = createSymbolTable(getNamedMembers(members)); addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); } @@ -14990,12 +15600,12 @@ var ts; } setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } - function resolveObjectOrUnionTypeMembers(type) { + function resolveStructuredTypeMembers(type) { if (!type.members) { if (type.flags & (1024 /* Class */ | 2048 /* Interface */)) { resolveClassOrInterfaceMembers(type); } - else if (type.flags & 32768 /* Anonymous */) { + else if (type.flags & 65536 /* Anonymous */) { resolveAnonymousTypeMembers(type); } else if (type.flags & 8192 /* Tuple */) { @@ -15004,6 +15614,9 @@ var ts; else if (type.flags & 16384 /* Union */) { resolveUnionTypeMembers(type); } + else if (type.flags & 32768 /* Intersection */) { + resolveIntersectionTypeMembers(type); + } else { resolveTypeReferenceMembers(type); } @@ -15012,16 +15625,16 @@ var ts; } // Return properties of an object type or an empty array for other types function getPropertiesOfObjectType(type) { - if (type.flags & 48128 /* ObjectType */) { - return resolveObjectOrUnionTypeMembers(type).properties; + if (type.flags & 80896 /* ObjectType */) { + return resolveStructuredTypeMembers(type).properties; } return emptyArray; } - // If the given type is an object type and that type has a property by the given name, return - // the symbol for that property. Otherwise return undefined. + // If the given type is an object type and that type has a property by the given name, + // return the symbol for that property.Otherwise return undefined. function getPropertyOfObjectType(type, name) { - if (type.flags & 48128 /* ObjectType */) { - var resolved = resolveObjectOrUnionTypeMembers(type); + if (type.flags & 80896 /* ObjectType */) { + var resolved = resolveStructuredTypeMembers(type); if (ts.hasProperty(resolved.members, name)) { var symbol = resolved.members[name]; if (symbolIsValue(symbol)) { @@ -15030,23 +15643,30 @@ var ts; } } } - function getPropertiesOfUnionType(type) { - var result = []; - ts.forEach(getPropertiesOfType(type.types[0]), function (prop) { - var unionProp = getPropertyOfUnionType(type, prop.name); - if (unionProp) { - result.push(unionProp); + function getPropertiesOfUnionOrIntersectionType(type) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var current = _a[_i]; + for (var _b = 0, _c = getPropertiesOfType(current); _b < _c.length; _b++) { + var prop = _c[_b]; + getPropertyOfUnionOrIntersectionType(type, prop.name); } - }); - return result; + // The properties of a union type are those that are present in all constituent types, so + // we only need to check the properties of the first type + if (type.flags & 16384 /* Union */) { + break; + } + } + return type.resolvedProperties ? symbolsToArray(type.resolvedProperties) : emptyArray; } function getPropertiesOfType(type) { type = getApparentType(type); - return type.flags & 16384 /* Union */ ? getPropertiesOfUnionType(type) : getPropertiesOfObjectType(type); + return type.flags & 49152 /* UnionOrIntersection */ ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } - // For a type parameter, return the base constraint of the type parameter. For the string, number, - // boolean, and symbol primitive types, return the corresponding object types. Otherwise return the - // type itself. Note that the apparent type of a union type is the union type itself. + /** + * For a type parameter, return the base constraint of the type parameter. For the string, number, + * boolean, and symbol primitive types, return the corresponding object types. Otherwise return the + * type itself. Note that the apparent type of a union type is the union type itself. + */ function getApparentType(type) { if (type.flags & 16384 /* Union */) { type = getReducedTypeOfUnionType(type); @@ -15068,51 +15688,60 @@ var ts; else if (type.flags & 8 /* Boolean */) { type = globalBooleanType; } - else if (type.flags & 2097152 /* ESSymbol */) { + else if (type.flags & 4194304 /* ESSymbol */) { type = globalESSymbolType; } return type; } - function createUnionProperty(unionType, name) { - var types = unionType.types; + function createUnionOrIntersectionProperty(containingType, name) { + var types = containingType.types; var props; for (var _i = 0; _i < types.length; _i++) { var current = types[_i]; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); - if (!prop || getDeclarationFlagsFromSymbol(prop) & (32 /* Private */ | 64 /* Protected */)) { + if (prop && !(getDeclarationFlagsFromSymbol(prop) & (32 /* Private */ | 64 /* Protected */))) { + if (!props) { + props = [prop]; + } + else if (!ts.contains(props, prop)) { + props.push(prop); + } + } + else if (containingType.flags & 16384 /* Union */) { + // A union type requires the property to be present in all constituent types return undefined; } - if (!props) { - props = [prop]; - } - else { - props.push(prop); - } } } + if (!props) { + return undefined; + } + if (props.length === 1) { + return props[0]; + } var propTypes = []; var declarations = []; for (var _a = 0; _a < props.length; _a++) { var prop = props[_a]; if (prop.declarations) { - declarations.push.apply(declarations, prop.declarations); + ts.addRange(declarations, prop.declarations); } propTypes.push(getTypeOfSymbol(prop)); } - var result = createSymbol(4 /* Property */ | 67108864 /* Transient */ | 268435456 /* UnionProperty */, name); - result.unionType = unionType; + var result = createSymbol(4 /* Property */ | 67108864 /* Transient */ | 268435456 /* SyntheticProperty */, name); + result.containingType = containingType; result.declarations = declarations; - result.type = getUnionType(propTypes); + result.type = containingType.flags & 16384 /* Union */ ? getUnionType(propTypes) : getIntersectionType(propTypes); return result; } - function getPropertyOfUnionType(type, name) { + function getPropertyOfUnionOrIntersectionType(type, name) { var properties = type.resolvedProperties || (type.resolvedProperties = {}); if (ts.hasProperty(properties, name)) { return properties[name]; } - var property = createUnionProperty(type, name); + var property = createUnionOrIntersectionProperty(type, name); if (property) { properties[name] = property; } @@ -15123,8 +15752,8 @@ var ts; // Object and Function as appropriate. function getPropertyOfType(type, name) { type = getApparentType(type); - if (type.flags & 48128 /* ObjectType */) { - var resolved = resolveObjectOrUnionTypeMembers(type); + if (type.flags & 80896 /* ObjectType */) { + var resolved = resolveStructuredTypeMembers(type); if (ts.hasProperty(resolved.members, name)) { var symbol = resolved.members[name]; if (symbolIsValue(symbol)) { @@ -15139,14 +15768,14 @@ var ts; } return getPropertyOfObjectType(globalObjectType, name); } - if (type.flags & 16384 /* Union */) { - return getPropertyOfUnionType(type, name); + if (type.flags & 49152 /* UnionOrIntersection */) { + return getPropertyOfUnionOrIntersectionType(type, name); } return undefined; } - function getSignaturesOfObjectOrUnionType(type, kind) { - if (type.flags & (48128 /* ObjectType */ | 16384 /* Union */)) { - var resolved = resolveObjectOrUnionTypeMembers(type); + function getSignaturesOfStructuredType(type, kind) { + if (type.flags & 130048 /* StructuredType */) { + var resolved = resolveStructuredTypeMembers(type); return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures; } return emptyArray; @@ -15154,27 +15783,34 @@ var ts; // Return the signatures of the given kind in the given type. Creates synthetic union signatures when necessary and // maps primitive types and type parameters are to their apparent types. function getSignaturesOfType(type, kind) { - return getSignaturesOfObjectOrUnionType(getApparentType(type), kind); + return getSignaturesOfStructuredType(getApparentType(type), kind); } - function typeHasCallOrConstructSignatures(type) { + function typeHasConstructSignatures(type) { var apparentType = getApparentType(type); - if (apparentType.flags & (48128 /* ObjectType */ | 16384 /* Union */)) { - var resolved = resolveObjectOrUnionTypeMembers(type); - return resolved.callSignatures.length > 0 - || resolved.constructSignatures.length > 0; + if (apparentType.flags & (80896 /* ObjectType */ | 16384 /* Union */)) { + var resolved = resolveStructuredTypeMembers(type); + return resolved.constructSignatures.length > 0; } return false; } - function getIndexTypeOfObjectOrUnionType(type, kind) { - if (type.flags & (48128 /* ObjectType */ | 16384 /* Union */)) { - var resolved = resolveObjectOrUnionTypeMembers(type); + function typeHasCallOrConstructSignatures(type) { + var apparentType = getApparentType(type); + if (apparentType.flags & 130048 /* StructuredType */) { + var resolved = resolveStructuredTypeMembers(type); + return resolved.callSignatures.length > 0 || resolved.constructSignatures.length > 0; + } + return false; + } + function getIndexTypeOfStructuredType(type, kind) { + if (type.flags & 130048 /* StructuredType */) { + var resolved = resolveStructuredTypeMembers(type); return kind === 0 /* String */ ? resolved.stringIndexType : resolved.numberIndexType; } } // Return the index type of the given kind in the given type. Creates synthetic union index types when necessary and // maps primitive types and type parameters are to their apparent types. function getIndexTypeOfType(type, kind) { - return getIndexTypeOfObjectOrUnionType(getApparentType(type), kind); + return getIndexTypeOfStructuredType(getApparentType(type), kind); } // Return list of type parameters with duplicates removed (duplicate identifier errors are generated in the actual // type checking functions). @@ -15203,7 +15839,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 137 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 141 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -15231,7 +15867,7 @@ var ts; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); - if (declaration.type.kind === 143 /* TypePredicate */) { + if (declaration.type.kind === 147 /* TypePredicate */) { var typePredicateNode = declaration.type; typePredicate = { parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, @@ -15243,8 +15879,8 @@ var ts; else { // TypeScript 1.0 spec (April 2014): // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. - if (declaration.kind === 138 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 139 /* SetAccessor */); + if (declaration.kind === 142 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 143 /* SetAccessor */); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -15262,19 +15898,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 145 /* FunctionType */: - case 146 /* ConstructorType */: - case 203 /* FunctionDeclaration */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 137 /* Constructor */: - case 140 /* CallSignature */: - case 141 /* ConstructSignature */: - case 142 /* IndexSignature */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 165 /* FunctionExpression */: - case 166 /* ArrowFunction */: + case 149 /* FunctionType */: + case 150 /* ConstructorType */: + case 210 /* FunctionDeclaration */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 141 /* Constructor */: + case 144 /* CallSignature */: + case 145 /* ConstructSignature */: + case 146 /* IndexSignature */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: // Don't include signature if node is the implementation of an overloaded function. A node is considered // an implementation node if it has a body and the previous node is of the same kind and immediately // precedes the implementation node (i.e. has the same parent and ends where the implementation starts). @@ -15351,8 +15987,8 @@ var ts; // object type literal or interface (using the new keyword). Each way of declaring a constructor // will result in a different declaration kind. if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 137 /* Constructor */ || signature.declaration.kind === 141 /* ConstructSignature */; - var type = createObjectType(32768 /* Anonymous */ | 131072 /* FromSignature */); + var isConstructor = signature.declaration.kind === 141 /* Constructor */ || signature.declaration.kind === 145 /* ConstructSignature */; + var type = createObjectType(65536 /* Anonymous */ | 262144 /* FromSignature */); type.members = emptySymbols; type.properties = emptyArray; type.callSignatures = !isConstructor ? [signature] : emptyArray; @@ -15365,10 +16001,9 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 121 /* NumberKeyword */ : 123 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 125 /* NumberKeyword */ : 127 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { - var len = indexSymbol.declarations.length; for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; var node = decl; @@ -15395,13 +16030,13 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 130 /* TypeParameter */).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 134 /* TypeParameter */).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 130 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 134 /* TypeParameter */).parent); } function getTypeListId(types) { switch (types.length) { @@ -15429,7 +16064,7 @@ var ts; var type = types[_i]; result |= type.flags; } - return result & 1572864 /* RequiresWidening */; + return result & 3145728 /* RequiresWidening */; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); @@ -15454,13 +16089,13 @@ var ts; currentNode = currentNode.parent; } // if last step was made from the type parameter this means that path has started somewhere in constraint which is illegal - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 130 /* TypeParameter */; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 134 /* TypeParameter */; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 144 /* TypeReference */ && n.typeName.kind === 65 /* Identifier */) { + if (n.kind === 148 /* TypeReference */ && n.typeName.kind === 66 /* Identifier */) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056 /* Type */, undefined, undefined); @@ -15547,7 +16182,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { // We only support expressions that are simple qualified names. For other expressions this produces undefined. - var typeNameOrExpression = node.kind === 144 /* TypeReference */ ? node.typeName : + var typeNameOrExpression = node.kind === 148 /* TypeReference */ ? node.typeName : ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : undefined; var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056 /* Type */) || unknownSymbol; @@ -15579,9 +16214,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 204 /* ClassDeclaration */: - case 205 /* InterfaceDeclaration */: - case 207 /* EnumDeclaration */: + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: + case 214 /* EnumDeclaration */: return declaration; } } @@ -15590,7 +16225,7 @@ var ts; return arity ? emptyGenericType : emptyObjectType; } var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 48128 /* ObjectType */)) { + if (!(type.flags & 80896 /* ObjectType */)) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name); return arity ? emptyGenericType : emptyObjectType; } @@ -15613,6 +16248,19 @@ var ts; if (arity === void 0) { arity = 0; } return getTypeOfGlobalSymbol(getGlobalTypeSymbol(name), arity); } + function tryGetGlobalType(name, arity) { + if (arity === void 0) { arity = 0; } + return getTypeOfGlobalSymbol(getGlobalSymbol(name, 793056 /* Type */, undefined), arity); + } + /** + * Returns a type that is inside a namespace at the global scope, e.g. + * getExportedTypeFromNamespace('JSX', 'Element') returns the JSX.Element type + */ + function getExportedTypeFromNamespace(namespace, name) { + var namespaceSymbol = getGlobalSymbol(namespace, 1536 /* Namespace */, undefined); + var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793056 /* Type */); + return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); + } function getGlobalESSymbolConstructorSymbol() { return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol")); } @@ -15663,25 +16311,20 @@ var ts; } return links.resolvedType; } - function addTypeToSortedSet(sortedSet, type) { - if (type.flags & 16384 /* Union */) { - addTypesToSortedSet(sortedSet, type.types); + function addTypeToSet(typeSet, type, typeSetKind) { + if (type.flags & typeSetKind) { + addTypesToSet(typeSet, type.types, typeSetKind); } - else { - var i = 0; - var id = type.id; - while (i < sortedSet.length && sortedSet[i].id < id) { - i++; - } - if (i === sortedSet.length || sortedSet[i].id !== id) { - sortedSet.splice(i, 0, type); - } + else if (!ts.contains(typeSet, type)) { + typeSet.push(type); } } - function addTypesToSortedSet(sortedTypes, types) { + // Add the given types to the given type set. Order is preserved, duplicates are removed, + // and nested types of the given kind are flattened into the set. + function addTypesToSet(typeSet, types, typeSetKind) { for (var _i = 0; _i < types.length; _i++) { var type = types[_i]; - addTypeToSortedSet(sortedTypes, type); + addTypeToSet(typeSet, type, typeSetKind); } } function isSubtypeOfAny(candidate, types) { @@ -15720,6 +16363,9 @@ var ts; } } } + function compareTypeIds(type1, type2) { + return type1.id - type2.id; + } // The noSubtypeReduction flag is there because it isn't possible to always do subtype reduction. The flag // is true when creating a union type from a type node and when instantiating a union type. In both of those // cases subtype reduction has to be deferred to properly support recursive union types. For example, a @@ -15728,26 +16374,27 @@ var ts; if (types.length === 0) { return emptyObjectType; } - var sortedTypes = []; - addTypesToSortedSet(sortedTypes, types); + var typeSet = []; + addTypesToSet(typeSet, types, 16384 /* Union */); + typeSet.sort(compareTypeIds); if (noSubtypeReduction) { - if (containsTypeAny(sortedTypes)) { + if (containsTypeAny(typeSet)) { return anyType; } - removeAllButLast(sortedTypes, undefinedType); - removeAllButLast(sortedTypes, nullType); + removeAllButLast(typeSet, undefinedType); + removeAllButLast(typeSet, nullType); } else { - removeSubtypes(sortedTypes); + removeSubtypes(typeSet); } - if (sortedTypes.length === 1) { - return sortedTypes[0]; + if (typeSet.length === 1) { + return typeSet[0]; } - var id = getTypeListId(sortedTypes); + var id = getTypeListId(typeSet); var type = unionTypes[id]; if (!type) { - type = unionTypes[id] = createObjectType(16384 /* Union */ | getWideningFlagsOfTypes(sortedTypes)); - type.types = sortedTypes; + type = unionTypes[id] = createObjectType(16384 /* Union */ | getWideningFlagsOfTypes(typeSet)); + type.types = typeSet; type.reducedType = noSubtypeReduction ? undefined : type; } return type; @@ -15776,11 +16423,43 @@ var ts; } return links.resolvedType; } + // We do not perform supertype reduction on intersection types. Intersection types are created only by the & + // type operator and we can't reduce those because we want to support recursive intersection types. For example, + // a type alias of the form "type List = T & { next: List }" cannot be reduced during its declaration. + // Also, unlike union types, the order of the constituent types is preserved in order that overload resolution + // for intersections of types with signatures can be deterministic. + function getIntersectionType(types) { + if (types.length === 0) { + return emptyObjectType; + } + var typeSet = []; + addTypesToSet(typeSet, types, 32768 /* Intersection */); + if (containsTypeAny(typeSet)) { + return anyType; + } + if (typeSet.length === 1) { + return typeSet[0]; + } + var id = getTypeListId(typeSet); + var type = intersectionTypes[id]; + if (!type) { + type = intersectionTypes[id] = createObjectType(32768 /* Intersection */ | getWideningFlagsOfTypes(typeSet)); + type.types = typeSet; + } + return type; + } + function getTypeFromIntersectionTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode)); + } + return links.resolvedType; + } function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { // Deferred resolution of members is handled by resolveObjectTypeMembers - links.resolvedType = createObjectType(32768 /* Anonymous */, node.symbol); + links.resolvedType = createObjectType(65536 /* Anonymous */, node.symbol); } return links.resolvedType; } @@ -15801,44 +16480,46 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 112 /* AnyKeyword */: + case 114 /* AnyKeyword */: return anyType; - case 123 /* StringKeyword */: + case 127 /* StringKeyword */: return stringType; - case 121 /* NumberKeyword */: + case 125 /* NumberKeyword */: return numberType; - case 113 /* BooleanKeyword */: + case 117 /* BooleanKeyword */: return booleanType; - case 124 /* SymbolKeyword */: + case 128 /* SymbolKeyword */: return esSymbolType; - case 99 /* VoidKeyword */: + case 100 /* VoidKeyword */: return voidType; case 8 /* StringLiteral */: return getTypeFromStringLiteral(node); - case 144 /* TypeReference */: + case 148 /* TypeReference */: return getTypeFromTypeReference(node); - case 143 /* TypePredicate */: + case 147 /* TypePredicate */: return booleanType; - case 179 /* ExpressionWithTypeArguments */: + case 185 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 147 /* TypeQuery */: + case 151 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 149 /* ArrayType */: + case 153 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 150 /* TupleType */: + case 154 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 151 /* UnionType */: + case 155 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 152 /* ParenthesizedType */: + case 156 /* IntersectionType */: + return getTypeFromIntersectionTypeNode(node); + case 157 /* ParenthesizedType */: return getTypeFromTypeNode(node.type); - case 145 /* FunctionType */: - case 146 /* ConstructorType */: - case 148 /* TypeLiteral */: + case 149 /* FunctionType */: + case 150 /* ConstructorType */: + case 152 /* TypeLiteral */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode - case 65 /* Identifier */: - case 128 /* QualifiedName */: + case 66 /* Identifier */: + case 132 /* QualifiedName */: var symbol = getSymbolInfo(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -15968,7 +16649,7 @@ var ts; } function instantiateAnonymousType(type, mapper) { // Mark the anonymous type as instantiated such that our infinite instantiation detection logic can recognize it - var result = createObjectType(32768 /* Anonymous */ | 65536 /* Instantiated */, type.symbol); + var result = createObjectType(65536 /* Anonymous */ | 131072 /* Instantiated */, type.symbol); result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol); result.members = createSymbolTable(result.properties); result.callSignatures = instantiateList(getSignaturesOfType(type, 0 /* Call */), mapper, instantiateSignature); @@ -15986,7 +16667,7 @@ var ts; if (type.flags & 512 /* TypeParameter */) { return mapper(type); } - if (type.flags & 32768 /* Anonymous */) { + if (type.flags & 65536 /* Anonymous */) { return type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) ? instantiateAnonymousType(type, mapper) : type; } @@ -15999,33 +16680,36 @@ var ts; if (type.flags & 16384 /* Union */) { return getUnionType(instantiateList(type.types, mapper, instantiateType), true); } + if (type.flags & 32768 /* Intersection */) { + return getIntersectionType(instantiateList(type.types, mapper, instantiateType)); + } } return type; } // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 136 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 140 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 165 /* FunctionExpression */: - case 166 /* ArrowFunction */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 157 /* ObjectLiteralExpression */: + case 162 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 156 /* ArrayLiteralExpression */: + case 161 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 173 /* ConditionalExpression */: + case 179 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 172 /* BinaryExpression */: - return node.operatorToken.kind === 49 /* BarBarToken */ && + case 178 /* BinaryExpression */: + return node.operatorToken.kind === 50 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 227 /* PropertyAssignment */: + case 242 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 164 /* ParenthesizedExpression */: + case 169 /* ParenthesizedExpression */: return isContextSensitive(node.expression); } return false; @@ -16034,10 +16718,10 @@ var ts; return !node.typeParameters && node.parameters.length && !ts.forEach(node.parameters, function (p) { return p.type; }); } function getTypeWithoutSignatures(type) { - if (type.flags & 48128 /* ObjectType */) { - var resolved = resolveObjectOrUnionTypeMembers(type); + if (type.flags & 80896 /* ObjectType */) { + var resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length) { - var result = createObjectType(32768 /* Anonymous */, type.symbol); + var result = createObjectType(65536 /* Anonymous */, type.symbol); result.members = resolved.members; result.properties = resolved.properties; result.callSignatures = emptyArray; @@ -16071,6 +16755,16 @@ var ts; var targetType = getOrCreateTypeFromSignature(target); return checkTypeRelatedTo(sourceType, targetType, assignableRelation, undefined); } + /** + * Checks if 'source' is related to 'target' (e.g.: is a assignable to). + * @param source The left-hand-side of the relation. + * @param target The right-hand-side of the relation. + * @param relation The relation considered. One of 'identityRelation', 'assignableRelation', or 'subTypeRelation'. + * Used as both to determine which checks are performed and as a cache of previously computed results. + * @param errorNode The node upon which all errors will be reported, if defined. + * @param headMessage If the error chain should be prepended by a head message, then headMessage will be used. + * @param containingMessageChain A chain of errors to prepend any new errors found. + */ function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain) { var errorInfo; var sourceStack; @@ -16132,37 +16826,10 @@ var ts; } } var saveErrorInfo = errorInfo; - if (source.flags & 16384 /* Union */ || target.flags & 16384 /* Union */) { - if (relation === identityRelation) { - if (source.flags & 16384 /* Union */ && target.flags & 16384 /* Union */) { - if (result = unionTypeRelatedToUnionType(source, target)) { - if (result &= unionTypeRelatedToUnionType(target, source)) { - return result; - } - } - } - else if (source.flags & 16384 /* Union */) { - if (result = unionTypeRelatedToType(source, target, reportErrors)) { - return result; - } - } - else { - if (result = unionTypeRelatedToType(target, source, reportErrors)) { - return result; - } - } - } - else { - if (source.flags & 16384 /* Union */) { - if (result = unionTypeRelatedToType(source, target, reportErrors)) { - return result; - } - } - else { - if (result = typeRelatedToUnionType(source, target, reportErrors)) { - return result; - } - } + if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { + // We have type references to same target type, see if relationship holds for all type arguments + if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + return result; } } else if (source.flags & 512 /* TypeParameter */ && target.flags & 512 /* TypeParameter */) { @@ -16170,27 +16837,63 @@ var ts; return result; } } - else if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { - // We have type references to same target type, see if relationship holds for all type arguments - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { - return result; + else if (relation !== identityRelation) { + // Note that the "each" checks must precede the "some" checks to produce the correct results + if (source.flags & 16384 /* Union */) { + if (result = eachTypeRelatedToType(source, target, reportErrors)) { + return result; + } + } + else if (target.flags & 32768 /* Intersection */) { + if (result = typeRelatedToEachType(source, target, reportErrors)) { + return result; + } + } + else { + // It is necessary to try "each" checks on both sides because there may be nested "some" checks + // on either side that need to be prioritized. For example, A | B = (A | B) & (C | D) or + // A & B = (A & B) | (C & D). + if (source.flags & 32768 /* Intersection */) { + // If target is a union type the following check will report errors so we suppress them here + if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384 /* Union */))) { + return result; + } + } + if (target.flags & 16384 /* Union */) { + if (result = typeRelatedToSomeType(source, target, reportErrors)) { + return result; + } + } + } + } + else { + if (source.flags & 16384 /* Union */ && target.flags & 16384 /* Union */ || + source.flags & 32768 /* Intersection */ && target.flags & 32768 /* Intersection */) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { + return result; + } + } } } // Even if relationship doesn't hold for unions, type parameters, or generic type references, // it may hold in a structural comparison. // Report structural errors only if we haven't reported any errors yet var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; - // identity relation does not use apparent type + // Identity relation does not use apparent type var sourceOrApparentType = relation === identityRelation ? source : getApparentType(source); - if (sourceOrApparentType.flags & 48128 /* ObjectType */ && target.flags & 48128 /* ObjectType */) { + // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates + // to X. Failing both of those we want to check if the aggregation of A and B's members structurally + // relates to X. Thus, we include intersection types on the source side here. + if (sourceOrApparentType.flags & (80896 /* ObjectType */ | 32768 /* Intersection */) && target.flags & 80896 /* ObjectType */) { if (result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors)) { errorInfo = saveErrorInfo; return result; } } - else if (source.flags & 512 /* TypeParameter */ && sourceOrApparentType.flags & 16384 /* Union */) { + else if (source.flags & 512 /* TypeParameter */ && sourceOrApparentType.flags & 49152 /* UnionOrIntersection */) { // We clear the errors first because the following check often gives a better error than - // the union comparison above if it is applicable. + // the union or intersection comparison above if it is applicable. errorInfo = saveErrorInfo; if (result = isRelatedTo(sourceOrApparentType, target, reportErrors)) { return result; @@ -16208,12 +16911,12 @@ var ts; } return 0 /* False */; } - function unionTypeRelatedToUnionType(source, target) { + function eachTypeRelatedToSomeType(source, target) { var result = -1 /* True */; var sourceTypes = source.types; for (var _i = 0; _i < sourceTypes.length; _i++) { var sourceType = sourceTypes[_i]; - var related = typeRelatedToUnionType(sourceType, target, false); + var related = typeRelatedToSomeType(sourceType, target, false); if (!related) { return 0 /* False */; } @@ -16221,7 +16924,7 @@ var ts; } return result; } - function typeRelatedToUnionType(source, target, reportErrors) { + function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; for (var i = 0, len = targetTypes.length; i < len; i++) { var related = isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1); @@ -16231,7 +16934,30 @@ var ts; } return 0 /* False */; } - function unionTypeRelatedToType(source, target, reportErrors) { + function typeRelatedToEachType(source, target, reportErrors) { + var result = -1 /* True */; + var targetTypes = target.types; + for (var _i = 0; _i < targetTypes.length; _i++) { + var targetType = targetTypes[_i]; + var related = isRelatedTo(source, targetType, reportErrors); + if (!related) { + return 0 /* False */; + } + result &= related; + } + return result; + } + function someTypeRelatedToType(source, target, reportErrors) { + var sourceTypes = source.types; + for (var i = 0, len = sourceTypes.length; i < len; i++) { + var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); + if (related) { + return related; + } + } + return 0 /* False */; + } + function eachTypeRelatedToType(source, target, reportErrors) { var result = -1 /* True */; var sourceTypes = source.types; for (var _i = 0; _i < sourceTypes.length; _i++) { @@ -16292,7 +17018,6 @@ var ts; } var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; var related = relation[id]; - //let related: RelationComparisonResult = undefined; // relation[id]; if (related !== undefined) { // If we computed this relation already and it was failed and reported, or if we're not being asked to elaborate // errors, we can use the cached value. Otherwise, recompute the relation @@ -16368,7 +17093,7 @@ var ts; } var result = -1 /* True */; var properties = getPropertiesOfObjectType(target); - var requireOptionalProperties = relation === subtypeRelation && !(source.flags & 262144 /* ObjectLiteral */); + var requireOptionalProperties = relation === subtypeRelation && !(source.flags & 524288 /* ObjectLiteral */); for (var _i = 0; _i < properties.length; _i++) { var targetProp = properties[_i]; var sourceProp = getPropertyOfType(source, targetProp.name); @@ -16382,22 +17107,22 @@ var ts; } } else if (!(targetProp.flags & 134217728 /* Prototype */)) { - var sourceFlags = getDeclarationFlagsFromSymbol(sourceProp); - var targetFlags = getDeclarationFlagsFromSymbol(targetProp); - if (sourceFlags & 32 /* Private */ || targetFlags & 32 /* Private */) { + var sourcePropFlags = getDeclarationFlagsFromSymbol(sourceProp); + var targetPropFlags = getDeclarationFlagsFromSymbol(targetProp); + if (sourcePropFlags & 32 /* Private */ || targetPropFlags & 32 /* Private */) { if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { - if (sourceFlags & 32 /* Private */ && targetFlags & 32 /* Private */) { + if (sourcePropFlags & 32 /* Private */ && targetPropFlags & 32 /* Private */) { reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); } else { - reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourceFlags & 32 /* Private */ ? source : target), typeToString(sourceFlags & 32 /* Private */ ? target : source)); + reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 32 /* Private */ ? source : target), typeToString(sourcePropFlags & 32 /* Private */ ? target : source)); } } return 0 /* False */; } } - else if (targetFlags & 64 /* Protected */) { + else if (targetPropFlags & 64 /* Protected */) { var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32 /* Class */; var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(sourceProp.parent) : undefined; var targetClass = getDeclaredTypeOfSymbol(targetProp.parent); @@ -16408,7 +17133,7 @@ var ts; return 0 /* False */; } } - else if (sourceFlags & 64 /* Protected */) { + else if (sourcePropFlags & 64 /* Protected */) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } @@ -16441,6 +17166,9 @@ var ts; return result; } function propertiesIdenticalTo(source, target) { + if (!(source.flags & 80896 /* ObjectType */ && target.flags & 80896 /* ObjectType */)) { + return 0 /* False */; + } var sourceProperties = getPropertiesOfObjectType(source); var targetProperties = getPropertiesOfObjectType(target); if (sourceProperties.length !== targetProperties.length) { @@ -16474,11 +17202,11 @@ var ts; var saveErrorInfo = errorInfo; outer: for (var _i = 0; _i < targetSignatures.length; _i++) { var t = targetSignatures[_i]; - if (!t.hasStringLiterals || target.flags & 131072 /* FromSignature */) { + if (!t.hasStringLiterals || target.flags & 262144 /* FromSignature */) { var localErrors = reportErrors; for (var _a = 0; _a < sourceSignatures.length; _a++) { var s = sourceSignatures[_a]; - if (!s.hasStringLiterals || source.flags & 131072 /* FromSignature */) { + if (!s.hasStringLiterals || source.flags & 262144 /* FromSignature */) { var related = signatureRelatedTo(s, t, localErrors); if (related) { result &= related; @@ -16666,12 +17394,12 @@ var ts; // some level beyond that. function isDeeplyNestedGeneric(type, stack, depth) { // We track type references (created by createTypeReference) and instantiated types (created by instantiateType) - if (type.flags & (4096 /* Reference */ | 65536 /* Instantiated */) && depth >= 5) { + if (type.flags & (4096 /* Reference */ | 131072 /* Instantiated */) && depth >= 5) { var symbol = type.symbol; var count = 0; for (var i = 0; i < depth; i++) { var t = stack[i]; - if (t.flags & (4096 /* Reference */ | 65536 /* Instantiated */) && t.symbol === symbol) { + if (t.flags & (4096 /* Reference */ | 131072 /* Instantiated */) && t.symbol === symbol) { count++; if (count >= 5) return true; @@ -16838,11 +17566,11 @@ var ts; return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); } function getWidenedType(type) { - if (type.flags & 1572864 /* RequiresWidening */) { + if (type.flags & 3145728 /* RequiresWidening */) { if (type.flags & (32 /* Undefined */ | 64 /* Null */)) { return anyType; } - if (type.flags & 262144 /* ObjectLiteral */) { + if (type.flags & 524288 /* ObjectLiteral */) { return getWidenedTypeOfObjectLiteral(type); } if (type.flags & 16384 /* Union */) { @@ -16867,11 +17595,11 @@ var ts; if (isArrayType(type)) { return reportWideningErrorsInType(type.typeArguments[0]); } - if (type.flags & 262144 /* ObjectLiteral */) { + if (type.flags & 524288 /* ObjectLiteral */) { var errorReported = false; ts.forEach(getPropertiesOfObjectType(type), function (p) { var t = getTypeOfSymbol(p); - if (t.flags & 524288 /* ContainsUndefinedOrNull */) { + if (t.flags & 1048576 /* ContainsUndefinedOrNull */) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); } @@ -16886,22 +17614,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 131 /* Parameter */: + case 135 /* Parameter */: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 203 /* FunctionDeclaration */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 165 /* FunctionExpression */: - case 166 /* ArrowFunction */: + case 210 /* FunctionDeclaration */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -16914,7 +17642,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 524288 /* ContainsUndefinedOrNull */) { + if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 1048576 /* ContainsUndefinedOrNull */) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); @@ -17010,11 +17738,11 @@ var ts; inferFromTypes(sourceTypes[i], targetTypes[i]); } } - else if (target.flags & 16384 /* Union */) { + else if (target.flags & 49152 /* UnionOrIntersection */) { var targetTypes = target.types; var typeParameterCount = 0; var typeParameter; - // First infer to each type in union that isn't a type parameter + // First infer to each type in union or intersection that isn't a type parameter for (var _i = 0; _i < targetTypes.length; _i++) { var t = targetTypes[_i]; if (t.flags & 512 /* TypeParameter */ && ts.contains(context.typeParameters, t)) { @@ -17025,23 +17753,26 @@ var ts; inferFromTypes(source, t); } } - // If union contains a single naked type parameter, make a secondary inference to that type parameter - if (typeParameterCount === 1) { + // Next, if target is a union type containing a single naked type parameter, make a + // secondary inference to that type parameter. We don't do this for intersection types + // because in a target type like Foo & T we don't know how which parts of the source type + // should be matched by Foo and which should be inferred to T. + if (target.flags & 16384 /* Union */ && typeParameterCount === 1) { inferiority++; inferFromTypes(source, typeParameter); inferiority--; } } - else if (source.flags & 16384 /* Union */) { - // Source is a union type, infer from each consituent type + else if (source.flags & 49152 /* UnionOrIntersection */) { + // Source is a union or intersection type, infer from each consituent type var sourceTypes = source.types; for (var _a = 0; _a < sourceTypes.length; _a++) { var sourceType = sourceTypes[_a]; inferFromTypes(sourceType, target); } } - else if (source.flags & 48128 /* ObjectType */ && (target.flags & (4096 /* Reference */ | 8192 /* Tuple */) || - (target.flags & 32768 /* Anonymous */) && target.symbol && target.symbol.flags & (8192 /* Method */ | 2048 /* TypeLiteral */))) { + else if (source.flags & 80896 /* ObjectType */ && (target.flags & (4096 /* Reference */ | 8192 /* Tuple */) || + (target.flags & 65536 /* Anonymous */) && target.symbol && target.symbol.flags & (8192 /* Method */ | 2048 /* TypeLiteral */ | 32 /* Class */))) { // If source is an object type, and target is a type reference, a tuple type, the type of a method, or a type literal, infer from members if (isInProcess(source, target)) { return; @@ -17170,10 +17901,10 @@ var ts; // The expression is restricted to a single identifier or a sequence of identifiers separated by periods while (node) { switch (node.kind) { - case 147 /* TypeQuery */: + case 151 /* TypeQuery */: return true; - case 65 /* Identifier */: - case 128 /* QualifiedName */: + case 66 /* Identifier */: + case 132 /* QualifiedName */: node = node.parent; continue; default: @@ -17219,12 +17950,12 @@ var ts; } return links.assignmentChecks[symbol.id] = isAssignedIn(node); function isAssignedInBinaryExpression(node) { - if (node.operatorToken.kind >= 53 /* FirstAssignment */ && node.operatorToken.kind <= 64 /* LastAssignment */) { + if (node.operatorToken.kind >= 54 /* FirstAssignment */ && node.operatorToken.kind <= 65 /* LastAssignment */) { var n = node.left; - while (n.kind === 164 /* ParenthesizedExpression */) { + while (n.kind === 169 /* ParenthesizedExpression */) { n = n.expression; } - if (n.kind === 65 /* Identifier */ && getResolvedSymbol(n) === symbol) { + if (n.kind === 66 /* Identifier */ && getResolvedSymbol(n) === symbol) { return true; } } @@ -17238,46 +17969,55 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 172 /* BinaryExpression */: + case 178 /* BinaryExpression */: return isAssignedInBinaryExpression(node); - case 201 /* VariableDeclaration */: - case 155 /* BindingElement */: + case 208 /* VariableDeclaration */: + case 160 /* BindingElement */: return isAssignedInVariableDeclaration(node); - case 153 /* ObjectBindingPattern */: - case 154 /* ArrayBindingPattern */: - case 156 /* ArrayLiteralExpression */: - case 157 /* ObjectLiteralExpression */: - case 158 /* PropertyAccessExpression */: - case 159 /* ElementAccessExpression */: - case 160 /* CallExpression */: - case 161 /* NewExpression */: - case 163 /* TypeAssertionExpression */: - case 164 /* ParenthesizedExpression */: - case 170 /* PrefixUnaryExpression */: - case 167 /* DeleteExpression */: - case 168 /* TypeOfExpression */: - case 169 /* VoidExpression */: - case 171 /* PostfixUnaryExpression */: - case 173 /* ConditionalExpression */: - case 176 /* SpreadElementExpression */: - case 182 /* Block */: - case 183 /* VariableStatement */: - case 185 /* ExpressionStatement */: - case 186 /* IfStatement */: - case 187 /* DoStatement */: - case 188 /* WhileStatement */: - case 189 /* ForStatement */: - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: - case 194 /* ReturnStatement */: - case 195 /* WithStatement */: - case 196 /* SwitchStatement */: - case 223 /* CaseClause */: - case 224 /* DefaultClause */: - case 197 /* LabeledStatement */: - case 198 /* ThrowStatement */: - case 199 /* TryStatement */: - case 226 /* CatchClause */: + case 158 /* ObjectBindingPattern */: + case 159 /* ArrayBindingPattern */: + case 161 /* ArrayLiteralExpression */: + case 162 /* ObjectLiteralExpression */: + case 163 /* PropertyAccessExpression */: + case 164 /* ElementAccessExpression */: + case 165 /* CallExpression */: + case 166 /* NewExpression */: + case 168 /* TypeAssertionExpression */: + case 186 /* AsExpression */: + case 169 /* ParenthesizedExpression */: + case 176 /* PrefixUnaryExpression */: + case 172 /* DeleteExpression */: + case 175 /* AwaitExpression */: + case 173 /* TypeOfExpression */: + case 174 /* VoidExpression */: + case 177 /* PostfixUnaryExpression */: + case 181 /* YieldExpression */: + case 179 /* ConditionalExpression */: + case 182 /* SpreadElementExpression */: + case 189 /* Block */: + case 190 /* VariableStatement */: + case 192 /* ExpressionStatement */: + case 193 /* IfStatement */: + case 194 /* DoStatement */: + case 195 /* WhileStatement */: + case 196 /* ForStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: + case 201 /* ReturnStatement */: + case 202 /* WithStatement */: + case 203 /* SwitchStatement */: + case 238 /* CaseClause */: + case 239 /* DefaultClause */: + case 204 /* LabeledStatement */: + case 205 /* ThrowStatement */: + case 206 /* TryStatement */: + case 241 /* CatchClause */: + case 230 /* JsxElement */: + case 231 /* JsxSelfClosingElement */: + case 235 /* JsxAttribute */: + case 236 /* JsxSpreadAttribute */: + case 232 /* JsxOpeningElement */: + case 237 /* JsxExpression */: return ts.forEachChild(node, isAssignedIn); } return false; @@ -17324,43 +18064,43 @@ var ts; var type = getTypeOfSymbol(symbol); // Only narrow when symbol is variable of type any or an object, union, or type parameter type if (node && symbol.flags & 3 /* Variable */) { - if (isTypeAny(type) || type.flags & (48128 /* ObjectType */ | 16384 /* Union */ | 512 /* TypeParameter */)) { + if (isTypeAny(type) || type.flags & (80896 /* ObjectType */ | 16384 /* Union */ | 512 /* TypeParameter */)) { loop: while (node.parent) { var child = node; node = node.parent; var narrowedType = type; switch (node.kind) { - case 186 /* IfStatement */: + case 193 /* IfStatement */: // In a branch of an if statement, narrow based on controlling expression if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 173 /* ConditionalExpression */: + case 179 /* ConditionalExpression */: // In a branch of a conditional expression, narrow based on controlling condition if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 172 /* BinaryExpression */: + case 178 /* BinaryExpression */: // In the right operand of an && or ||, narrow based on left operand if (child === node.right) { - if (node.operatorToken.kind === 48 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 49 /* AmpersandAmpersandToken */) { narrowedType = narrowType(type, node.left, true); } - else if (node.operatorToken.kind === 49 /* BarBarToken */) { + else if (node.operatorToken.kind === 50 /* BarBarToken */) { narrowedType = narrowType(type, node.left, false); } } break; - case 230 /* SourceFile */: - case 208 /* ModuleDeclaration */: - case 203 /* FunctionDeclaration */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 137 /* Constructor */: + case 245 /* SourceFile */: + case 215 /* ModuleDeclaration */: + case 210 /* FunctionDeclaration */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 141 /* Constructor */: // Stop at the first containing function or module declaration break loop; } @@ -17377,22 +18117,22 @@ var ts; return type; function narrowTypeByEquality(type, expr, assumeTrue) { // Check that we have 'typeof ' on the left and string literal on the right - if (expr.left.kind !== 168 /* TypeOfExpression */ || expr.right.kind !== 8 /* StringLiteral */) { + if (expr.left.kind !== 173 /* TypeOfExpression */ || expr.right.kind !== 8 /* StringLiteral */) { return type; } var left = expr.left; var right = expr.right; - if (left.expression.kind !== 65 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) { + if (left.expression.kind !== 66 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) { return type; } var typeInfo = primitiveTypeInfo[right.text]; - if (expr.operatorToken.kind === 31 /* ExclamationEqualsEqualsToken */) { + if (expr.operatorToken.kind === 32 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } if (assumeTrue) { // Assumed result is true. If check was not for a primitive type, remove all primitive types if (!typeInfo) { - return removeTypesFromUnionType(type, 258 /* StringLike */ | 132 /* NumberLike */ | 8 /* Boolean */ | 2097152 /* ESSymbol */, + return removeTypesFromUnionType(type, 258 /* StringLike */ | 132 /* NumberLike */ | 8 /* Boolean */ | 4194304 /* ESSymbol */, /*isOfTypeKind*/ true, false); } // Check was for a primitive type, return that primitive type if it is a subtype @@ -17442,7 +18182,7 @@ var ts; } function narrowTypeByInstanceof(type, expr, assumeTrue) { // Check that type is not any, assumed result is true, and we have variable symbol on the left - if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 65 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { + if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 66 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { return type; } // Check that right operand is a function type with a prototype property @@ -17465,7 +18205,7 @@ var ts; if (rightType.flags & 2048 /* Interface */) { constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures; } - else if (rightType.flags & 32768 /* Anonymous */) { + else if (rightType.flags & 65536 /* Anonymous */) { constructSignatures = getSignaturesOfType(rightType, 1 /* Construct */); } if (constructSignatures && constructSignatures.length) { @@ -17510,27 +18250,27 @@ var ts; // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 160 /* CallExpression */: + case 165 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 164 /* ParenthesizedExpression */: + case 169 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 172 /* BinaryExpression */: + case 178 /* BinaryExpression */: var operator = expr.operatorToken.kind; - if (operator === 30 /* EqualsEqualsEqualsToken */ || operator === 31 /* ExclamationEqualsEqualsToken */) { + if (operator === 31 /* EqualsEqualsEqualsToken */ || operator === 32 /* ExclamationEqualsEqualsToken */) { return narrowTypeByEquality(type, expr, assumeTrue); } - else if (operator === 48 /* AmpersandAmpersandToken */) { + else if (operator === 49 /* AmpersandAmpersandToken */) { return narrowTypeByAnd(type, expr, assumeTrue); } - else if (operator === 49 /* BarBarToken */) { + else if (operator === 50 /* BarBarToken */) { return narrowTypeByOr(type, expr, assumeTrue); } - else if (operator === 87 /* InstanceOfKeyword */) { + else if (operator === 88 /* InstanceOfKeyword */) { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 170 /* PrefixUnaryExpression */: - if (expr.operator === 46 /* ExclamationToken */) { + case 176 /* PrefixUnaryExpression */: + if (expr.operator === 47 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -17546,8 +18286,17 @@ var ts; // will be bound to non-arrow function that contain this arrow function. This results in inconsistent behavior. // To avoid that we will give an error to users if they use arguments objects in arrow function so that they // can explicitly bound arguments objects - if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 166 /* ArrowFunction */ && languageVersion < 2 /* ES6 */) { - error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); + if (symbol === argumentsSymbol) { + var container = ts.getContainingFunction(node); + if (container.kind === 171 /* ArrowFunction */) { + if (languageVersion < 2 /* ES6 */) { + error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); + } + } + if (node.parserContextFlags & 8 /* Await */) { + getNodeLinks(container).flags |= 4096 /* CaptureArguments */; + getNodeLinks(node).flags |= 2048 /* LexicalArguments */; + } } if (symbol.flags & 8388608 /* Alias */ && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { markAliasSymbolAsReferenced(symbol); @@ -17570,7 +18319,7 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 /* ES6 */ || (symbol.flags & 2 /* BlockScopedVariable */) === 0 || - symbol.valueDeclaration.parent.kind === 226 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 241 /* CatchClause */) { return; } // - check if binding is used in some function @@ -17579,12 +18328,12 @@ var ts; // nesting structure: // (variable declaration or binding element) -> variable declaration list -> container var container = symbol.valueDeclaration; - while (container.kind !== 202 /* VariableDeclarationList */) { + while (container.kind !== 209 /* VariableDeclarationList */) { container = container.parent; } // get the parent of variable declaration list container = container.parent; - if (container.kind === 183 /* VariableStatement */) { + if (container.kind === 190 /* VariableStatement */) { // if parent is variable statement - get its parent container = container.parent; } @@ -17596,7 +18345,7 @@ var ts; grammarErrorOnFirstToken(current, ts.Diagnostics.Loop_contains_block_scoped_variable_0_referenced_by_a_function_in_the_loop_This_is_only_supported_in_ECMAScript_6_or_higher, ts.declarationNameToString(node)); } // mark value declaration so during emit they can have a special handling - getNodeLinks(symbol.valueDeclaration).flags |= 256 /* BlockScopedBindingInLoop */; + getNodeLinks(symbol.valueDeclaration).flags |= 16384 /* BlockScopedBindingInLoop */; break; } current = current.parent; @@ -17604,7 +18353,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 134 /* PropertyDeclaration */ || container.kind === 137 /* Constructor */) { + if (container.kind === 138 /* PropertyDeclaration */ || container.kind === 141 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -17618,32 +18367,32 @@ var ts; var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 166 /* ArrowFunction */) { + if (container.kind === 171 /* ArrowFunction */) { container = ts.getThisContainer(container, false); // When targeting es6, arrow function lexically bind "this" so we do not need to do the work of binding "this" in emitted code needToCaptureLexicalThis = (languageVersion < 2 /* ES6 */); } switch (container.kind) { - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 207 /* EnumDeclaration */: + case 214 /* EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 137 /* Constructor */: + case 141 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: if (container.flags & 128 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 129 /* ComputedPropertyName */: + case 133 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -17658,14 +18407,14 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 131 /* Parameter */) { + if (n.kind === 135 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 160 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 165 /* CallExpression */ && node.parent.expression === node; var classDeclaration = ts.getContainingClass(node); var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); var baseClassType = classType && getBaseTypes(classType)[0]; @@ -17682,7 +18431,7 @@ var ts; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - canUseSuperExpression = container.kind === 137 /* Constructor */; + canUseSuperExpression = container.kind === 141 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -17691,7 +18440,7 @@ var ts; // - In a static member function or static member accessor // super property access might appear in arrow functions with arbitrary deep nesting needToCaptureLexicalThis = false; - while (container && container.kind === 166 /* ArrowFunction */) { + while (container && container.kind === 171 /* ArrowFunction */) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; } @@ -17699,34 +18448,34 @@ var ts; if (container && ts.isClassLike(container.parent)) { if (container.flags & 128 /* Static */) { canUseSuperExpression = - container.kind === 136 /* MethodDeclaration */ || - container.kind === 135 /* MethodSignature */ || - container.kind === 138 /* GetAccessor */ || - container.kind === 139 /* SetAccessor */; + container.kind === 140 /* MethodDeclaration */ || + container.kind === 139 /* MethodSignature */ || + container.kind === 142 /* GetAccessor */ || + container.kind === 143 /* SetAccessor */; } else { canUseSuperExpression = - container.kind === 136 /* MethodDeclaration */ || - container.kind === 135 /* MethodSignature */ || - container.kind === 138 /* GetAccessor */ || - container.kind === 139 /* SetAccessor */ || - container.kind === 134 /* PropertyDeclaration */ || - container.kind === 133 /* PropertySignature */ || - container.kind === 137 /* Constructor */; + container.kind === 140 /* MethodDeclaration */ || + container.kind === 139 /* MethodSignature */ || + container.kind === 142 /* GetAccessor */ || + container.kind === 143 /* SetAccessor */ || + container.kind === 138 /* PropertyDeclaration */ || + container.kind === 137 /* PropertySignature */ || + container.kind === 141 /* Constructor */; } } } if (canUseSuperExpression) { var returnType; if ((container.flags & 128 /* Static */) || isCallExpression) { - getNodeLinks(node).flags |= 32 /* SuperStatic */; + getNodeLinks(node).flags |= 512 /* SuperStatic */; returnType = getBaseConstructorTypeOfClass(classType); } else { - getNodeLinks(node).flags |= 16 /* SuperInstance */; + getNodeLinks(node).flags |= 256 /* SuperInstance */; returnType = baseClassType; } - if (container.kind === 137 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 141 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); returnType = unknownType; @@ -17740,7 +18489,7 @@ var ts; return returnType; } } - if (container && container.kind === 129 /* ComputedPropertyName */) { + if (container && container.kind === 133 /* ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { @@ -17785,7 +18534,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 131 /* Parameter */) { + if (declaration.kind === 135 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -17816,12 +18565,21 @@ var ts; } return undefined; } + function isInParameterInitializerBeforeContainingFunction(node) { + while (node.parent && !ts.isFunctionLike(node.parent)) { + if (node.parent.kind === 135 /* Parameter */ && node.parent.initializer === node) { + return true; + } + node = node.parent; + } + return false; + } function getContextualReturnType(functionDecl) { // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed if (functionDecl.type || - functionDecl.kind === 137 /* Constructor */ || - functionDecl.kind === 138 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 139 /* SetAccessor */))) { + functionDecl.kind === 141 /* Constructor */ || + functionDecl.kind === 142 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 143 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature @@ -17843,7 +18601,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 162 /* TaggedTemplateExpression */) { + if (template.parent.kind === 167 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -17851,13 +18609,13 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 53 /* FirstAssignment */ && operator <= 64 /* LastAssignment */) { + if (operator >= 54 /* FirstAssignment */ && operator <= 65 /* LastAssignment */) { // In an assignment expression, the right operand is contextually typed by the type of the left operand. if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); } } - else if (operator === 49 /* BarBarToken */) { + else if (operator === 50 /* BarBarToken */) { // When an || expression has a contextual type, the operands are contextually typed by that type. When an || // expression has no contextual type, the right operand is contextually typed by the type of the left operand. var type = getContextualType(binaryExpression); @@ -17897,12 +18655,12 @@ var ts; } function getTypeOfPropertyOfContextualType(type, name) { return applyToContextualType(type, function (t) { - var prop = getPropertyOfObjectType(t, name); + var prop = t.flags & 130048 /* StructuredType */ ? getPropertyOfType(t, name) : undefined; return prop ? getTypeOfSymbol(prop) : undefined; }); } function getIndexTypeOfContextualType(type, kind) { - return applyToContextualType(type, function (t) { return getIndexTypeOfObjectOrUnionType(t, kind); }); + return applyToContextualType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }); } // Return true if the given contextual type is a tuple-like type function contextualTypeIsTupleLikeType(type) { @@ -17910,7 +18668,7 @@ var ts; } // Return true if the given contextual type provides an index signature of the given kind function contextualTypeHasIndexSignature(type, kind) { - return !!(type.flags & 16384 /* Union */ ? ts.forEach(type.types, function (t) { return getIndexTypeOfObjectOrUnionType(t, kind); }) : getIndexTypeOfObjectOrUnionType(type, kind)); + return !!(type.flags & 16384 /* Union */ ? ts.forEach(type.types, function (t) { return getIndexTypeOfStructuredType(t, kind); }) : getIndexTypeOfStructuredType(type, kind)); } // In an object literal contextually typed by a type T, the contextual type of a property assignment is the type of // the matching property in T, if one exists. Otherwise, it is the type of the numeric index signature in T, if one @@ -17962,9 +18720,30 @@ var ts; var conditional = node.parent; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } + function getContextualTypeForJsxExpression(expr) { + // Contextual type only applies to JSX expressions that are in attribute assignments (not in 'Children' positions) + if (expr.parent.kind === 235 /* JsxAttribute */) { + var attrib = expr.parent; + var attrsType = getJsxElementAttributesType(attrib.parent); + if (!attrsType || isTypeAny(attrsType)) { + return undefined; + } + else { + return getTypeOfPropertyOfType(attrsType, attrib.name.text); + } + } + if (expr.kind === 236 /* JsxSpreadAttribute */) { + return getJsxElementAttributesType(expr.parent); + } + return undefined; + } // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily // be "pushed" onto a node using the contextualType property. function getContextualType(node) { + var type = getContextualTypeWorker(node); + return type && getApparentType(type); + } + function getContextualTypeWorker(node) { if (isInsideWithStatementBody(node)) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; @@ -17974,42 +18753,46 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 201 /* VariableDeclaration */: - case 131 /* Parameter */: - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: - case 155 /* BindingElement */: + case 208 /* VariableDeclaration */: + case 135 /* Parameter */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: + case 160 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 166 /* ArrowFunction */: - case 194 /* ReturnStatement */: + case 171 /* ArrowFunction */: + case 201 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 175 /* YieldExpression */: + case 181 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 160 /* CallExpression */: - case 161 /* NewExpression */: + case 165 /* CallExpression */: + case 166 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 163 /* TypeAssertionExpression */: + case 168 /* TypeAssertionExpression */: + case 186 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 172 /* BinaryExpression */: + case 178 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 227 /* PropertyAssignment */: + case 242 /* PropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 156 /* ArrayLiteralExpression */: + case 161 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 173 /* ConditionalExpression */: + case 179 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 180 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 174 /* TemplateExpression */); + case 187 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 180 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 164 /* ParenthesizedExpression */: + case 169 /* ParenthesizedExpression */: return getContextualType(parent); + case 237 /* JsxExpression */: + case 236 /* JsxSpreadAttribute */: + return getContextualTypeForJsxExpression(parent); } return undefined; } // If the given type is an object or union type, if that type has a single signature, and if // that signature is non-generic, return the signature. Otherwise return undefined. function getNonGenericSignature(type) { - var signatures = getSignaturesOfObjectOrUnionType(type, 0 /* Call */); + var signatures = getSignaturesOfStructuredType(type, 0 /* Call */); if (signatures.length === 1) { var signature = signatures[0]; if (!signature.typeParameters) { @@ -18018,7 +18801,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 165 /* FunctionExpression */ || node.kind === 166 /* ArrowFunction */; + return node.kind === 170 /* FunctionExpression */ || node.kind === 171 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -18032,7 +18815,7 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 136 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 140 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -18049,7 +18832,7 @@ var ts; // The signature set of all constituent type with call signatures should match // So number of signatures allowed is either 0 or 1 if (signatureList && - getSignaturesOfObjectOrUnionType(current, 0 /* Call */).length > 1) { + getSignaturesOfStructuredType(current, 0 /* Call */).length > 1) { return undefined; } var signature = getNonGenericSignature(current); @@ -18088,13 +18871,13 @@ var ts; // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ p: a}] = xxx'. function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 172 /* BinaryExpression */ && parent.operatorToken.kind === 53 /* EqualsToken */ && parent.left === node) { + if (parent.kind === 178 /* BinaryExpression */ && parent.operatorToken.kind === 54 /* EqualsToken */ && parent.left === node) { return true; } - if (parent.kind === 227 /* PropertyAssignment */) { + if (parent.kind === 242 /* PropertyAssignment */) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 156 /* ArrayLiteralExpression */) { + if (parent.kind === 161 /* ArrayLiteralExpression */) { return isAssignmentTarget(parent); } return false; @@ -18119,7 +18902,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 176 /* SpreadElementExpression */) { + if (inDestructuringPattern && e.kind === 182 /* SpreadElementExpression */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -18127,7 +18910,7 @@ var ts; // c is represented in the tree as a spread element in an array literal. // But c really functions as a rest element, and its purpose is to provide // a contextual type for the right hand side of the assignment. Therefore, - // instead of calling checkExpression on "...c", which will give an error + // instead of calling checkExpression on "...c", which will give an error // if c is not iterable/array-like, we need to act as if we are trying to // get the contextual element type from it. So we do something similar to // getContextualTypeForElementExpression, which will crucially not error @@ -18143,7 +18926,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 176 /* SpreadElementExpression */; + hasSpreadElement = hasSpreadElement || e.kind === 182 /* SpreadElementExpression */; } if (!hasSpreadElement) { var contextualType = getContextualType(node); @@ -18154,7 +18937,7 @@ var ts; return createArrayType(getUnionType(elementTypes)); } function isNumericName(name) { - return name.kind === 129 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 133 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { // It seems odd to consider an expression of type Any to result in a numeric name, @@ -18194,7 +18977,7 @@ var ts; links.resolvedType = checkExpression(node.expression); // This will allow types number, string, symbol or any. It will also allow enums, the unknown // type, and any union of these types (like string | number). - if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 /* NumberLike */ | 258 /* StringLike */ | 2097152 /* ESSymbol */)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 /* NumberLike */ | 258 /* StringLike */ | 4194304 /* ESSymbol */)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } else { @@ -18213,18 +18996,18 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 227 /* PropertyAssignment */ || - memberDecl.kind === 228 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 242 /* PropertyAssignment */ || + memberDecl.kind === 243 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 227 /* PropertyAssignment */) { + if (memberDecl.kind === 242 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 136 /* MethodDeclaration */) { + else if (memberDecl.kind === 140 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 228 /* ShorthandPropertyAssignment */); + ts.Debug.assert(memberDecl.kind === 243 /* ShorthandPropertyAssignment */); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -18244,7 +19027,7 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 138 /* GetAccessor */ || memberDecl.kind === 139 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 142 /* GetAccessor */ || memberDecl.kind === 143 /* SetAccessor */); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -18255,7 +19038,7 @@ var ts; var stringIndexType = getIndexType(0 /* String */); var numberIndexType = getIndexType(1 /* Number */); var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); - result.flags |= 262144 /* ObjectLiteral */ | 1048576 /* ContainsObjectLiteral */ | (typeFlags & 524288 /* ContainsUndefinedOrNull */); + result.flags |= 524288 /* ObjectLiteral */ | 2097152 /* ContainsObjectLiteral */ | (typeFlags & 1048576 /* ContainsUndefinedOrNull */); return result; function getIndexType(kind) { if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { @@ -18280,50 +19063,475 @@ var ts; return undefined; } } + function checkJsxSelfClosingElement(node) { + checkJsxOpeningLikeElement(node); + return jsxElementType || anyType; + } + function tagNamesAreEquivalent(lhs, rhs) { + if (lhs.kind !== rhs.kind) { + return false; + } + if (lhs.kind === 66 /* Identifier */) { + return lhs.text === rhs.text; + } + return lhs.right.text === rhs.right.text && + tagNamesAreEquivalent(lhs.left, rhs.left); + } + function checkJsxElement(node) { + // Check that the closing tag matches + if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) { + error(node.closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNode(node.openingElement.tagName)); + } + // Check attributes + checkJsxOpeningLikeElement(node.openingElement); + // Check children + for (var _i = 0, _a = node.children; _i < _a.length; _i++) { + var child = _a[_i]; + switch (child.kind) { + case 237 /* JsxExpression */: + checkJsxExpression(child); + break; + case 230 /* JsxElement */: + checkJsxElement(child); + break; + case 231 /* JsxSelfClosingElement */: + checkJsxSelfClosingElement(child); + break; + default: + // No checks for JSX Text + ts.Debug.assert(child.kind === 233 /* JsxText */); + } + } + return jsxElementType || anyType; + } + /** + * Returns true iff the JSX element name would be a valid JS identifier, ignoring restrictions about keywords not being identifiers + */ + function isUnhyphenatedJsxName(name) { + // - is the only character supported in JSX attribute names that isn't valid in JavaScript identifiers + return name.indexOf("-") < 0; + } + /** + * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name + */ + function isJsxIntrinsicIdentifier(tagName) { + if (tagName.kind === 132 /* QualifiedName */) { + return false; + } + else { + return ts.isIntrinsicJsxName(tagName.text); + } + } + function checkJsxAttribute(node, elementAttributesType, nameTable) { + var correspondingPropType = undefined; + // Look up the corresponding property for this attribute + if (elementAttributesType === emptyObjectType && isUnhyphenatedJsxName(node.name.text)) { + // If there is no 'props' property, you may not have non-"data-" attributes + error(node.parent, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, getJsxElementPropertiesName()); + } + else if (elementAttributesType && !isTypeAny(elementAttributesType)) { + var correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); + correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); + // If there's no corresponding property with this name, error + if (!correspondingPropType && isUnhyphenatedJsxName(node.name.text)) { + error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); + return unknownType; + } + } + var exprType; + if (node.initializer) { + exprType = checkExpression(node.initializer); + } + else { + // is sugar for + exprType = booleanType; + } + if (correspondingPropType) { + checkTypeAssignableTo(exprType, correspondingPropType, node); + } + nameTable[node.name.text] = true; + return exprType; + } + function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { + var type = checkExpression(node.expression); + var props = getPropertiesOfType(type); + for (var _i = 0; _i < props.length; _i++) { + var prop = props[_i]; + // Is there a corresponding property in the element attributes type? Skip checking of properties + // that have already been assigned to, as these are not actually pushed into the resulting type + if (!nameTable[prop.name]) { + var targetPropSym = getPropertyOfType(elementAttributesType, prop.name); + if (targetPropSym) { + var msg = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property, prop.name); + checkTypeAssignableTo(getTypeOfSymbol(prop), getTypeOfSymbol(targetPropSym), node, undefined, msg); + } + nameTable[prop.name] = true; + } + } + return type; + } + /// Returns the type JSX.IntrinsicElements. May return `unknownType` if that type is not present. + function getJsxIntrinsicElementsType() { + if (!jsxIntrinsicElementsType) { + jsxIntrinsicElementsType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.IntrinsicElements) || unknownType; + } + return jsxIntrinsicElementsType; + } + /// Given a JSX opening element or self-closing element, return the symbol of the property that the tag name points to if + /// this is an intrinsic tag. This might be a named + /// property of the IntrinsicElements interface, or its string indexer. + /// If this is a class-based tag (otherwise returns undefined), returns the symbol of the class + /// type or factory function. + /// Otherwise, returns unknownSymbol. + function getJsxElementTagSymbol(node) { + var flags = 8 /* UnknownElement */; + var links = getNodeLinks(node); + if (!links.resolvedSymbol) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + links.resolvedSymbol = lookupIntrinsicTag(node); + } + else { + links.resolvedSymbol = lookupClassTag(node); + } + } + return links.resolvedSymbol; + function lookupIntrinsicTag(node) { + var intrinsicElementsType = getJsxIntrinsicElementsType(); + if (intrinsicElementsType !== unknownType) { + // Property case + var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.text); + if (intrinsicProp) { + links.jsxFlags |= 1 /* IntrinsicNamedElement */; + return intrinsicProp; + } + // Intrinsic string indexer case + var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0 /* String */); + if (indexSignatureType) { + links.jsxFlags |= 2 /* IntrinsicIndexedElement */; + return intrinsicElementsType.symbol; + } + // Wasn't found + error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, 'JSX.' + JsxNames.IntrinsicElements); + return unknownSymbol; + } + else { + if (compilerOptions.noImplicitAny) { + error(node, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, JsxNames.IntrinsicElements); + } + } + } + function lookupClassTag(node) { + var valueSymbol; + // Look up the value in the current scope + if (node.tagName.kind === 66 /* Identifier */) { + var tag = node.tagName; + var sym = getResolvedSymbol(tag); + valueSymbol = sym.exportSymbol || sym; + } + else { + valueSymbol = checkQualifiedName(node.tagName).symbol; + } + if (valueSymbol && valueSymbol !== unknownSymbol) { + links.jsxFlags |= 4 /* ClassElement */; + getSymbolLinks(valueSymbol).referenced = true; + } + return valueSymbol || unknownSymbol; + } + } + /** + * Given a JSX element that is a class element, finds the Element Instance Type. If the + * element is not a class element, or the class element type cannot be determined, returns 'undefined'. + * For example, in the element , the element instance type is `MyClass` (not `typeof MyClass`). + */ + function getJsxElementInstanceType(node) { + if (!(getNodeLinks(node).jsxFlags & 4 /* ClassElement */)) { + // There is no such thing as an instance type for a non-class element + return undefined; + } + var classSymbol = getJsxElementTagSymbol(node); + if (classSymbol === unknownSymbol) { + // Couldn't find the class instance type. Error has already been issued + return anyType; + } + var valueType = getTypeOfSymbol(classSymbol); + if (isTypeAny(valueType)) { + // Short-circuit if the class tag is using an element type 'any' + return anyType; + } + // Resolve the signatures, preferring constructors + var signatures = getSignaturesOfType(valueType, 1 /* Construct */); + if (signatures.length === 0) { + // No construct signatures, try call signatures + signatures = getSignaturesOfType(valueType, 0 /* Call */); + if (signatures.length === 0) { + // We found no signatures at all, which is an error + error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); + return undefined; + } + } + // Check that the constructor/factory returns an object type + var returnType = getUnionType(signatures.map(function (s) { return getReturnTypeOfSignature(s); })); + if (!isTypeAny(returnType) && !(returnType.flags & 80896 /* ObjectType */)) { + error(node.tagName, ts.Diagnostics.The_return_type_of_a_JSX_element_constructor_must_return_an_object_type); + return undefined; + } + // Issue an error if this return type isn't assignable to JSX.ElementClass + var elemClassType = getJsxGlobalElementClassType(); + if (elemClassType) { + checkTypeRelatedTo(returnType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + } + return returnType; + } + /// e.g. "props" for React.d.ts, + /// or 'undefined' if ElementAttributesPropery doesn't exist (which means all + /// non-intrinsic elements' attributes type is 'any'), + /// or '' if it has 0 properties (which means every + /// non-instrinsic elements' attributes type is the element instance type) + function getJsxElementPropertiesName() { + // JSX + var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1536 /* Namespace */, undefined); + // JSX.ElementAttributesProperty [symbol] + var attribsPropTypeSym = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.ElementAttributesPropertyNameContainer, 793056 /* Type */); + // JSX.ElementAttributesProperty [type] + var attribPropType = attribsPropTypeSym && getDeclaredTypeOfSymbol(attribsPropTypeSym); + // The properites of JSX.ElementAttributesProperty + var attribProperties = attribPropType && getPropertiesOfType(attribPropType); + if (attribProperties) { + // Element Attributes has zero properties, so the element attributes type will be the class instance type + if (attribProperties.length === 0) { + return ""; + } + else if (attribProperties.length === 1) { + return attribProperties[0].name; + } + else { + error(attribsPropTypeSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, JsxNames.ElementAttributesPropertyNameContainer); + return undefined; + } + } + else { + // No interface exists, so the element attributes type will be an implicit any + return undefined; + } + } + /** + * Given an opening/self-closing element, get the 'element attributes type', i.e. the type that tells + * us which attributes are valid on a given element. + */ + function getJsxElementAttributesType(node) { + var links = getNodeLinks(node); + if (!links.resolvedJsxType) { + var sym = getJsxElementTagSymbol(node); + if (links.jsxFlags & 4 /* ClassElement */) { + var elemInstanceType = getJsxElementInstanceType(node); + if (isTypeAny(elemInstanceType)) { + return links.resolvedJsxType = anyType; + } + var propsName = getJsxElementPropertiesName(); + if (propsName === undefined) { + // There is no type ElementAttributesProperty, return 'any' + return links.resolvedJsxType = anyType; + } + else if (propsName === "") { + // If there is no e.g. 'props' member in ElementAttributesProperty, use the element class type instead + return links.resolvedJsxType = elemInstanceType; + } + else { + var attributesType = getTypeOfPropertyOfType(elemInstanceType, propsName); + if (!attributesType) { + // There is no property named 'props' on this instance type + return links.resolvedJsxType = emptyObjectType; + } + else if (isTypeAny(attributesType) || (attributesType === unknownType)) { + return links.resolvedJsxType = attributesType; + } + else if (!(attributesType.flags & 80896 /* ObjectType */)) { + error(node.tagName, ts.Diagnostics.JSX_element_attributes_type_0_must_be_an_object_type, typeToString(attributesType)); + return links.resolvedJsxType = anyType; + } + else { + return links.resolvedJsxType = attributesType; + } + } + } + else if (links.jsxFlags & 1 /* IntrinsicNamedElement */) { + return links.resolvedJsxType = getTypeOfSymbol(sym); + } + else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { + return links.resolvedJsxType = getIndexTypeOfSymbol(sym, 0 /* String */); + } + else { + // Resolution failed, so we don't know + return links.resolvedJsxType = anyType; + } + } + return links.resolvedJsxType; + } + /** + * Given a JSX attribute, returns the symbol for the corresponds property + * of the element attributes type. Will return unknownSymbol for attributes + * that have no matching element attributes type property. + */ + function getJsxAttributePropertySymbol(attrib) { + var attributesType = getJsxElementAttributesType(attrib.parent); + var prop = getPropertyOfType(attributesType, attrib.name.text); + return prop || unknownSymbol; + } + var jsxElementClassType = undefined; + function getJsxGlobalElementClassType() { + if (!jsxElementClassType) { + jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); + } + return jsxElementClassType; + } + /// Returns all the properties of the Jsx.IntrinsicElements interface + function getJsxIntrinsicTagNames() { + var intrinsics = getJsxIntrinsicElementsType(); + return intrinsics ? getPropertiesOfType(intrinsics) : emptyArray; + } + function checkJsxPreconditions(errorNode) { + // Preconditions for using JSX + if ((compilerOptions.jsx || 0 /* None */) === 0 /* None */) { + error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided); + } + if (jsxElementType === undefined) { + if (compilerOptions.noImplicitAny) { + error(errorNode, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist); + } + } + } + function checkJsxOpeningLikeElement(node) { + checkGrammarJsxElement(node); + checkJsxPreconditions(node); + // If we're compiling under --jsx react, the symbol 'React' should + // be marked as 'used' so we don't incorrectly elide its import. And if there + // is no 'React' symbol in scope, we should issue an error. + if (compilerOptions.jsx === 2 /* React */) { + var reactSym = resolveName(node.tagName, 'React', 107455 /* Value */, ts.Diagnostics.Cannot_find_name_0, 'React'); + if (reactSym) { + getSymbolLinks(reactSym).referenced = true; + } + } + var targetAttributesType = getJsxElementAttributesType(node); + var nameTable = {}; + // Process this array in right-to-left order so we know which + // attributes (mostly from spreads) are being overwritten and + // thus should have their types ignored + var sawSpreadedAny = false; + for (var i = node.attributes.length - 1; i >= 0; i--) { + if (node.attributes[i].kind === 235 /* JsxAttribute */) { + checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); + } + else { + ts.Debug.assert(node.attributes[i].kind === 236 /* JsxSpreadAttribute */); + var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); + if (isTypeAny(spreadType)) { + sawSpreadedAny = true; + } + } + } + // Check that all required properties have been provided. If an 'any' + // was spreaded in, though, assume that it provided all required properties + if (targetAttributesType && !sawSpreadedAny) { + var targetProperties = getPropertiesOfType(targetAttributesType); + for (var i = 0; i < targetProperties.length; i++) { + if (!(targetProperties[i].flags & 536870912 /* Optional */) && + nameTable[targetProperties[i].name] === undefined) { + error(node, ts.Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType)); + } + } + } + } + function checkJsxExpression(node) { + if (node.expression) { + return checkExpression(node.expression); + } + else { + return unknownType; + } + } // If a symbol is a synthesized symbol with no value declaration, we assume it is a property. Example of this are the synthesized // '.prototype' property as well as synthesized tuple index properties. function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 134 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 138 /* PropertyDeclaration */; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; } + /** + * Check whether the requested property access is valid. + * Returns true if node is a valid property access, and false otherwise. + * @param node The node to be checked. + * @param left The left hand side of the property access (e.g.: the super in `super.foo`). + * @param type The type of left. + * @param prop The symbol for the right hand side of the property access. + */ function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); - // Public properties are always accessible + var declaringClass = getDeclaredTypeOfSymbol(prop.parent); + if (left.kind === 92 /* SuperKeyword */) { + var errorNode = node.kind === 163 /* PropertyAccessExpression */ ? + node.name : + node.right; + // TS 1.0 spec (April 2014): 4.8.2 + // - In a constructor, instance member function, instance member accessor, or + // instance member variable initializer where this references a derived class instance, + // a super property access is permitted and must specify a public instance member function of the base class. + // - In a static member function or static member accessor + // where this references the constructor function object of a derived class, + // a super property access is permitted and must specify a public static member function of the base class. + if (getDeclarationKindFromSymbol(prop) !== 140 /* MethodDeclaration */) { + // `prop` refers to a *property* declared in the super class + // rather than a *method*, so it does not satisfy the above criteria. + error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + return false; + } + if (flags & 256 /* Abstract */) { + // A method cannot be accessed in a super property access if the method is abstract. + // This error could mask a private property access error. But, a member + // cannot simultaneously be private and abstract, so this will trigger an + // additional error elsewhere. + error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(declaringClass)); + return false; + } + } + // Public properties are otherwise accessible. if (!(flags & (32 /* Private */ | 64 /* Protected */))) { - return; + return true; } // Property is known to be private or protected at this point // Get the declaring and enclosing class instance types var enclosingClassDeclaration = ts.getContainingClass(node); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; - var declaringClass = getDeclaredTypeOfSymbol(prop.parent); // Private property is accessible if declaring and enclosing class are the same if (flags & 32 /* Private */) { if (declaringClass !== enclosingClass) { error(node, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); + return false; } - return; + return true; } // Property is known to be protected at this point // All protected properties of a supertype are accessible in a super access - if (left.kind === 91 /* SuperKeyword */) { - return; + if (left.kind === 92 /* SuperKeyword */) { + return true; } // A protected property is accessible in the declaring class and classes derived from it if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass)); - return; + return false; } // No further restrictions for static properties if (flags & 128 /* Static */) { - return; + return true; } // An instance property must be accessed through an instance of the enclosing class + // TODO: why is the first part of this check here? if (!(getTargetType(type).flags & (1024 /* Class */ | 2048 /* Interface */) && 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; } + return true; } function checkPropertyAccessExpression(node) { return checkPropertyAccessExpressionOrQualifiedName(node, node.expression, node.name); @@ -18350,38 +19558,19 @@ var ts; } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32 /* Class */) { - // TS 1.0 spec (April 2014): 4.8.2 - // - In a constructor, instance member function, instance member accessor, or - // instance member variable initializer where this references a derived class instance, - // a super property access is permitted and must specify a public instance member function of the base class. - // - In a static member function or static member accessor - // where this references the constructor function object of a derived class, - // a super property access is permitted and must specify a public static member function of the base class. - if (left.kind === 91 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 136 /* MethodDeclaration */) { - error(right, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); - } - else { - checkClassPropertyAccess(node, left, type, prop); - } + checkClassPropertyAccess(node, left, type, prop); } return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 158 /* PropertyAccessExpression */ + var left = node.kind === 163 /* PropertyAccessExpression */ ? node.expression : node.left; var type = checkExpression(left); if (type !== unknownType && !isTypeAny(type)) { var prop = getPropertyOfType(getWidenedType(type), propertyName); if (prop && prop.parent && prop.parent.flags & 32 /* Class */) { - if (left.kind === 91 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 136 /* MethodDeclaration */) { - return false; - } - else { - var modificationCount = diagnostics.getModificationCount(); - checkClassPropertyAccess(node, left, type, prop); - return diagnostics.getModificationCount() === modificationCount; - } + return checkClassPropertyAccess(node, left, type, prop); } } return true; @@ -18390,7 +19579,7 @@ var ts; // Grammar checking if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 161 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 166 /* NewExpression */ && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -18423,21 +19612,21 @@ var ts; // - Otherwise, if IndexExpr is of type Any, the String or Number primitive type, or an enum type, the property access is of type Any. // See if we can index as a property. if (node.argumentExpression) { - var name_10 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); - if (name_10 !== undefined) { - var prop = getPropertyOfType(objectType, name_10); + var name_11 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); + if (name_11 !== undefined) { + var prop = getPropertyOfType(objectType, name_11); if (prop) { getNodeLinks(node).resolvedSymbol = prop; return getTypeOfSymbol(prop); } else if (isConstEnum) { - error(node.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_const_enum_1, name_10, symbolToString(objectType.symbol)); + error(node.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_const_enum_1, name_11, symbolToString(objectType.symbol)); return unknownType; } } } // Check for compatible indexer types. - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 /* StringLike */ | 132 /* NumberLike */ | 2097152 /* ESSymbol */)) { + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 /* StringLike */ | 132 /* NumberLike */ | 4194304 /* ESSymbol */)) { // Try to use a number indexer. if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132 /* NumberLike */)) { var numberIndexType = getIndexTypeOfType(objectType, 1 /* Number */); @@ -18492,7 +19681,7 @@ var ts; return false; } // Make sure the property type is the primitive symbol type - if ((expressionType.flags & 2097152 /* ESSymbol */) === 0) { + if ((expressionType.flags & 4194304 /* ESSymbol */) === 0) { if (reportError) { error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); } @@ -18519,10 +19708,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 162 /* TaggedTemplateExpression */) { + if (node.kind === 167 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 132 /* Decorator */) { + else if (node.kind !== 136 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -18588,7 +19777,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 176 /* SpreadElementExpression */) { + if (arg && arg.kind === 182 /* SpreadElementExpression */) { return i; } } @@ -18600,13 +19789,13 @@ var ts; var callIsIncomplete; // In incomplete call we want to be lenient when we have too few arguments var isDecorator; var spreadArgIndex = -1; - if (node.kind === 162 /* TaggedTemplateExpression */) { + if (node.kind === 167 /* TaggedTemplateExpression */) { var tagExpression = node; // Even if the call is incomplete, we'll have a missing expression as our last argument, // so we can say the count is just the arg list length adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 174 /* TemplateExpression */) { + if (tagExpression.template.kind === 180 /* TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var templateExpression = tagExpression.template; @@ -18623,7 +19812,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 132 /* Decorator */) { + else if (node.kind === 136 /* Decorator */) { isDecorator = true; typeArguments = undefined; adjustedArgCount = getEffectiveArgumentCount(node, undefined, signature); @@ -18632,7 +19821,7 @@ var ts; var callExpression = node; if (!callExpression.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(callExpression.kind === 161 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 166 /* NewExpression */); return signature.minArgumentCount === 0; } // For IDE scenarios we may have an incomplete call, so a trailing comma is tantamount to adding another argument. @@ -18664,8 +19853,8 @@ var ts; } // If type has a single call signature and no other members, return that signature. Otherwise, return undefined. function getSingleCallSignature(type) { - if (type.flags & 48128 /* ObjectType */) { - var resolved = resolveObjectOrUnionTypeMembers(type); + if (type.flags & 80896 /* ObjectType */) { + var resolved = resolveStructuredTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && resolved.properties.length === 0 && !resolved.stringIndexType && !resolved.numberIndexType) { return resolved.callSignatures[0]; @@ -18711,10 +19900,10 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 178 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 184 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); - // If the effective argument type is 'undefined', there is no synthetic type + // If the effective argument type is 'undefined', there is no synthetic type // for the argument. In that case, we should check the argument. if (argType === undefined) { // For context sensitive arguments we pass the identityMapper, which is a signal to treat all @@ -18770,11 +19959,11 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 178 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 184 /* OmittedExpression */) { // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); - // If the effective argument type is 'undefined', there is no synthetic type + // If the effective argument type is 'undefined', there is no synthetic type // for the argument. In that case, we should check the argument. if (argType === undefined) { argType = arg.kind === 8 /* StringLiteral */ && !reportErrors @@ -18802,16 +19991,16 @@ var ts; */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 162 /* TaggedTemplateExpression */) { + if (node.kind === 167 /* TaggedTemplateExpression */) { var template = node.template; args = [undefined]; - if (template.kind === 174 /* TemplateExpression */) { + if (template.kind === 180 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 132 /* Decorator */) { + else if (node.kind === 136 /* Decorator */) { // For a decorator, we return undefined as we will determine // the number and types of arguments for a decorator using // `getEffectiveArgumentCount` and `getEffectiveArgumentType` below. @@ -18836,26 +20025,26 @@ var ts; * Otherwise, the argument count is the length of the 'args' array. */ function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 132 /* Decorator */) { + if (node.kind === 136 /* Decorator */) { switch (node.parent.kind) { - case 204 /* ClassDeclaration */: - case 177 /* ClassExpression */: + case 211 /* ClassDeclaration */: + case 183 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; - case 134 /* PropertyDeclaration */: - // A property declaration decorator will have two arguments (see + case 138 /* PropertyDeclaration */: + // A property declaration decorator will have two arguments (see // `PropertyDecorator` in core.d.ts) return 2; - case 136 /* MethodDeclaration */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: + case 140 /* MethodDeclaration */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts) - // If the method decorator signature only accepts a target and a key, we will only + // If the method decorator signature only accepts a target and a key, we will only // type check those arguments. return signature.parameters.length >= 3 ? 3 : 2; - case 131 /* Parameter */: - // A parameter declaration decorator will have three arguments (see + case 135 /* Parameter */: + // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts) return 3; } @@ -18879,28 +20068,28 @@ var ts; function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. switch (node.kind) { - case 204 /* ClassDeclaration */: - case 177 /* ClassExpression */: - // For a class decorator, the `target` is the type of the class (e.g. the + case 211 /* ClassDeclaration */: + case 183 /* ClassExpression */: + // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class) var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); - case 131 /* Parameter */: - // For a parameter decorator, the `target` is the parent type of the - // parameter's containing method. + case 135 /* Parameter */: + // For a parameter decorator, the `target` is the parent type of the + // parameter's containing method. node = node.parent; - if (node.kind === 137 /* Constructor */) { + if (node.kind === 141 /* Constructor */) { var classSymbol_1 = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol_1); } // fall-through - case 134 /* PropertyDeclaration */: - case 136 /* MethodDeclaration */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: + case 138 /* PropertyDeclaration */: + case 140 /* MethodDeclaration */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: // For a property or method decorator, the `target` is the // "static"-side type of the parent of the member if the member is - // declared "static"; otherwise, it is the "instance"-side type of the + // declared "static"; otherwise, it is the "instance"-side type of the // parent of the member. return getParentTypeOfClassElement(node); default: @@ -18926,35 +20115,35 @@ var ts; function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` switch (node.kind) { - case 204 /* ClassDeclaration */: + case 211 /* ClassDeclaration */: ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; - case 131 /* Parameter */: + case 135 /* Parameter */: node = node.parent; - if (node.kind === 137 /* Constructor */) { + if (node.kind === 141 /* Constructor */) { // For a constructor parameter decorator, the `propertyKey` will be `undefined`. return anyType; } // For a non-constructor parameter decorator, the `propertyKey` will be either // a string or a symbol, based on the name of the parameter's containing method. // fall-through - case 134 /* PropertyDeclaration */: - case 136 /* MethodDeclaration */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: + case 138 /* PropertyDeclaration */: + case 140 /* MethodDeclaration */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: // The `propertyKey` for a property or method decorator will be a - // string literal type if the member name is an identifier, number, or string; + // string literal type if the member name is an identifier, number, or string; // otherwise, if the member name is a computed property name it will // be either string or symbol. var element = node; switch (element.name.kind) { - case 65 /* Identifier */: + case 66 /* Identifier */: case 7 /* NumericLiteral */: case 8 /* StringLiteral */: return getStringLiteralType(element.name); - case 129 /* ComputedPropertyName */: + case 133 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(element.name); - if (allConstituentTypesHaveKind(nameType, 2097152 /* ESSymbol */)) { + if (allConstituentTypesHaveKind(nameType, 4194304 /* ESSymbol */)) { return nameType; } else { @@ -18980,18 +20169,18 @@ var ts; // The third argument to a decorator is either its `descriptor` for a method decorator // or its `parameterIndex` for a paramter decorator switch (node.kind) { - case 204 /* ClassDeclaration */: + case 211 /* ClassDeclaration */: ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; - case 131 /* Parameter */: + case 135 /* Parameter */: // The `parameterIndex` for a parameter decorator is always a number return numberType; - case 134 /* PropertyDeclaration */: + case 138 /* PropertyDeclaration */: ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; - case 136 /* MethodDeclaration */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: + case 140 /* MethodDeclaration */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` // for the type of the member. var propertyType = getTypeOfNode(node); @@ -19021,17 +20210,17 @@ var ts; * Gets the effective argument type for an argument in a call expression. */ function getEffectiveArgumentType(node, argIndex, arg) { - // Decorators provide special arguments, a tagged template expression provides + // Decorators provide special arguments, a tagged template expression provides // a special first argument, and string literals get string literal types // unless we're reporting errors - if (node.kind === 132 /* Decorator */) { + if (node.kind === 136 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 162 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 167 /* TaggedTemplateExpression */) { return globalTemplateStringsArrayType; } // This is not a synthetic argument, so we return 'undefined' - // to signal that the caller needs to check the argument. + // to signal that the caller needs to check the argument. return undefined; } /** @@ -19039,8 +20228,8 @@ var ts; */ function getEffectiveArgument(node, args, argIndex) { // For a decorator or the first argument of a tagged template expression we return undefined. - if (node.kind === 132 /* Decorator */ || - (argIndex === 0 && node.kind === 162 /* TaggedTemplateExpression */)) { + if (node.kind === 136 /* Decorator */ || + (argIndex === 0 && node.kind === 167 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -19049,11 +20238,11 @@ var ts; * Gets the error node to use when reporting errors for an effective argument. */ function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 132 /* Decorator */) { + if (node.kind === 136 /* Decorator */) { // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 162 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 167 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -19062,13 +20251,13 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 162 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 132 /* Decorator */; + var isTaggedTemplate = node.kind === 167 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 136 /* Decorator */; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (node.expression.kind !== 91 /* SuperKeyword */) { + if (node.expression.kind !== 92 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -19092,7 +20281,7 @@ var ts; // For a tagged template, then the first argument be 'undefined' if necessary // because it represents a TemplateStringsArray. // - // For a decorator, no arguments are susceptible to contextual typing due to the fact + // For a decorator, no arguments are susceptible to contextual typing due to the fact // decorators are applied to a declaration by the emitter, and not to an expression. var excludeArgument; if (!isDecorator) { @@ -19271,7 +20460,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 91 /* SuperKeyword */) { + if (node.expression.kind === 92 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated @@ -19331,7 +20520,7 @@ var ts; } } var expressionType = checkExpression(node.expression); - // If ConstructExpr's apparent type(section 3.8.1) is an object type with one or + // If expressionType's apparent type(section 3.8.1) is an object type with one or // more construct signatures, the expression is processed in the same manner as a // function call, but using the construct signatures as the initial set of candidate // signatures for overload resolution. The result type of the function call becomes @@ -19341,8 +20530,17 @@ var ts; // Another error has already been reported return resolveErrorCall(node); } + // If the expression is a class of abstract type, then it cannot be instantiated. + // Note, only class declarations can be declared abstract. + // In the case of a merged class-module or class-interface declaration, + // only the class declaration node will have the Abstract flag set. + var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 211 /* ClassDeclaration */); + if (valueDecl && valueDecl.flags & 256 /* Abstract */) { + error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name)); + return resolveErrorCall(node); + } // TS 1.0 spec: 4.11 - // If ConstructExpr is of type Any, Args can be any argument + // If expressionType is of type Any, Args can be any argument // list and the result of the operation is of type Any. if (isTypeAny(expressionType)) { if (node.typeArguments) { @@ -19358,7 +20556,7 @@ var ts; if (constructSignatures.length) { return resolveCall(node, constructSignatures, candidatesOutArray); } - // If ConstructExpr's apparent type is an object type with no construct signatures but + // If expressionType's apparent type is an object type with no construct signatures but // one or more call signatures, the expression is processed as a function call. A compile-time // error occurs if the result of the function call is not Void. The type of the result of the // operation is Any. @@ -19395,16 +20593,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 204 /* ClassDeclaration */: - case 177 /* ClassExpression */: + case 211 /* ClassDeclaration */: + case 183 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 131 /* Parameter */: + case 135 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 134 /* PropertyDeclaration */: + case 138 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 136 /* MethodDeclaration */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: + case 140 /* MethodDeclaration */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -19441,16 +20639,16 @@ var ts; // to correctly fill the candidatesOutArray. if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 160 /* CallExpression */) { + if (node.kind === 165 /* CallExpression */) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 161 /* NewExpression */) { + else if (node.kind === 166 /* NewExpression */) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 162 /* TaggedTemplateExpression */) { + else if (node.kind === 167 /* TaggedTemplateExpression */) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } - else if (node.kind === 132 /* Decorator */) { + else if (node.kind === 136 /* Decorator */) { links.resolvedSignature = resolveDecorator(node, candidatesOutArray); } else { @@ -19459,19 +20657,24 @@ var ts; } return links.resolvedSignature; } + /** + * Syntactically and semantically checks a call or new expression. + * @param node The call/new expression to be checked. + * @returns On success, the expression's signature's return type. On failure, anyType. + */ function checkCallExpression(node) { // Grammar checking; stop grammar-checking if checkGrammarTypeArguments return true checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 91 /* SuperKeyword */) { + if (node.expression.kind === 92 /* SuperKeyword */) { return voidType; } - if (node.kind === 161 /* NewExpression */) { + if (node.kind === 166 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 137 /* Constructor */ && - declaration.kind !== 141 /* ConstructSignature */ && - declaration.kind !== 146 /* ConstructorType */) { + declaration.kind !== 141 /* Constructor */ && + declaration.kind !== 145 /* ConstructSignature */ && + declaration.kind !== 150 /* ConstructorType */) { // When resolved signature is a call signature (and not a construct signature) the result type is any if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); @@ -19484,7 +20687,7 @@ var ts; function checkTaggedTemplateExpression(node) { return getReturnTypeOfSignature(getResolvedSignature(node)); } - function checkTypeAssertion(node) { + function checkAssertion(node) { var exprType = checkExpression(node.expression); var targetType = getTypeFromTypeNode(node.type); if (produceDiagnostics && targetType !== unknownType) { @@ -19513,14 +20716,32 @@ var ts; links.type = instantiateType(getTypeOfSymbol(ts.lastOrUndefined(context.parameters)), mapper); } } + function createPromiseType(promisedType) { + // creates a `Promise` type where `T` is the promisedType argument + var globalPromiseType = getGlobalPromiseType(); + if (globalPromiseType !== emptyObjectType) { + // if the promised type is itself a promise, get the underlying type; otherwise, fallback to the promised type + promisedType = getAwaitedType(promisedType); + return createTypeReference(globalPromiseType, [promisedType]); + } + return emptyObjectType; + } function getReturnTypeFromBody(func, contextualMapper) { var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); if (!func.body) { return unknownType; } + var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 182 /* Block */) { + if (func.body.kind !== 189 /* Block */) { type = checkExpressionCached(func.body, contextualMapper); + if (isAsync) { + // From within an async function you can return either a non-promise value or a promise. Any + // Promise/A+ compatible implementation will always assimilate any foreign promise, so the + // return type of the body should be unwrapped to its awaited type, which we will wrap in + // the native Promise type later in this function. + type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + } } else { var types; @@ -19536,9 +20757,20 @@ var ts; } } else { - types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper); + types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper, isAsync); if (types.length === 0) { - return voidType; + if (isAsync) { + // For an async function, the return type will not be void, but rather a Promise for void. + var promiseType = createPromiseType(voidType); + if (promiseType === emptyObjectType) { + error(func, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return unknownType; + } + return promiseType; + } + else { + return voidType; + } } } // When yield/return statements are contextually typed we allow the return type to be a union type. @@ -19561,7 +20793,21 @@ var ts; if (!contextualSignature) { reportErrorsFromWidening(func, type); } - return getWidenedType(type); + var widenedType = getWidenedType(type); + if (isAsync) { + // From within an async function you can return either a non-promise value or a promise. Any + // Promise/A+ compatible implementation will always assimilate any foreign promise, so the + // return type of the body is awaited type of the body, wrapped in a native Promise type. + var promiseType = createPromiseType(widenedType); + if (promiseType === emptyObjectType) { + error(func, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return unknownType; + } + return promiseType; + } + else { + return widenedType; + } } function checkAndAggregateYieldOperandTypes(body, contextualMapper) { var aggregatedTypes = []; @@ -19580,12 +20826,19 @@ var ts; }); return aggregatedTypes; } - function checkAndAggregateReturnExpressionTypes(body, contextualMapper) { + function checkAndAggregateReturnExpressionTypes(body, contextualMapper, isAsync) { var aggregatedTypes = []; ts.forEachReturnStatement(body, function (returnStatement) { var expr = returnStatement.expression; if (expr) { var type = checkExpressionCached(expr, contextualMapper); + if (isAsync) { + // From within an async function you can return either a non-promise value or a promise. Any + // Promise/A+ compatible implementation will always assimilate any foreign promise, so the + // return type of the body should be unwrapped to its awaited type, which should be wrapped in + // the native Promise type by the caller. + type = checkAwaitedType(type, body.parent, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + } if (!ts.contains(aggregatedTypes, type)) { aggregatedTypes.push(type); } @@ -19599,7 +20852,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 198 /* ThrowStatement */); + return (body.statements.length === 1) && (body.statements[0].kind === 205 /* ThrowStatement */); } // TypeScript Specification 1.0 (6.3) - July 2014 // An explicitly typed function whose return type isn't the Void or the Any type @@ -19614,7 +20867,7 @@ var ts; return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. - if (ts.nodeIsMissing(func.body) || func.body.kind !== 182 /* Block */) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 189 /* Block */) { return; } var bodyBlock = func.body; @@ -19632,26 +20885,30 @@ 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 !== 136 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 140 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 165 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 170 /* FunctionExpression */) { checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards if (contextualMapper === identityMapper && isContextSensitive(node)) { return anyFunctionType; } + var isAsync = ts.isAsyncFunctionLike(node); + if (isAsync) { + emitAwaiter = true; + } var links = getNodeLinks(node); var type = getTypeOfSymbol(node.symbol); // Check if function expression is contextually typed and assign parameter types if so - if (!(links.flags & 64 /* ContextChecked */)) { + if (!(links.flags & 1024 /* ContextChecked */)) { var contextualSignature = getContextualSignature(node); // If a type check is started at a function expression that is an argument of a function call, obtaining the // contextual type may recursively get back to here during overload resolution of the call. If so, we will have // already assigned contextual types. - if (!(links.flags & 64 /* ContextChecked */)) { - links.flags |= 64 /* ContextChecked */; + if (!(links.flags & 1024 /* ContextChecked */)) { + links.flags |= 1024 /* ContextChecked */; if (contextualSignature) { var signature = getSignaturesOfType(type, 0 /* Call */)[0]; if (isContextSensitive(node)) { @@ -19667,16 +20924,25 @@ var ts; checkSignatureDeclaration(node); } } - if (produceDiagnostics && node.kind !== 136 /* MethodDeclaration */ && node.kind !== 135 /* MethodSignature */) { + if (produceDiagnostics && node.kind !== 140 /* MethodDeclaration */ && node.kind !== 139 /* MethodSignature */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 136 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); - if (node.type && !node.asteriskToken) { - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); + ts.Debug.assert(node.kind !== 140 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + var isAsync = ts.isAsyncFunctionLike(node); + if (isAsync) { + emitAwaiter = true; + } + var returnType = node.type && getTypeFromTypeNode(node.type); + var promisedType; + if (returnType && isAsync) { + promisedType = checkAsyncFunctionReturnType(node); + } + if (returnType && !node.asteriskToken) { + checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); } if (node.body) { if (!node.type) { @@ -19687,13 +20953,24 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 182 /* Block */) { + if (node.body.kind === 189 /* Block */) { checkSourceElement(node.body); } else { + // From within an async function you can return either a non-promise value or a promise. Any + // Promise/A+ compatible implementation will always assimilate any foreign promise, so we + // should not be checking assignability of a promise to the return type. Instead, we need to + // check assignability of the awaited type of the expression body against the promised type of + // its return type annotation. var exprType = checkExpression(node.body); - if (node.type) { - checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), node.body, undefined); + if (returnType) { + if (isAsync) { + var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member); + checkTypeAssignableTo(awaitedType, promisedType, node.body); + } + else { + checkTypeAssignableTo(exprType, returnType, node.body); + } } checkFunctionAndClassExpressionBodies(node.body); } @@ -19722,24 +20999,24 @@ var ts; // and property accesses(section 4.10). // All other expression constructs described in this chapter are classified as values. switch (n.kind) { - case 65 /* Identifier */: { + case 66 /* Identifier */: { var symbol = findSymbol(n); // TypeScript 1.0 spec (April 2014): 4.3 // An identifier expression that references a variable or parameter is classified as a reference. // An identifier expression that references any other kind of entity is classified as a value(and therefore cannot be the target of an assignment). return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3 /* Variable */) !== 0; } - case 158 /* PropertyAccessExpression */: { + case 163 /* PropertyAccessExpression */: { var symbol = findSymbol(n); // TypeScript 1.0 spec (April 2014): 4.10 // A property access expression is always classified as a reference. // NOTE (not in spec): assignment to enum members should not be allowed return !symbol || symbol === unknownSymbol || (symbol.flags & ~8 /* EnumMember */) !== 0; } - case 159 /* ElementAccessExpression */: + case 164 /* ElementAccessExpression */: // old compiler doesn't check indexed assess return true; - case 164 /* ParenthesizedExpression */: + case 169 /* ParenthesizedExpression */: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -19747,22 +21024,22 @@ var ts; } function isConstVariableReference(n) { switch (n.kind) { - case 65 /* Identifier */: - case 158 /* PropertyAccessExpression */: { + case 66 /* Identifier */: + case 163 /* PropertyAccessExpression */: { var symbol = findSymbol(n); - return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 8192 /* Const */) !== 0; + return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768 /* Const */) !== 0; } - case 159 /* ElementAccessExpression */: { + case 164 /* ElementAccessExpression */: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); if (symbol && index && index.kind === 8 /* StringLiteral */) { - var name_11 = index.text; - var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_11); - return prop && (prop.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 8192 /* Const */) !== 0; + var name_12 = index.text; + var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_12); + return prop && (prop.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 32768 /* Const */) !== 0; } return false; } - case 164 /* ParenthesizedExpression */: + case 169 /* ParenthesizedExpression */: return isConstVariableReference(n.expression); default: return false; @@ -19783,27 +21060,40 @@ var ts; return booleanType; } function checkTypeOfExpression(node) { - var operandType = checkExpression(node.expression); + checkExpression(node.expression); return stringType; } function checkVoidExpression(node) { - var operandType = checkExpression(node.expression); + checkExpression(node.expression); return undefinedType; } + function checkAwaitExpression(node) { + // Grammar checking + if (produceDiagnostics) { + if (!(node.parserContextFlags & 8 /* Await */)) { + grammarErrorOnFirstToken(node, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); + } + if (isInParameterInitializerBeforeContainingFunction(node)) { + error(node, ts.Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer); + } + } + var operandType = checkExpression(node.expression); + return checkAwaitedType(operandType, node); + } function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); switch (node.operator) { - case 33 /* PlusToken */: - case 34 /* MinusToken */: - case 47 /* TildeToken */: - if (someConstituentTypeHasKind(operandType, 2097152 /* ESSymbol */)) { + case 34 /* PlusToken */: + case 35 /* MinusToken */: + case 48 /* TildeToken */: + if (someConstituentTypeHasKind(operandType, 4194304 /* ESSymbol */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 46 /* ExclamationToken */: + case 47 /* ExclamationToken */: return booleanType; - case 38 /* PlusPlusToken */: - case 39 /* MinusMinusToken */: + case 39 /* PlusPlusToken */: + case 40 /* MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors @@ -19828,7 +21118,7 @@ var ts; if (type.flags & kind) { return true; } - if (type.flags & 16384 /* Union */) { + if (type.flags & 49152 /* UnionOrIntersection */) { var types = type.types; for (var _i = 0; _i < types.length; _i++) { var current = types[_i]; @@ -19840,12 +21130,12 @@ var ts; } return false; } - // Return true if type has the given flags, or is a union type composed of types that all have those flags. + // Return true if type has the given flags, or is a union or intersection type composed of types that all have those flags. function allConstituentTypesHaveKind(type, kind) { if (type.flags & kind) { return true; } - if (type.flags & 16384 /* Union */) { + if (type.flags & 49152 /* UnionOrIntersection */) { var types = type.types; for (var _i = 0; _i < types.length; _i++) { var current = types[_i]; @@ -19858,7 +21148,7 @@ var ts; return false; } function isConstEnumObjectType(type) { - return type.flags & (48128 /* ObjectType */ | 32768 /* Anonymous */) && type.symbol && isConstEnumSymbol(type.symbol); + return type.flags & (80896 /* ObjectType */ | 65536 /* Anonymous */) && type.symbol && isConstEnumSymbol(type.symbol); } function isConstEnumSymbol(symbol) { return (symbol.flags & 128 /* ConstEnum */) !== 0; @@ -19869,7 +21159,7 @@ var ts; // and the right operand to be of type Any or a subtype of the 'Function' interface type. // The result is always of the Boolean primitive type. // NOTE: do not raise error if leftType is unknown as related error was already reported - if (allConstituentTypesHaveKind(leftType, 2097662 /* Primitive */)) { + if (allConstituentTypesHaveKind(leftType, 4194814 /* Primitive */)) { 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); } // NOTE: do not raise error if right is unknown as related error was already reported @@ -19883,10 +21173,10 @@ var ts; // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, // and the right operand to be of type Any, an object type, or a type parameter type. // The result is always of the Boolean primitive type. - if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */ | 132 /* NumberLike */ | 2097152 /* ESSymbol */)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */ | 132 /* NumberLike */ | 4194304 /* ESSymbol */)) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 48128 /* ObjectType */ | 512 /* TypeParameter */)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 /* ObjectType */ | 512 /* TypeParameter */)) { 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); } return booleanType; @@ -19895,19 +21185,19 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 227 /* PropertyAssignment */ || p.kind === 228 /* ShorthandPropertyAssignment */) { + if (p.kind === 242 /* PropertyAssignment */ || p.kind === 243 /* ShorthandPropertyAssignment */) { // TODO(andersh): Computed property support - var name_12 = p.name; + var name_13 = p.name; var type = isTypeAny(sourceType) ? sourceType - : getTypeOfPropertyOfType(sourceType, name_12.text) || - isNumericLiteralName(name_12.text) && getIndexTypeOfType(sourceType, 1 /* Number */) || + : getTypeOfPropertyOfType(sourceType, name_13.text) || + isNumericLiteralName(name_13.text) && getIndexTypeOfType(sourceType, 1 /* Number */) || getIndexTypeOfType(sourceType, 0 /* String */); if (type) { - checkDestructuringAssignment(p.initializer || name_12, type); + checkDestructuringAssignment(p.initializer || name_13, type); } else { - error(name_12, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_12)); + error(name_13, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_13)); } } else { @@ -19924,8 +21214,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 178 /* OmittedExpression */) { - if (e.kind !== 176 /* SpreadElementExpression */) { + if (e.kind !== 184 /* OmittedExpression */) { + if (e.kind !== 182 /* SpreadElementExpression */) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -19950,7 +21240,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 172 /* BinaryExpression */ && restExpression.operatorToken.kind === 53 /* EqualsToken */) { + if (restExpression.kind === 178 /* BinaryExpression */ && restExpression.operatorToken.kind === 54 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -19963,14 +21253,14 @@ var ts; return sourceType; } function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 172 /* BinaryExpression */ && target.operatorToken.kind === 53 /* EqualsToken */) { + if (target.kind === 178 /* BinaryExpression */ && target.operatorToken.kind === 54 /* EqualsToken */) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 157 /* ObjectLiteralExpression */) { + if (target.kind === 162 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 156 /* ArrayLiteralExpression */) { + if (target.kind === 161 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -19984,32 +21274,32 @@ var ts; } function checkBinaryExpression(node, contextualMapper) { var operator = node.operatorToken.kind; - if (operator === 53 /* EqualsToken */ && (node.left.kind === 157 /* ObjectLiteralExpression */ || node.left.kind === 156 /* ArrayLiteralExpression */)) { + if (operator === 54 /* EqualsToken */ && (node.left.kind === 162 /* ObjectLiteralExpression */ || node.left.kind === 161 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); } var leftType = checkExpression(node.left, contextualMapper); var rightType = checkExpression(node.right, contextualMapper); switch (operator) { - case 35 /* AsteriskToken */: - case 56 /* AsteriskEqualsToken */: - case 36 /* SlashToken */: - case 57 /* SlashEqualsToken */: - case 37 /* PercentToken */: - case 58 /* PercentEqualsToken */: - case 34 /* MinusToken */: - case 55 /* MinusEqualsToken */: - case 40 /* LessThanLessThanToken */: - case 59 /* LessThanLessThanEqualsToken */: - case 41 /* GreaterThanGreaterThanToken */: - case 60 /* GreaterThanGreaterThanEqualsToken */: - case 42 /* GreaterThanGreaterThanGreaterThanToken */: - case 61 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 44 /* BarToken */: - case 63 /* BarEqualsToken */: - case 45 /* CaretToken */: - case 64 /* CaretEqualsToken */: - case 43 /* AmpersandToken */: - case 62 /* AmpersandEqualsToken */: + case 36 /* AsteriskToken */: + case 57 /* AsteriskEqualsToken */: + case 37 /* SlashToken */: + case 58 /* SlashEqualsToken */: + case 38 /* PercentToken */: + case 59 /* PercentEqualsToken */: + case 35 /* MinusToken */: + case 56 /* MinusEqualsToken */: + case 41 /* LessThanLessThanToken */: + case 60 /* LessThanLessThanEqualsToken */: + case 42 /* GreaterThanGreaterThanToken */: + case 61 /* GreaterThanGreaterThanEqualsToken */: + case 43 /* GreaterThanGreaterThanGreaterThanToken */: + case 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 45 /* BarToken */: + case 64 /* BarEqualsToken */: + case 46 /* CaretToken */: + case 65 /* CaretEqualsToken */: + case 44 /* AmpersandToken */: + case 63 /* AmpersandEqualsToken */: // TypeScript 1.0 spec (April 2014): 4.15.1 // These operators require their operands to be of type Any, the Number primitive type, // or an enum type. Operands of an enum type are treated @@ -20037,8 +21327,8 @@ var ts; } } return numberType; - case 33 /* PlusToken */: - case 54 /* PlusEqualsToken */: + case 34 /* PlusToken */: + case 55 /* PlusEqualsToken */: // TypeScript 1.0 spec (April 2014): 4.15.2 // The binary + operator requires both operands to be of the Number primitive type or an enum type, // or at least one of the operands to be of type Any or the String primitive type. @@ -20072,35 +21362,35 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 54 /* PlusEqualsToken */) { + if (operator === 55 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; case 24 /* LessThanToken */: - case 25 /* GreaterThanToken */: - case 26 /* LessThanEqualsToken */: - case 27 /* GreaterThanEqualsToken */: + case 26 /* GreaterThanToken */: + case 27 /* LessThanEqualsToken */: + case 28 /* GreaterThanEqualsToken */: if (!checkForDisallowedESSymbolOperand(operator)) { return booleanType; } // Fall through - case 28 /* EqualsEqualsToken */: - case 29 /* ExclamationEqualsToken */: - case 30 /* EqualsEqualsEqualsToken */: - case 31 /* ExclamationEqualsEqualsToken */: + case 29 /* EqualsEqualsToken */: + case 30 /* ExclamationEqualsToken */: + case 31 /* EqualsEqualsEqualsToken */: + case 32 /* ExclamationEqualsEqualsToken */: if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { reportOperatorError(); } return booleanType; - case 87 /* InstanceOfKeyword */: + case 88 /* InstanceOfKeyword */: return checkInstanceOfExpression(node, leftType, rightType); - case 86 /* InKeyword */: + case 87 /* InKeyword */: return checkInExpression(node, leftType, rightType); - case 48 /* AmpersandAmpersandToken */: + case 49 /* AmpersandAmpersandToken */: return rightType; - case 49 /* BarBarToken */: + case 50 /* BarBarToken */: return getUnionType([leftType, rightType]); - case 53 /* EqualsToken */: + case 54 /* EqualsToken */: checkAssignmentOperator(rightType); return rightType; case 23 /* CommaToken */: @@ -20108,8 +21398,8 @@ var ts; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 2097152 /* ESSymbol */) ? node.left : - someConstituentTypeHasKind(rightType, 2097152 /* ESSymbol */) ? node.right : + var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 4194304 /* ESSymbol */) ? node.left : + someConstituentTypeHasKind(rightType, 4194304 /* ESSymbol */) ? node.right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -20119,21 +21409,21 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 44 /* BarToken */: - case 63 /* BarEqualsToken */: - return 49 /* BarBarToken */; - case 45 /* CaretToken */: - case 64 /* CaretEqualsToken */: - return 31 /* ExclamationEqualsEqualsToken */; - case 43 /* AmpersandToken */: - case 62 /* AmpersandEqualsToken */: - return 48 /* AmpersandAmpersandToken */; + case 45 /* BarToken */: + case 64 /* BarEqualsToken */: + return 50 /* BarBarToken */; + case 46 /* CaretToken */: + case 65 /* CaretEqualsToken */: + return 32 /* ExclamationEqualsEqualsToken */; + case 44 /* AmpersandToken */: + case 63 /* AmpersandEqualsToken */: + return 49 /* AmpersandAmpersandToken */; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 53 /* FirstAssignment */ && operator <= 64 /* LastAssignment */) { + if (produceDiagnostics && operator >= 54 /* FirstAssignment */ && operator <= 65 /* LastAssignment */) { // TypeScript 1.0 spec (April 2014): 4.17 // An assignment of the form // VarExpr = ValueExpr @@ -20169,8 +21459,13 @@ var ts; } function checkYieldExpression(node) { // Grammar checking - if (!(node.parserContextFlags & 4 /* Yield */) || isYieldExpressionInClass(node)) { - grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); + if (produceDiagnostics) { + if (!(node.parserContextFlags & 2 /* Yield */) || isYieldExpressionInClass(node)) { + grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); + } + if (isInParameterInitializerBeforeContainingFunction(node)) { + error(node, ts.Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer); + } } if (node.expression) { var func = ts.getContainingFunction(node); @@ -20235,7 +21530,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 129 /* ComputedPropertyName */) { + if (node.name.kind === 133 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); @@ -20246,7 +21541,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 129 /* ComputedPropertyName */) { + if (node.name.kind === 133 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -20276,7 +21571,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpression(node, contextualMapper) { var type; - if (node.kind === 128 /* QualifiedName */) { + if (node.kind === 132 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -20288,9 +21583,9 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 158 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 159 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 65 /* Identifier */ || node.kind === 128 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 163 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 164 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 66 /* Identifier */ || node.kind === 132 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); } @@ -20304,68 +21599,79 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 65 /* Identifier */: + case 66 /* Identifier */: return checkIdentifier(node); - case 93 /* ThisKeyword */: + case 94 /* ThisKeyword */: return checkThisExpression(node); - case 91 /* SuperKeyword */: + case 92 /* SuperKeyword */: return checkSuperExpression(node); - case 89 /* NullKeyword */: + case 90 /* NullKeyword */: return nullType; - case 95 /* TrueKeyword */: - case 80 /* FalseKeyword */: + case 96 /* TrueKeyword */: + case 81 /* FalseKeyword */: return booleanType; case 7 /* NumericLiteral */: return checkNumericLiteral(node); - case 174 /* TemplateExpression */: + case 180 /* TemplateExpression */: return checkTemplateExpression(node); case 8 /* StringLiteral */: case 10 /* NoSubstitutionTemplateLiteral */: return stringType; case 9 /* RegularExpressionLiteral */: return globalRegExpType; - case 156 /* ArrayLiteralExpression */: + case 161 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 157 /* ObjectLiteralExpression */: + case 162 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 158 /* PropertyAccessExpression */: + case 163 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 159 /* ElementAccessExpression */: + case 164 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 160 /* CallExpression */: - case 161 /* NewExpression */: + case 165 /* CallExpression */: + case 166 /* NewExpression */: return checkCallExpression(node); - case 162 /* TaggedTemplateExpression */: + case 167 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 163 /* TypeAssertionExpression */: - return checkTypeAssertion(node); - case 164 /* ParenthesizedExpression */: + case 169 /* ParenthesizedExpression */: return checkExpression(node.expression, contextualMapper); - case 177 /* ClassExpression */: + case 183 /* ClassExpression */: return checkClassExpression(node); - case 165 /* FunctionExpression */: - case 166 /* ArrowFunction */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 168 /* TypeOfExpression */: + case 173 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 167 /* DeleteExpression */: + case 168 /* TypeAssertionExpression */: + case 186 /* AsExpression */: + return checkAssertion(node); + case 172 /* DeleteExpression */: return checkDeleteExpression(node); - case 169 /* VoidExpression */: + case 174 /* VoidExpression */: return checkVoidExpression(node); - case 170 /* PrefixUnaryExpression */: + case 175 /* AwaitExpression */: + return checkAwaitExpression(node); + case 176 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 171 /* PostfixUnaryExpression */: + case 177 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 172 /* BinaryExpression */: + case 178 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 173 /* ConditionalExpression */: + case 179 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 176 /* SpreadElementExpression */: + case 182 /* SpreadElementExpression */: return checkSpreadElementExpression(node, contextualMapper); - case 178 /* OmittedExpression */: + case 184 /* OmittedExpression */: return undefinedType; - case 175 /* YieldExpression */: + case 181 /* YieldExpression */: return checkYieldExpression(node); + case 237 /* JsxExpression */: + return checkJsxExpression(node); + case 230 /* JsxElement */: + return checkJsxElement(node); + case 231 /* JsxSelfClosingElement */: + return checkJsxSelfClosingElement(node); + case 232 /* JsxOpeningElement */: + ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; } @@ -20393,7 +21699,7 @@ var ts; var func = ts.getContainingFunction(node); if (node.flags & 112 /* AccessibilityModifier */) { func = ts.getContainingFunction(node); - if (!(func.kind === 137 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 141 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -20410,15 +21716,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 136 /* MethodDeclaration */ || - node.kind === 203 /* FunctionDeclaration */ || - node.kind === 165 /* FunctionExpression */; + return node.kind === 140 /* MethodDeclaration */ || + node.kind === 210 /* FunctionDeclaration */ || + node.kind === 170 /* FunctionExpression */; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 65 /* Identifier */ && + if (param.name.kind === 66 /* Identifier */ && param.name.text === parameter.text) { return i; } @@ -20428,31 +21734,31 @@ var ts; } function isInLegalTypePredicatePosition(node) { switch (node.parent.kind) { - case 166 /* ArrowFunction */: - case 140 /* CallSignature */: - case 203 /* FunctionDeclaration */: - case 165 /* FunctionExpression */: - case 145 /* FunctionType */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 171 /* ArrowFunction */: + case 144 /* CallSignature */: + case 210 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: + case 149 /* FunctionType */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: return node === node.parent.type; } return false; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 142 /* IndexSignature */) { + if (node.kind === 146 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 145 /* FunctionType */ || node.kind === 203 /* FunctionDeclaration */ || node.kind === 146 /* ConstructorType */ || - node.kind === 140 /* CallSignature */ || node.kind === 137 /* Constructor */ || - node.kind === 141 /* ConstructSignature */) { + else if (node.kind === 149 /* FunctionType */ || node.kind === 210 /* FunctionDeclaration */ || node.kind === 150 /* ConstructorType */ || + node.kind === 144 /* CallSignature */ || node.kind === 141 /* Constructor */ || + node.kind === 145 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { - if (node.type.kind === 143 /* TypePredicate */) { + if (node.type.kind === 147 /* TypePredicate */) { var typePredicate = getSignatureFromDeclaration(node).typePredicate; var typePredicateNode = node.type; if (isInLegalTypePredicatePosition(typePredicateNode)) { @@ -20471,19 +21777,19 @@ var ts; if (hasReportedError) { break; } - if (param.name.kind === 153 /* ObjectBindingPattern */ || - param.name.kind === 154 /* ArrayBindingPattern */) { + if (param.name.kind === 158 /* ObjectBindingPattern */ || + param.name.kind === 159 /* ArrayBindingPattern */) { (function checkBindingPattern(pattern) { for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.name.kind === 65 /* Identifier */ && + if (element.name.kind === 66 /* Identifier */ && element.name.text === typePredicate.parameterName) { error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); hasReportedError = true; break; } - else if (element.name.kind === 154 /* ArrayBindingPattern */ || - element.name.kind === 153 /* ObjectBindingPattern */) { + else if (element.name.kind === 159 /* ArrayBindingPattern */ || + element.name.kind === 158 /* ObjectBindingPattern */) { checkBindingPattern(element.name); } } @@ -20507,10 +21813,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 141 /* ConstructSignature */: + case 145 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 140 /* CallSignature */: + case 144 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -20538,7 +21844,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 205 /* InterfaceDeclaration */) { + if (node.kind === 212 /* InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration // to prevent this run check only for the first declaration of a given kind @@ -20558,7 +21864,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 123 /* StringKeyword */: + case 127 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -20566,7 +21872,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 121 /* NumberKeyword */: + case 125 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -20589,6 +21895,11 @@ var ts; checkGrammarMethod(node) || checkGrammarComputedPropertyName(node.name); // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration checkFunctionLikeDeclaration(node); + // Abstract methods cannot have an implementation. + // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. + if (node.flags & 256 /* Abstract */ && node.body) { + error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); + } } function checkConstructorDeclaration(node) { // Grammar check on signature of constructor and modifier of the constructor is done in checkSignatureDeclaration function. @@ -20610,30 +21921,30 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 160 /* CallExpression */ && n.expression.kind === 91 /* SuperKeyword */; + return n.kind === 165 /* CallExpression */ && n.expression.kind === 92 /* SuperKeyword */; } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } switch (n.kind) { - case 165 /* FunctionExpression */: - case 203 /* FunctionDeclaration */: - case 166 /* ArrowFunction */: - case 157 /* ObjectLiteralExpression */: return false; + case 170 /* FunctionExpression */: + case 210 /* FunctionDeclaration */: + case 171 /* ArrowFunction */: + case 162 /* ObjectLiteralExpression */: return false; default: return ts.forEachChild(n, containsSuperCall); } } function markThisReferencesAsErrors(n) { - if (n.kind === 93 /* ThisKeyword */) { + if (n.kind === 94 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 165 /* FunctionExpression */ && n.kind !== 203 /* FunctionDeclaration */) { + else if (n.kind !== 170 /* FunctionExpression */ && n.kind !== 210 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 134 /* PropertyDeclaration */ && + return n.kind === 138 /* PropertyDeclaration */ && !(n.flags & 128 /* Static */) && !!n.initializer; } @@ -20650,7 +21961,7 @@ var ts; ts.forEach(node.parameters, function (p) { return p.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */); }); if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 185 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { + if (!statements.length || statements[0].kind !== 192 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); } else { @@ -20668,7 +21979,7 @@ var ts; if (produceDiagnostics) { // Grammar checking accessors checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 138 /* GetAccessor */) { + if (node.kind === 142 /* GetAccessor */) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } @@ -20676,7 +21987,7 @@ var ts; if (!ts.hasDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 138 /* GetAccessor */ ? 139 /* SetAccessor */ : 138 /* GetAccessor */; + var otherKind = node.kind === 142 /* GetAccessor */ ? 143 /* SetAccessor */ : 142 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { @@ -20746,7 +22057,7 @@ var ts; } ts.forEach(node.elementTypes, checkSourceElement); } - function checkUnionType(node) { + function checkUnionOrIntersectionType(node) { ts.forEach(node.types, checkSourceElement); } function isPrivateWithinAmbient(node) { @@ -20772,9 +22083,9 @@ var ts; var signaturesToCheck; // Unnamed (call\construct) signatures in interfaces are inherited and not shadowed so examining just node symbol won't give complete answer. // Use declaring type to obtain full list of signatures. - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 205 /* InterfaceDeclaration */) { - ts.Debug.assert(signatureDeclarationNode.kind === 140 /* CallSignature */ || signatureDeclarationNode.kind === 141 /* ConstructSignature */); - var signatureKind = signatureDeclarationNode.kind === 140 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 212 /* InterfaceDeclaration */) { + ts.Debug.assert(signatureDeclarationNode.kind === 144 /* CallSignature */ || signatureDeclarationNode.kind === 145 /* ConstructSignature */); + var signatureKind = signatureDeclarationNode.kind === 144 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -20792,7 +22103,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 205 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 212 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported flags |= 1 /* Export */; @@ -20831,6 +22142,9 @@ var ts; else if (deviation & (32 /* Private */ | 64 /* Protected */)) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } + else if (deviation & 256 /* Abstract */) { + error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract); + } }); } } @@ -20845,7 +22159,7 @@ var ts; }); } } - var flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 32 /* Private */ | 64 /* Protected */; + var flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 32 /* Private */ | 64 /* Protected */ | 256 /* Abstract */; var someNodeFlags = 0; var allNodeFlags = flagsToCheck; var someHaveQuestionToken = false; @@ -20875,7 +22189,7 @@ var ts; // TODO(jfreeman): These are methods, so handle computed name case if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { // the only situation when this is possible (same kind\same name but different symbol) - mixed static and instance class members - ts.Debug.assert(node.kind === 136 /* MethodDeclaration */ || node.kind === 135 /* MethodSignature */); + ts.Debug.assert(node.kind === 140 /* MethodDeclaration */ || node.kind === 139 /* MethodSignature */); ts.Debug.assert((node.flags & 128 /* Static */) !== (subsequentNode.flags & 128 /* Static */)); var diagnostic = node.flags & 128 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); @@ -20892,7 +22206,14 @@ var ts; error(errorNode, ts.Diagnostics.Constructor_implementation_is_missing); } else { - error(errorNode, ts.Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration); + // Report different errors regarding non-consecutive blocks of declarations depending on whether + // the node in question is abstract. + if (node.flags & 256 /* Abstract */) { + error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); + } + else { + error(errorNode, ts.Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration); + } } } // when checking exported function declarations across modules check only duplicate implementations @@ -20904,7 +22225,7 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 205 /* InterfaceDeclaration */ || node.parent.kind === 148 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 212 /* InterfaceDeclaration */ || node.parent.kind === 152 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -20915,7 +22236,7 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if (node.kind === 203 /* FunctionDeclaration */ || node.kind === 136 /* MethodDeclaration */ || node.kind === 135 /* MethodSignature */ || node.kind === 137 /* Constructor */) { + if (node.kind === 210 /* FunctionDeclaration */ || node.kind === 140 /* MethodDeclaration */ || node.kind === 139 /* MethodSignature */ || node.kind === 141 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -20956,7 +22277,9 @@ var ts; error(declaration.name, ts.Diagnostics.Duplicate_function_implementation); }); } - if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body) { + // Abstract methods can't have an implementation -- in particular, they don't need one. + if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && + !(lastSeenNonAmbientDeclaration.flags & 256 /* Abstract */)) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { @@ -21038,16 +22361,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 205 /* InterfaceDeclaration */: + case 212 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: return d.name.kind === 8 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 204 /* ClassDeclaration */: - case 207 /* EnumDeclaration */: + case 211 /* ClassDeclaration */: + case 214 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 211 /* ImportEqualsDeclaration */: + case 218 /* ImportEqualsDeclaration */: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -21057,6 +22380,229 @@ var ts; } } } + function checkNonThenableType(type, location, message) { + if (!(type.flags & 1 /* Any */) && isTypeAssignableTo(type, getGlobalThenableType())) { + if (location) { + if (!message) { + message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; + } + error(location, message); + } + return unknownType; + } + return type; + } + /** + * Gets the "promised type" of a promise. + * @param type The type of the promise. + * @remarks The "promised type" of a type is the type of the "value" parameter of the "onfulfilled" callback. + */ + function getPromisedType(promise) { + // + // { // promise + // then( // thenFunction + // onfulfilled: ( // onfulfilledParameterType + // value: T // valueParameterType + // ) => any + // ): any; + // } + // + if (promise.flags & 1 /* Any */) { + return undefined; + } + if ((promise.flags & 4096 /* Reference */) && promise.target === tryGetGlobalPromiseType()) { + return promise.typeArguments[0]; + } + var globalPromiseLikeType = getInstantiatedGlobalPromiseLikeType(); + if (globalPromiseLikeType === emptyObjectType || !isTypeAssignableTo(promise, globalPromiseLikeType)) { + return undefined; + } + var thenFunction = getTypeOfPropertyOfType(promise, "then"); + if (thenFunction && (thenFunction.flags & 1 /* Any */)) { + return undefined; + } + var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0 /* Call */) : emptyArray; + if (thenSignatures.length === 0) { + return undefined; + } + var onfulfilledParameterType = getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)); + if (onfulfilledParameterType.flags & 1 /* Any */) { + return undefined; + } + var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0 /* Call */); + if (onfulfilledParameterSignatures.length === 0) { + return undefined; + } + var valueParameterType = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature)); + return valueParameterType; + } + function getTypeOfFirstParameterOfSignature(signature) { + return getTypeAtPosition(signature, 0); + } + /** + * Gets the "awaited type" of a type. + * @param type The type to await. + * @remarks The "awaited type" of an expression is its "promised type" if the expression is a + * Promise-like type; otherwise, it is the type of the expression. This is used to reflect + * The runtime behavior of the `await` keyword. + */ + function getAwaitedType(type) { + return checkAwaitedType(type, undefined, undefined); + } + function checkAwaitedType(type, location, message) { + return checkAwaitedTypeWorker(type); + function checkAwaitedTypeWorker(type) { + if (type.flags & 16384 /* Union */) { + var types = []; + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var constituentType = _a[_i]; + types.push(checkAwaitedTypeWorker(constituentType)); + } + return getUnionType(types); + } + else { + var promisedType = getPromisedType(type); + if (promisedType === undefined) { + // The type was not a PromiseLike, so it could not be unwrapped any further. + // As long as the type does not have a callable "then" property, it is + // safe to return the type; otherwise, an error will have been reported in + // the call to checkNonThenableType and we will return unknownType. + // + // An example of a non-promise "thenable" might be: + // + // await { then(): void {} } + // + // The "thenable" does not match the minimal definition for a PromiseLike. When + // a Promise/A+-compatible or ES6 promise tries to adopt this value, the promise + // will never settle. We treat this as an error to help flag an early indicator + // of a runtime problem. If the user wants to return this value from an async + // function, they would need to wrap it in some other value. If they want it to + // be treated as a promise, they can cast to . + return checkNonThenableType(type, location, message); + } + else { + if (type.id === promisedType.id || awaitedTypeStack.indexOf(promisedType.id) >= 0) { + // We have a bad actor in the form of a promise whose promised type is + // the same promise type, or a mutually recursive promise. Return the + // unknown type as we cannot guess the shape. If this were the actual + // case in the JavaScript, this Promise would never resolve. + // + // An example of a bad actor with a singly-recursive promise type might + // be: + // + // interface BadPromise { + // then( + // onfulfilled: (value: BadPromise) => any, + // onrejected: (error: any) => any): BadPromise; + // } + // + // The above interface will pass the PromiseLike check, and return a + // promised type of `BadPromise`. Since this is a self reference, we + // don't want to keep recursing ad infinitum. + // + // An example of a bad actor in the form of a mutually-recursive + // promise type might be: + // + // interface BadPromiseA { + // then( + // onfulfilled: (value: BadPromiseB) => any, + // onrejected: (error: any) => any): BadPromiseB; + // } + // + // interface BadPromiseB { + // then( + // onfulfilled: (value: BadPromiseA) => any, + // onrejected: (error: any) => any): BadPromiseA; + // } + // + if (location) { + error(location, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method, symbolToString(type.symbol)); + } + return unknownType; + } + // Keep track of the type we're about to unwrap to avoid bad recursive promise types. + // See the comments above for more information. + awaitedTypeStack.push(type.id); + var awaitedType = checkAwaitedTypeWorker(promisedType); + awaitedTypeStack.pop(); + return awaitedType; + } + } + } + } + /** + * Checks the return type of an async function to ensure it is a compatible + * Promise implementation. + * @param node The signature to check + * @param returnType The return type for the function + * @remarks + * This checks that an async function has a valid Promise-compatible return type, + * and returns the *awaited type* of the promise. An async function has a valid + * Promise-compatible return type if the resolved value of the return type has a + * construct signature that takes in an `initializer` function that in turn supplies + * a `resolve` function as one of its arguments and results in an object with a + * callable `then` signature. + */ + function checkAsyncFunctionReturnType(node) { + var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); + if (globalPromiseConstructorLikeType === emptyObjectType) { + // If we couldn't resolve the global PromiseConstructorLike type we cannot verify + // compatibility with __awaiter. + return unknownType; + } + // As part of our emit for an async function, we will need to emit the entity name of + // the return type annotation as an expression. To meet the necessary runtime semantics + // for __awaiter, we must also check that the type of the declaration (e.g. the static + // side or "constructor" of the promise type) is compatible `PromiseConstructorLike`. + // + // An example might be (from lib.es6.d.ts): + // + // interface Promise { ... } + // interface PromiseConstructor { + // new (...): Promise; + // } + // declare var Promise: PromiseConstructor; + // + // When an async function declares a return type annotation of `Promise`, we + // need to get the type of the `Promise` variable declaration above, which would + // be `PromiseConstructor`. + // + // The same case applies to a class: + // + // declare class Promise { + // constructor(...); + // then(...): Promise; + // } + // + // When we get the type of the `Promise` symbol here, we get the type of the static + // side of the `Promise` class, which would be `{ new (...): Promise }`. + var promiseType = getTypeFromTypeNode(node.type); + if (promiseType === unknownType && compilerOptions.isolatedModules) { + // If we are compiling with isolatedModules, we may not be able to resolve the + // type as a value. As such, we will just return unknownType; + return unknownType; + } + var promiseConstructor = getMergedSymbol(promiseType.symbol); + if (!promiseConstructor || !symbolIsValue(promiseConstructor)) { + error(node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeToString(promiseType)); + return unknownType; + } + // Validate the promise constructor type. + var promiseConstructorType = getTypeOfSymbol(promiseConstructor); + if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type)) { + return unknownType; + } + // Verify there is no local declaration that could collide with the promise constructor. + var promiseName = ts.getEntityNameFromTypeNode(node.type); + var root = getFirstIdentifier(promiseName); + var rootSymbol = getSymbol(node.locals, root.text, 107455 /* Value */); + if (rootSymbol) { + error(rootSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, root.text, getFullyQualifiedName(promiseConstructor)); + return unknownType; + } + // Get and return the awaited type of the return type. + return checkAwaitedType(promiseType, node, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + } /** Check a decorator */ function checkDecorator(node) { var signature = getResolvedSignature(node); @@ -21068,22 +22614,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 204 /* ClassDeclaration */: + case 211 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 131 /* Parameter */: + case 135 /* Parameter */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 134 /* PropertyDeclaration */: + case 138 /* PropertyDeclaration */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 136 /* MethodDeclaration */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: + case 140 /* MethodDeclaration */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -21094,16 +22640,13 @@ var ts; /** Checks a type reference node as an expression. */ function checkTypeNodeAsExpression(node) { // When we are emitting type metadata for decorators, we need to try to check the type - // as if it were an expression so that we can emit the type in a value position when we + // as if it were an expression so that we can emit the type in a value position when we // serialize the type metadata. - if (node && node.kind === 144 /* TypeReference */) { - var type = getTypeFromTypeNode(node); - var shouldCheckIfUnknownType = type === unknownType && compilerOptions.isolatedModules; - if (!type || (!shouldCheckIfUnknownType && type.flags & (2097279 /* Intrinsic */ | 132 /* NumberLike */ | 258 /* StringLike */))) { - return; - } - if (shouldCheckIfUnknownType || type.symbol.valueDeclaration) { - checkExpression(node.typeName); + if (node && node.kind === 148 /* TypeReference */) { + var root = getFirstIdentifier(node.typeName); + var rootSymbol = resolveName(root, root.text, 107455 /* Value */, undefined, undefined); + if (rootSymbol && rootSymbol.flags & 8388608 /* Alias */ && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { + markAliasSymbolAsReferenced(rootSymbol); } } } @@ -21113,20 +22656,20 @@ var ts; */ function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 134 /* PropertyDeclaration */: + case 138 /* PropertyDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 131 /* Parameter */: + case 135 /* Parameter */: checkTypeNodeAsExpression(node.type); break; - case 136 /* MethodDeclaration */: + case 140 /* MethodDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 138 /* GetAccessor */: + case 142 /* GetAccessor */: checkTypeNodeAsExpression(node.type); break; - case 139 /* SetAccessor */: - checkTypeNodeAsExpression(getSetAccessorTypeAnnotationNode(node)); + case 143 /* SetAccessor */: + checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node)); break; } } @@ -21154,25 +22697,25 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 204 /* ClassDeclaration */: + case 211 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 136 /* MethodDeclaration */: + case 140 /* MethodDeclaration */: checkParameterTypeAnnotationsAsExpressions(node); // fall-through - case 139 /* SetAccessor */: - case 138 /* GetAccessor */: - case 134 /* PropertyDeclaration */: - case 131 /* Parameter */: + case 143 /* SetAccessor */: + case 142 /* GetAccessor */: + case 138 /* PropertyDeclaration */: + case 135 /* Parameter */: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 131 /* Parameter */) { + if (node.kind === 135 /* Parameter */) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); @@ -21188,10 +22731,17 @@ var ts; function checkFunctionLikeDeclaration(node) { checkDecorators(node); 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; + } // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 129 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 133 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -21217,7 +22767,12 @@ var ts; } checkSourceElement(node.body); if (node.type && !isAccessor(node.kind) && !node.asteriskToken) { - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); + var returnType = getTypeFromTypeNode(node.type); + var promisedType; + if (isAsync) { + promisedType = checkAsyncFunctionReturnType(node); + } + checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); } if (produceDiagnostics && !node.type) { // Report an implicit any error if there is no body, no explicit return type, and node is not a private method @@ -21235,11 +22790,11 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 182 /* Block */) { + if (node.kind === 189 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 209 /* ModuleBlock */) { + if (ts.isFunctionBlock(node) || node.kind === 216 /* ModuleBlock */) { checkFunctionAndClassExpressionBodies(node); } } @@ -21258,12 +22813,12 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 134 /* PropertyDeclaration */ || - node.kind === 133 /* PropertySignature */ || - node.kind === 136 /* MethodDeclaration */ || - node.kind === 135 /* MethodSignature */ || - node.kind === 138 /* GetAccessor */ || - node.kind === 139 /* SetAccessor */) { + if (node.kind === 138 /* PropertyDeclaration */ || + node.kind === 137 /* PropertySignature */ || + node.kind === 140 /* MethodDeclaration */ || + node.kind === 139 /* MethodSignature */ || + node.kind === 142 /* GetAccessor */ || + node.kind === 143 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -21272,7 +22827,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 131 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 135 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -21288,7 +22843,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 65 /* Identifier */; + var isDeclaration_1 = node.kind !== 66 /* Identifier */; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -21311,7 +22866,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 65 /* Identifier */; + var isDeclaration_2 = node.kind !== 66 /* Identifier */; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -21325,12 +22880,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 208 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 215 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 230 /* SourceFile */ && ts.isExternalModule(parent)) { + if (parent.kind === 245 /* SourceFile */ && ts.isExternalModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -21359,13 +22914,13 @@ var ts; // let x = 0; // symbol for this declaration will be 'symbol' // } // skip block-scoped variables and parameters - if ((ts.getCombinedNodeFlags(node) & 12288 /* BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { + if ((ts.getCombinedNodeFlags(node) & 49152 /* BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { return; } // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 201 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 208 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -21374,25 +22929,25 @@ var ts; if (localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { - if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 12288 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 202 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 183 /* VariableStatement */ && varDeclList.parent.parent + if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152 /* BlockScoped */) { + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 209 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 190 /* VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; // names of block-scoped and function scoped variables can collide only // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) var namesShareScope = container && - (container.kind === 182 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 209 /* ModuleBlock */ || - container.kind === 208 /* ModuleDeclaration */ || - container.kind === 230 /* SourceFile */); + (container.kind === 189 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 216 /* ModuleBlock */ || + container.kind === 215 /* ModuleDeclaration */ || + container.kind === 245 /* SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail // since LHS will be block scoped name instead of function scoped if (!namesShareScope) { - var name_13 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_13, name_13); + 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); } } } @@ -21400,18 +22955,18 @@ var ts; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 131 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 135 /* Parameter */) { return; } var func = ts.getContainingFunction(node); visit(node.initializer); function visit(n) { - if (n.kind === 65 /* Identifier */) { + if (n.kind === 66 /* Identifier */) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; // check FunctionLikeDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name and if this entry matches the resolved symbol if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455 /* Value */) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 131 /* Parameter */) { + if (referencedSymbol.valueDeclaration.kind === 135 /* Parameter */) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -21437,7 +22992,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 129 /* ComputedPropertyName */) { + if (node.name.kind === 133 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -21448,7 +23003,7 @@ var ts; ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 131 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 135 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -21480,10 +23035,10 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 134 /* PropertyDeclaration */ && node.kind !== 133 /* PropertySignature */) { + if (node.kind !== 138 /* PropertyDeclaration */ && node.kind !== 137 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 201 /* VariableDeclaration */ || node.kind === 155 /* BindingElement */) { + if (node.kind === 208 /* VariableDeclaration */ || node.kind === 160 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -21504,21 +23059,19 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarVariableDeclarationList(node.declarationList) || checkGrammarForDisallowedLetOrConstStatement(node); ts.forEach(node.declarationList.declarations, checkSourceElement); } - function checkGrammarDisallowedModifiersInBlockOrObjectLiteralExpression(node) { - if (node.modifiers) { - if (inBlockOrObjectLiteralExpression(node)) { + function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { + // We only disallow modifier on a method declaration if it is a property of object-literal-expression + if (node.modifiers && node.parent.kind === 162 /* ObjectLiteralExpression */) { + if (ts.isAsyncFunctionLike(node)) { + if (node.modifiers.length > 1) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + } + else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } } } - function inBlockOrObjectLiteralExpression(node) { - while (node) { - if (node.kind === 182 /* Block */ || node.kind === 157 /* ObjectLiteralExpression */) { - return true; - } - node = node.parent; - } - } function checkExpressionStatement(node) { // Grammar checking checkGrammarStatementInAmbientContext(node); @@ -21546,12 +23099,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 202 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 209 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 202 /* VariableDeclarationList */) { + if (node.initializer.kind === 209 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -21571,14 +23124,14 @@ var ts; // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 202 /* VariableDeclarationList */) { + if (node.initializer.kind === 209 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); // There may be a destructuring assignment on the left side - if (varExpr.kind === 156 /* ArrayLiteralExpression */ || varExpr.kind === 157 /* ObjectLiteralExpression */) { + if (varExpr.kind === 161 /* ArrayLiteralExpression */ || varExpr.kind === 162 /* ObjectLiteralExpression */) { // iteratedType may be undefined. In this case, we still want to check the structure of // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like // to short circuit the type relation checking as much as possible, so we pass the unknownType. @@ -21607,7 +23160,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 202 /* VariableDeclarationList */) { + if (node.initializer.kind === 209 /* VariableDeclarationList */) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -21621,7 +23174,7 @@ var ts; // and Expr must be an expression of type Any, an object type, or a type parameter type. var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 156 /* ArrayLiteralExpression */ || varExpr.kind === 157 /* ObjectLiteralExpression */) { + if (varExpr.kind === 161 /* ArrayLiteralExpression */ || varExpr.kind === 162 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */)) { @@ -21635,7 +23188,7 @@ var ts; var rightType = checkExpression(node.expression); // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved // in this case error about missing name is already reported - do not report extra one - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 48128 /* ObjectType */ | 512 /* TypeParameter */)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 /* ObjectType */ | 512 /* TypeParameter */)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); } checkSourceElement(node.statement); @@ -21860,7 +23413,7 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 138 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 139 /* SetAccessor */))); + return !!(node.kind === 142 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 143 /* SetAccessor */))); } function checkReturnStatement(node) { // Grammar checking @@ -21883,22 +23436,34 @@ var ts; // for generators. return; } - if (func.kind === 139 /* SetAccessor */) { + if (func.kind === 143 /* SetAccessor */) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 137 /* Constructor */) { + else if (func.kind === 141 /* Constructor */) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func) || signature.typePredicate) { - checkTypeAssignableTo(exprType, returnType, node.expression, undefined); + 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); + } + else { + checkTypeAssignableTo(exprType, returnType, node.expression); + } } } } } function checkWithStatement(node) { - checkGrammarStatementInAmbientContext(node); + // Grammar checking for withStatement + if (!checkGrammarStatementInAmbientContext(node)) { + if (node.parserContextFlags & 8 /* Await */) { + grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); + } + } checkExpression(node.expression); error(node.expression, ts.Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any); } @@ -21910,7 +23475,7 @@ var ts; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 224 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 239 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -21922,7 +23487,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 223 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 238 /* CaseClause */) { var caseClause = clause; // TypeScript 1.0 spec (April 2014):5.9 // In a 'switch' statement, each 'case' expression must be of a type that is assignable to or from the type of the 'switch' expression. @@ -21943,7 +23508,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 197 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 204 /* LabeledStatement */ && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -21973,7 +23538,7 @@ var ts; if (catchClause) { // Grammar checking if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 65 /* Identifier */) { + if (catchClause.variableDeclaration.name.kind !== 66 /* Identifier */) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -22048,7 +23613,7 @@ var ts; // perform property check if property or indexer is declared in 'type' // this allows to rule out cases when both property and indexer are inherited from the base class var errorNode; - if (prop.valueDeclaration.name.kind === 129 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 133 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -22103,10 +23668,14 @@ var ts; return getTypeOfSymbol(getSymbolOfNode(node)); } function checkClassDeclaration(node) { - if (!node.name && !(node.flags & 256 /* Default */)) { + if (!node.name && !(node.flags & 1024 /* Default */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } checkClassLikeDeclaration(node); + // Interfaces cannot be merged with non-ambient classes. + if (getSymbolOfNode(node).flags & 64 /* Interface */ && !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) { @@ -22207,46 +23776,63 @@ var ts; continue; } var derived = getTargetSymbol(getPropertyOfObjectType(type, base.name)); + var baseDeclarationFlags = getDeclarationFlagsFromSymbol(base); + ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); if (derived) { - var baseDeclarationFlags = getDeclarationFlagsFromSymbol(base); - var derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); - if ((baseDeclarationFlags & 32 /* Private */) || (derivedDeclarationFlags & 32 /* Private */)) { - // either base or derived property is private - not override, skip it - continue; - } - if ((baseDeclarationFlags & 128 /* Static */) !== (derivedDeclarationFlags & 128 /* Static */)) { - // value of 'static' is not the same for properties - not override, skip it - continue; - } - if ((base.flags & derived.flags & 8192 /* Method */) || ((base.flags & 98308 /* PropertyOrAccessor */) && (derived.flags & 98308 /* PropertyOrAccessor */))) { - // method is overridden with method or property/accessor is overridden with property/accessor - correct case - continue; - } - var errorMessage = void 0; - if (base.flags & 8192 /* Method */) { - if (derived.flags & 98304 /* Accessor */) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; + // In order to resolve whether the inherited method was overriden in the base class or not, + // we compare the Symbols obtained. Since getTargetSymbol returns the symbol on the *uninstantiated* + // type declaration, derived and base resolve to the same symbol even in the case of generic classes. + if (derived === base) { + // derived class inherits base without override/redeclaration + var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 211 /* ClassDeclaration */); + // It is an error to inherit an abstract member without implementing it or being declared abstract. + // If there is no declaration for the derived class (as in the case of class expressions), + // then the class cannot be declared abstract. + if (baseDeclarationFlags & 256 /* Abstract */ && (!derivedClassDecl || !(derivedClassDecl.flags & 256 /* Abstract */))) { + 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 { - ts.Debug.assert((derived.flags & 4 /* Property */) !== 0); - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; - } - } - else if (base.flags & 4 /* Property */) { - ts.Debug.assert((derived.flags & 8192 /* Method */) !== 0); - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; } else { - ts.Debug.assert((base.flags & 98304 /* Accessor */) !== 0); - ts.Debug.assert((derived.flags & 8192 /* Method */) !== 0); - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + // derived overrides base. + var derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); + if ((baseDeclarationFlags & 32 /* Private */) || (derivedDeclarationFlags & 32 /* Private */)) { + // either base or derived property is private - not override, skip it + continue; + } + if ((baseDeclarationFlags & 128 /* Static */) !== (derivedDeclarationFlags & 128 /* Static */)) { + // value of 'static' is not the same for properties - not override, skip it + continue; + } + if ((base.flags & derived.flags & 8192 /* Method */) || ((base.flags & 98308 /* PropertyOrAccessor */) && (derived.flags & 98308 /* PropertyOrAccessor */))) { + // method is overridden with method or property/accessor is overridden with property/accessor - correct case + continue; + } + var errorMessage = void 0; + if (base.flags & 8192 /* Method */) { + if (derived.flags & 98304 /* Accessor */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; + } + else { + ts.Debug.assert((derived.flags & 4 /* Property */) !== 0); + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; + } + } + else if (base.flags & 4 /* Property */) { + ts.Debug.assert((derived.flags & 8192 /* Method */) !== 0); + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + } + else { + ts.Debug.assert((base.flags & 98304 /* Accessor */) !== 0); + ts.Debug.assert((derived.flags & 8192 /* Method */) !== 0); + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } + error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } - error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } } } function isAccessor(kind) { - return kind === 138 /* GetAccessor */ || kind === 139 /* SetAccessor */; + return kind === 142 /* GetAccessor */ || kind === 143 /* SetAccessor */; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -22316,7 +23902,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 205 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 212 /* InterfaceDeclaration */); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -22333,6 +23919,16 @@ var ts; checkIndexConstraints(type); } } + // Interfaces cannot merge with non-ambient classes. + if (symbol && symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 211 /* ClassDeclaration */ && !ts.isInAmbientContext(declaration)) { + error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); + break; + } + } + } } ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) { if (!ts.isSupportedExpressionWithTypeArguments(heritageElement)) { @@ -22353,14 +23949,14 @@ var ts; } function computeEnumMemberValues(node) { var nodeLinks = getNodeLinks(node); - if (!(nodeLinks.flags & 128 /* EnumValuesComputed */)) { + if (!(nodeLinks.flags & 8192 /* EnumValuesComputed */)) { var enumSymbol = getSymbolOfNode(node); var enumType = getDeclaredTypeOfSymbol(enumSymbol); var autoValue = 0; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); ts.forEach(node.members, function (member) { - if (member.name.kind !== 129 /* ComputedPropertyName */ && isNumericLiteralName(member.name.text)) { + if (member.name.kind !== 133 /* ComputedPropertyName */ && isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } var initializer = member.initializer; @@ -22394,24 +23990,24 @@ var ts; getNodeLinks(member).enumMemberValue = autoValue++; } }); - nodeLinks.flags |= 128 /* EnumValuesComputed */; + nodeLinks.flags |= 8192 /* EnumValuesComputed */; } function getConstantValueForEnumMemberInitializer(initializer) { return evalConstant(initializer); function evalConstant(e) { switch (e.kind) { - case 170 /* PrefixUnaryExpression */: + case 176 /* PrefixUnaryExpression */: var value = evalConstant(e.operand); if (value === undefined) { return undefined; } switch (e.operator) { - case 33 /* PlusToken */: return value; - case 34 /* MinusToken */: return -value; - case 47 /* TildeToken */: return ~value; + case 34 /* PlusToken */: return value; + case 35 /* MinusToken */: return -value; + case 48 /* TildeToken */: return ~value; } return undefined; - case 172 /* BinaryExpression */: + case 178 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -22421,31 +24017,31 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 44 /* BarToken */: return left | right; - case 43 /* AmpersandToken */: return left & right; - case 41 /* GreaterThanGreaterThanToken */: return left >> right; - case 42 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 40 /* LessThanLessThanToken */: return left << right; - case 45 /* CaretToken */: return left ^ right; - case 35 /* AsteriskToken */: return left * right; - case 36 /* SlashToken */: return left / right; - case 33 /* PlusToken */: return left + right; - case 34 /* MinusToken */: return left - right; - case 37 /* PercentToken */: return left % right; + case 45 /* BarToken */: return left | right; + case 44 /* AmpersandToken */: return left & right; + case 42 /* GreaterThanGreaterThanToken */: return left >> right; + case 43 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 41 /* LessThanLessThanToken */: return left << right; + case 46 /* CaretToken */: return left ^ right; + case 36 /* AsteriskToken */: return left * right; + case 37 /* SlashToken */: return left / right; + case 34 /* PlusToken */: return left + right; + case 35 /* MinusToken */: return left - right; + case 38 /* PercentToken */: return left % right; } return undefined; case 7 /* NumericLiteral */: return +e.text; - case 164 /* ParenthesizedExpression */: + case 169 /* ParenthesizedExpression */: return evalConstant(e.expression); - case 65 /* Identifier */: - case 159 /* ElementAccessExpression */: - case 158 /* PropertyAccessExpression */: + case 66 /* Identifier */: + case 164 /* ElementAccessExpression */: + case 163 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType; var propertyName; - if (e.kind === 65 /* Identifier */) { + if (e.kind === 66 /* Identifier */) { // unqualified names can refer to member that reside in different declaration of the enum so just doing name resolution won't work. // instead pick current enum type and later try to fetch member from the type enumType = currentType; @@ -22453,7 +24049,7 @@ var ts; } else { var expression; - if (e.kind === 159 /* ElementAccessExpression */) { + if (e.kind === 164 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 8 /* StringLiteral */) { return undefined; @@ -22468,10 +24064,10 @@ var ts; // expression part in ElementAccess\PropertyAccess should be either identifier or dottedName var current = expression; while (current) { - if (current.kind === 65 /* Identifier */) { + if (current.kind === 66 /* Identifier */) { break; } - else if (current.kind === 158 /* PropertyAccessExpression */) { + else if (current.kind === 163 /* PropertyAccessExpression */) { current = current.expression; } else { @@ -22540,7 +24136,7 @@ var ts; var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 207 /* EnumDeclaration */) { + if (declaration.kind !== 214 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -22563,8 +24159,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 204 /* ClassDeclaration */ || - (declaration.kind === 203 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 211 /* ClassDeclaration */ || + (declaration.kind === 210 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -22618,12 +24214,12 @@ var ts; error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); } } - // if the module merges with a class declaration in the same lexical scope, + // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 204 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 211 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { - getNodeLinks(node).flags |= 2048 /* LexicalModuleMergesWithClass */; + getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; } } // Checks for ambient external modules. @@ -22640,17 +24236,17 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 128 /* QualifiedName */) { + if (node.kind === 132 /* QualifiedName */) { node = node.left; } - else if (node.kind === 158 /* PropertyAccessExpression */) { + else if (node.kind === 163 /* PropertyAccessExpression */) { node = node.expression; } else { break; } } - ts.Debug.assert(node.kind === 65 /* Identifier */); + ts.Debug.assert(node.kind === 66 /* Identifier */); return node; } function checkExternalImportOrExportDeclaration(node) { @@ -22659,9 +24255,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 209 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; - if (node.parent.kind !== 230 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 218 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 216 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; + if (node.parent.kind !== 245 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 225 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -22684,7 +24280,7 @@ var ts; (symbol.flags & 793056 /* Type */ ? 793056 /* Type */ : 0) | (symbol.flags & 1536 /* Namespace */ ? 1536 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 220 /* ExportSpecifier */ ? + var message = node.kind === 227 /* ExportSpecifier */ ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); @@ -22701,7 +24297,7 @@ var ts; // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors. return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499 /* Modifier */)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -22711,7 +24307,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 214 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 221 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -22760,7 +24356,7 @@ var ts; // If we hit an export in an illegal context, just bail out to avoid cascading errors. return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499 /* Modifier */)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { @@ -22768,8 +24364,8 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 209 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; - if (node.parent.kind !== 230 /* SourceFile */ && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 216 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; + if (node.parent.kind !== 245 /* SourceFile */ && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -22783,7 +24379,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 230 /* SourceFile */ && node.parent.kind !== 209 /* ModuleBlock */ && node.parent.kind !== 208 /* ModuleDeclaration */) { + if (node.parent.kind !== 245 /* SourceFile */ && node.parent.kind !== 216 /* ModuleBlock */ && node.parent.kind !== 215 /* ModuleDeclaration */) { return grammarErrorOnFirstToken(node, errorMessage); } } @@ -22798,16 +24394,16 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 230 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 208 /* ModuleDeclaration */ && container.name.kind === 65 /* Identifier */) { + var container = node.parent.kind === 245 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 215 /* ModuleDeclaration */ && container.name.kind === 66 /* Identifier */) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } // Grammar checking - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499 /* Modifier */)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 65 /* Identifier */) { + if (node.expression.kind === 66 /* Identifier */) { markExportAsReferenced(node); } else { @@ -22826,10 +24422,10 @@ var ts; } } function getModuleStatements(node) { - if (node.kind === 230 /* SourceFile */) { + if (node.kind === 245 /* SourceFile */) { return node.statements; } - if (node.kind === 208 /* ModuleDeclaration */ && node.body.kind === 209 /* ModuleBlock */) { + if (node.kind === 215 /* ModuleDeclaration */ && node.body.kind === 216 /* ModuleBlock */) { return node.body.statements; } return emptyArray; @@ -22860,112 +24456,126 @@ var ts; } } function checkSourceElement(node) { - if (!node) + if (!node) { return; - switch (node.kind) { - case 130 /* TypeParameter */: + } + var kind = node.kind; + if (cancellationToken) { + // Only bother checking on a few construct kinds. We don't want to be excessivly + // hitting the cancellation token on every node we check. + switch (kind) { + case 215 /* ModuleDeclaration */: + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: + case 210 /* FunctionDeclaration */: + cancellationToken.throwIfCancellationRequested(); + } + } + switch (kind) { + case 134 /* TypeParameter */: return checkTypeParameter(node); - case 131 /* Parameter */: + case 135 /* Parameter */: return checkParameter(node); - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: return checkPropertyDeclaration(node); - case 145 /* FunctionType */: - case 146 /* ConstructorType */: - case 140 /* CallSignature */: - case 141 /* ConstructSignature */: + case 149 /* FunctionType */: + case 150 /* ConstructorType */: + case 144 /* CallSignature */: + case 145 /* ConstructSignature */: return checkSignatureDeclaration(node); - case 142 /* IndexSignature */: + case 146 /* IndexSignature */: return checkSignatureDeclaration(node); - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: return checkMethodDeclaration(node); - case 137 /* Constructor */: + case 141 /* Constructor */: return checkConstructorDeclaration(node); - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: return checkAccessorDeclaration(node); - case 144 /* TypeReference */: + case 148 /* TypeReference */: return checkTypeReferenceNode(node); - case 143 /* TypePredicate */: + case 147 /* TypePredicate */: return checkTypePredicate(node); - case 147 /* TypeQuery */: + case 151 /* TypeQuery */: return checkTypeQuery(node); - case 148 /* TypeLiteral */: + case 152 /* TypeLiteral */: return checkTypeLiteral(node); - case 149 /* ArrayType */: + case 153 /* ArrayType */: return checkArrayType(node); - case 150 /* TupleType */: + case 154 /* TupleType */: return checkTupleType(node); - case 151 /* UnionType */: - return checkUnionType(node); - case 152 /* ParenthesizedType */: + case 155 /* UnionType */: + case 156 /* IntersectionType */: + return checkUnionOrIntersectionType(node); + case 157 /* ParenthesizedType */: return checkSourceElement(node.type); - case 203 /* FunctionDeclaration */: + case 210 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 182 /* Block */: - case 209 /* ModuleBlock */: + case 189 /* Block */: + case 216 /* ModuleBlock */: return checkBlock(node); - case 183 /* VariableStatement */: + case 190 /* VariableStatement */: return checkVariableStatement(node); - case 185 /* ExpressionStatement */: + case 192 /* ExpressionStatement */: return checkExpressionStatement(node); - case 186 /* IfStatement */: + case 193 /* IfStatement */: return checkIfStatement(node); - case 187 /* DoStatement */: + case 194 /* DoStatement */: return checkDoStatement(node); - case 188 /* WhileStatement */: + case 195 /* WhileStatement */: return checkWhileStatement(node); - case 189 /* ForStatement */: + case 196 /* ForStatement */: return checkForStatement(node); - case 190 /* ForInStatement */: + case 197 /* ForInStatement */: return checkForInStatement(node); - case 191 /* ForOfStatement */: + case 198 /* ForOfStatement */: return checkForOfStatement(node); - case 192 /* ContinueStatement */: - case 193 /* BreakStatement */: + case 199 /* ContinueStatement */: + case 200 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 194 /* ReturnStatement */: + case 201 /* ReturnStatement */: return checkReturnStatement(node); - case 195 /* WithStatement */: + case 202 /* WithStatement */: return checkWithStatement(node); - case 196 /* SwitchStatement */: + case 203 /* SwitchStatement */: return checkSwitchStatement(node); - case 197 /* LabeledStatement */: + case 204 /* LabeledStatement */: return checkLabeledStatement(node); - case 198 /* ThrowStatement */: + case 205 /* ThrowStatement */: return checkThrowStatement(node); - case 199 /* TryStatement */: + case 206 /* TryStatement */: return checkTryStatement(node); - case 201 /* VariableDeclaration */: + case 208 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 155 /* BindingElement */: + case 160 /* BindingElement */: return checkBindingElement(node); - case 204 /* ClassDeclaration */: + case 211 /* ClassDeclaration */: return checkClassDeclaration(node); - case 205 /* InterfaceDeclaration */: + case 212 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 206 /* TypeAliasDeclaration */: + case 213 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 207 /* EnumDeclaration */: + case 214 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 212 /* ImportDeclaration */: + case 219 /* ImportDeclaration */: return checkImportDeclaration(node); - case 211 /* ImportEqualsDeclaration */: + case 218 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 218 /* ExportDeclaration */: + case 225 /* ExportDeclaration */: return checkExportDeclaration(node); - case 217 /* ExportAssignment */: + case 224 /* ExportAssignment */: return checkExportAssignment(node); - case 184 /* EmptyStatement */: + case 191 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 200 /* DebuggerStatement */: + case 207 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 221 /* MissingDeclaration */: + case 228 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -22980,86 +24590,95 @@ var ts; // Delaying the type check of the body ensures foo has been assigned a type. function checkFunctionAndClassExpressionBodies(node) { switch (node.kind) { - case 165 /* FunctionExpression */: - case 166 /* ArrowFunction */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 177 /* ClassExpression */: + case 183 /* ClassExpression */: ts.forEach(node.members, checkSourceElement); break; - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 137 /* Constructor */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 203 /* FunctionDeclaration */: + case 141 /* Constructor */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 210 /* FunctionDeclaration */: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); break; - case 195 /* WithStatement */: + case 202 /* WithStatement */: checkFunctionAndClassExpressionBodies(node.expression); break; - case 132 /* Decorator */: - case 131 /* Parameter */: - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: - case 153 /* ObjectBindingPattern */: - case 154 /* ArrayBindingPattern */: - case 155 /* BindingElement */: - case 156 /* ArrayLiteralExpression */: - case 157 /* ObjectLiteralExpression */: - case 227 /* PropertyAssignment */: - case 158 /* PropertyAccessExpression */: - case 159 /* ElementAccessExpression */: - case 160 /* CallExpression */: - case 161 /* NewExpression */: - case 162 /* TaggedTemplateExpression */: - case 174 /* TemplateExpression */: - case 180 /* TemplateSpan */: - case 163 /* TypeAssertionExpression */: - case 164 /* ParenthesizedExpression */: - case 168 /* TypeOfExpression */: - case 169 /* VoidExpression */: - case 167 /* DeleteExpression */: - case 170 /* PrefixUnaryExpression */: - case 171 /* PostfixUnaryExpression */: - case 172 /* BinaryExpression */: - case 173 /* ConditionalExpression */: - case 176 /* SpreadElementExpression */: - case 182 /* Block */: - case 209 /* ModuleBlock */: - case 183 /* VariableStatement */: - case 185 /* ExpressionStatement */: - case 186 /* IfStatement */: - case 187 /* DoStatement */: - case 188 /* WhileStatement */: - case 189 /* ForStatement */: - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: - case 192 /* ContinueStatement */: - case 193 /* BreakStatement */: - case 194 /* ReturnStatement */: - case 196 /* SwitchStatement */: - case 210 /* CaseBlock */: - case 223 /* CaseClause */: - case 224 /* DefaultClause */: - case 197 /* LabeledStatement */: - case 198 /* ThrowStatement */: - case 199 /* TryStatement */: - case 226 /* CatchClause */: - case 201 /* VariableDeclaration */: - case 202 /* VariableDeclarationList */: - case 204 /* ClassDeclaration */: - case 207 /* EnumDeclaration */: - case 229 /* EnumMember */: - case 217 /* ExportAssignment */: - case 230 /* SourceFile */: + case 136 /* Decorator */: + case 135 /* Parameter */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: + case 158 /* ObjectBindingPattern */: + case 159 /* ArrayBindingPattern */: + case 160 /* BindingElement */: + case 161 /* ArrayLiteralExpression */: + case 162 /* ObjectLiteralExpression */: + case 242 /* PropertyAssignment */: + case 163 /* PropertyAccessExpression */: + case 164 /* ElementAccessExpression */: + case 165 /* CallExpression */: + case 166 /* NewExpression */: + case 167 /* TaggedTemplateExpression */: + case 180 /* TemplateExpression */: + case 187 /* TemplateSpan */: + case 168 /* TypeAssertionExpression */: + case 186 /* AsExpression */: + case 169 /* ParenthesizedExpression */: + case 173 /* TypeOfExpression */: + case 174 /* VoidExpression */: + case 175 /* AwaitExpression */: + case 172 /* DeleteExpression */: + case 176 /* PrefixUnaryExpression */: + case 177 /* PostfixUnaryExpression */: + case 178 /* BinaryExpression */: + case 179 /* ConditionalExpression */: + case 182 /* SpreadElementExpression */: + case 181 /* YieldExpression */: + case 189 /* Block */: + case 216 /* ModuleBlock */: + case 190 /* VariableStatement */: + case 192 /* ExpressionStatement */: + case 193 /* IfStatement */: + case 194 /* DoStatement */: + case 195 /* WhileStatement */: + case 196 /* ForStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: + case 199 /* ContinueStatement */: + case 200 /* BreakStatement */: + case 201 /* ReturnStatement */: + case 203 /* SwitchStatement */: + case 217 /* CaseBlock */: + case 238 /* CaseClause */: + case 239 /* DefaultClause */: + case 204 /* LabeledStatement */: + case 205 /* ThrowStatement */: + case 206 /* TryStatement */: + case 241 /* CatchClause */: + case 208 /* VariableDeclaration */: + case 209 /* VariableDeclarationList */: + case 211 /* ClassDeclaration */: + case 214 /* EnumDeclaration */: + case 244 /* EnumMember */: + case 224 /* ExportAssignment */: + case 245 /* SourceFile */: + case 237 /* JsxExpression */: + case 230 /* JsxElement */: + case 231 /* JsxSelfClosingElement */: + case 235 /* JsxAttribute */: + case 236 /* JsxSpreadAttribute */: + case 232 /* JsxOpeningElement */: ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; } @@ -23097,15 +24716,33 @@ var ts; links.flags |= 8 /* EmitExtends */; } if (emitDecorate) { - links.flags |= 512 /* EmitDecorate */; + links.flags |= 16 /* EmitDecorate */; } if (emitParam) { - links.flags |= 1024 /* EmitParam */; + links.flags |= 32 /* EmitParam */; + } + if (emitAwaiter) { + links.flags |= 64 /* EmitAwaiter */; + } + if (emitGenerator || (emitAwaiter && languageVersion < 2 /* ES6 */)) { + links.flags |= 128 /* EmitGenerator */; } links.flags |= 1 /* TypeChecked */; } } - function getDiagnostics(sourceFile) { + function getDiagnostics(sourceFile, ct) { + try { + // Record the cancellation token so it can be checked later on during checkSourceElement. + // Do this in a finally block so we can ensure that it gets reset back to nothing after + // this call is done. + cancellationToken = ct; + return getDiagnosticsWorker(sourceFile); + } + finally { + cancellationToken = undefined; + } + } + function getDiagnosticsWorker(sourceFile) { throwIfNonDiagnosticsProducing(); if (sourceFile) { checkSourceFile(sourceFile); @@ -23127,7 +24764,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 195 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 202 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -23150,29 +24787,36 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 230 /* SourceFile */: + case 245 /* SourceFile */: if (!ts.isExternalModule(location)) { break; } - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 207 /* EnumDeclaration */: + case 214 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 177 /* ClassExpression */: - if (location.name) { + case 183 /* ClassExpression */: + var className = location.name; + if (className) { copySymbol(location.symbol, meaning); } - // Fall through - case 204 /* ClassDeclaration */: - case 205 /* InterfaceDeclaration */: + // fall through; this fall-through is necessary because we would like to handle + // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: + // If we didn't come from static member of class or interface, + // add the type parameters into the symbol table + // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. + // Note: that the memberFlags come from previous iteration. if (!(memberFlags & 128 /* Static */)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); } break; - case 165 /* FunctionExpression */: - if (location.name) { + case 170 /* FunctionExpression */: + var funcName = location.name; + if (funcName) { copySymbol(location.symbol, meaning); } break; @@ -23182,11 +24826,20 @@ var ts; } copySymbols(globals, meaning); } - // Returns 'true' if we should stop processing symbols. + /** + * Copy the given symbol into symbol tables if the symbol has the given meaning + * and it doesn't already existed in the symbol table + * @param key a key for storing in symbol table; if undefined, use symbol.name + * @param symbol the symbol to be added into symbol table + * @param meaning meaning of symbol to filter by before adding to symbol table + */ function copySymbol(symbol, meaning) { if (symbol.flags & meaning) { var id = symbol.name; - if (!isReservedMemberName(id) && !ts.hasProperty(symbols, id)) { + // We will copy all symbol regardless of its reserved name because + // symbolsToArray will check whether the key is a reserved name and + // it will not copy symbol with reserved name to the array + if (!ts.hasProperty(symbols, id)) { symbols[id] = symbol; } } @@ -23194,51 +24847,50 @@ var ts; function copySymbols(source, meaning) { if (meaning) { for (var id in source) { - if (ts.hasProperty(source, id)) { - copySymbol(source[id], meaning); - } + var symbol = source[id]; + copySymbol(symbol, meaning); } } } } function isTypeDeclarationName(name) { - return name.kind === 65 /* Identifier */ && + return name.kind === 66 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 130 /* TypeParameter */: - case 204 /* ClassDeclaration */: - case 205 /* InterfaceDeclaration */: - case 206 /* TypeAliasDeclaration */: - case 207 /* EnumDeclaration */: + case 134 /* TypeParameter */: + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: + case 213 /* TypeAliasDeclaration */: + case 214 /* EnumDeclaration */: return true; } } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 128 /* QualifiedName */) { + while (node.parent && node.parent.kind === 132 /* QualifiedName */) { node = node.parent; } - return node.parent && node.parent.kind === 144 /* TypeReference */; + return node.parent && node.parent.kind === 148 /* TypeReference */; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 158 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 163 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 179 /* ExpressionWithTypeArguments */; + return node.parent && node.parent.kind === 185 /* ExpressionWithTypeArguments */; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 128 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 132 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 211 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 218 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 217 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 224 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -23250,11 +24902,11 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 217 /* ExportAssignment */) { + if (entityName.parent.kind === 224 /* ExportAssignment */) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); } - if (entityName.kind !== 158 /* PropertyAccessExpression */) { + if (entityName.kind !== 163 /* PropertyAccessExpression */) { if (isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); @@ -23264,29 +24916,32 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 179 /* ExpressionWithTypeArguments */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 185 /* ExpressionWithTypeArguments */ ? 793056 /* Type */ : 1536 /* Namespace */; meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } + else if ((entityName.parent.kind === 232 /* JsxOpeningElement */) || (entityName.parent.kind === 231 /* JsxSelfClosingElement */)) { + return getJsxElementTagSymbol(entityName.parent); + } else if (ts.isExpression(entityName)) { if (ts.nodeIsMissing(entityName)) { // Missing entity name. return undefined; } - if (entityName.kind === 65 /* Identifier */) { + if (entityName.kind === 66 /* Identifier */) { // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead // return the alias symbol. var meaning = 107455 /* Value */ | 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 158 /* PropertyAccessExpression */) { + else if (entityName.kind === 163 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 128 /* QualifiedName */) { + else if (entityName.kind === 132 /* QualifiedName */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -23295,13 +24950,16 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 144 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 148 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead // return the alias symbol. meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - if (entityName.parent.kind === 143 /* TypePredicate */) { + else if (entityName.parent.kind === 235 /* JsxAttribute */) { + return getJsxAttributePropertySymbol(entityName.parent); + } + if (entityName.parent.kind === 147 /* TypePredicate */) { return resolveEntityName(entityName, 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? @@ -23316,40 +24974,39 @@ var ts; // This is a declaration, call getSymbolOfNode return getSymbolOfNode(node.parent); } - if (node.kind === 65 /* Identifier */ && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 217 /* ExportAssignment */ + if (node.kind === 66 /* Identifier */ && isInRightSideOfImportOrExportAssignment(node)) { + return node.parent.kind === 224 /* ExportAssignment */ ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } switch (node.kind) { - case 65 /* Identifier */: - case 158 /* PropertyAccessExpression */: - case 128 /* QualifiedName */: + case 66 /* Identifier */: + case 163 /* PropertyAccessExpression */: + case 132 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 93 /* ThisKeyword */: - case 91 /* SuperKeyword */: + case 94 /* ThisKeyword */: + case 92 /* SuperKeyword */: var type = checkExpression(node); return type.symbol; - case 114 /* ConstructorKeyword */: + case 118 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 137 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 141 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; case 8 /* StringLiteral */: // External module name in an import declaration - var moduleName; if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 212 /* ImportDeclaration */ || node.parent.kind === 218 /* ExportDeclaration */) && + ((node.parent.kind === 219 /* ImportDeclaration */ || node.parent.kind === 225 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } - // Intentional fall-through + // Fall through case 7 /* NumericLiteral */: // index access - if (node.parent.kind === 159 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind === 164 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -23366,7 +25023,7 @@ var ts; // The function returns a value symbol of an identifier in the short-hand property assignment. // This is necessary as an identifier in short-hand property assignment can contains two meaning: // property name and property value. - if (location && location.kind === 228 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 243 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 107455 /* Value */); } return undefined; @@ -23405,6 +25062,9 @@ var ts; var symbol = getSymbolInfo(node); return symbol && getTypeOfSymbol(symbol); } + if (ts.isBindingPattern(node)) { + return getTypeForVariableLikeDeclaration(node.parent); + } if (isInRightSideOfImportOrExportAssignment(node)) { var symbol = getSymbolInfo(node); var declaredType = symbol && getDeclaredTypeOfSymbol(symbol); @@ -23443,11 +25103,11 @@ var ts; return getNamedMembers(propsByName); } function getRootSymbols(symbol) { - if (symbol.flags & 268435456 /* UnionProperty */) { + if (symbol.flags & 268435456 /* SyntheticProperty */) { var symbols = []; - var name_14 = symbol.name; - ts.forEach(getSymbolLinks(symbol).unionType.types, function (t) { - symbols.push(getPropertyOfType(t, name_14)); + var name_15 = symbol.name; + ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { + symbols.push(getPropertyOfType(t, name_15)); }); return symbols; } @@ -23477,11 +25137,11 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 230 /* SourceFile */) { + if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 245 /* SourceFile */) { return parentSymbol.valueDeclaration; } for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 208 /* ModuleDeclaration */ || n.kind === 207 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { + if ((n.kind === 215 /* ModuleDeclaration */ || n.kind === 214 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { return n; } } @@ -23496,11 +25156,11 @@ var ts; } function isStatementWithLocals(node) { switch (node.kind) { - case 182 /* Block */: - case 210 /* CaseBlock */: - case 189 /* ForStatement */: - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: + case 189 /* Block */: + case 217 /* CaseBlock */: + case 196 /* ForStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: return true; } return false; @@ -23530,22 +25190,22 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 211 /* ImportEqualsDeclaration */: - case 213 /* ImportClause */: - case 214 /* NamespaceImport */: - case 216 /* ImportSpecifier */: - case 220 /* ExportSpecifier */: + case 218 /* ImportEqualsDeclaration */: + case 220 /* ImportClause */: + case 221 /* NamespaceImport */: + case 223 /* ImportSpecifier */: + case 227 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 218 /* ExportDeclaration */: + case 225 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 217 /* ExportAssignment */: - return node.expression && node.expression.kind === 65 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + case 224 /* ExportAssignment */: + return node.expression && node.expression.kind === 66 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 230 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 245 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -23603,7 +25263,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 229 /* EnumMember */) { + if (node.kind === 244 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -23615,196 +25275,51 @@ var ts; } return undefined; } - /** Serializes an EntityName (with substitutions) to an appropriate JS constructor value. Used by the __metadata decorator. */ - function serializeEntityName(node, fallbackPath) { - if (node.kind === 65 /* Identifier */) { - // TODO(ron.buckton): The getExpressionNameSubstitution function has been removed, but calling it - // here has no effect anyway as an identifier in a type name is not an expression. - // var substitution = getExpressionNameSubstitution(node, getGeneratedNameForNode); - // var text = substitution || (node).text; - var text = node.text; - if (fallbackPath) { - fallbackPath.push(text); - } - else { - return text; - } + function isFunctionType(type) { + return type.flags & 80896 /* ObjectType */ && getSignaturesOfType(type, 0 /* Call */).length > 0; + } + function getTypeReferenceSerializationKind(node) { + // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. + var symbol = resolveEntityName(node.typeName, 107455 /* Value */, true); + var constructorType = symbol ? getTypeOfSymbol(symbol) : undefined; + if (constructorType && isConstructorType(constructorType)) { + return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; + } + var type = getTypeFromTypeNode(node); + if (type === unknownType) { + return ts.TypeReferenceSerializationKind.Unknown; + } + else if (type.flags & 1 /* Any */) { + return ts.TypeReferenceSerializationKind.ObjectType; + } + else if (allConstituentTypesHaveKind(type, 16 /* Void */)) { + return ts.TypeReferenceSerializationKind.VoidType; + } + else if (allConstituentTypesHaveKind(type, 8 /* Boolean */)) { + return ts.TypeReferenceSerializationKind.BooleanType; + } + else if (allConstituentTypesHaveKind(type, 132 /* NumberLike */)) { + return ts.TypeReferenceSerializationKind.NumberLikeType; + } + else if (allConstituentTypesHaveKind(type, 258 /* StringLike */)) { + return ts.TypeReferenceSerializationKind.StringLikeType; + } + else if (allConstituentTypesHaveKind(type, 8192 /* Tuple */)) { + return ts.TypeReferenceSerializationKind.ArrayLikeType; + } + else if (allConstituentTypesHaveKind(type, 4194304 /* ESSymbol */)) { + return ts.TypeReferenceSerializationKind.ESSymbolType; + } + else if (isFunctionType(type)) { + return ts.TypeReferenceSerializationKind.TypeWithCallSignature; + } + else if (isArrayType(type)) { + return ts.TypeReferenceSerializationKind.ArrayLikeType; } else { - var left = serializeEntityName(node.left, fallbackPath); - var right = serializeEntityName(node.right, fallbackPath); - if (!fallbackPath) { - return left + "." + right; - } + return ts.TypeReferenceSerializationKind.ObjectType; } } - /** Serializes a TypeReferenceNode to an appropriate JS constructor value. Used by the __metadata decorator. */ - function serializeTypeReferenceNode(node) { - // serialization of a TypeReferenceNode uses the following rules: - // - // * The serialized type of a TypeReference that is `void` is "void 0". - // * The serialized type of a TypeReference that is a `boolean` is "Boolean". - // * The serialized type of a TypeReference that is an enum or `number` is "Number". - // * The serialized type of a TypeReference that is a string literal or `string` is "String". - // * The serialized type of a TypeReference that is a tuple is "Array". - // * The serialized type of a TypeReference that is a `symbol` is "Symbol". - // * The serialized type of a TypeReference with a value declaration is its entity name. - // * The serialized type of a TypeReference with a call or construct signature is "Function". - // * The serialized type of any other type is "Object". - var type = getTypeFromTypeNode(node); - if (type.flags & 16 /* Void */) { - return "void 0"; - } - else if (type.flags & 8 /* Boolean */) { - return "Boolean"; - } - else if (type.flags & 132 /* NumberLike */) { - return "Number"; - } - else if (type.flags & 258 /* StringLike */) { - return "String"; - } - else if (type.flags & 8192 /* Tuple */) { - return "Array"; - } - else if (type.flags & 2097152 /* ESSymbol */) { - return "Symbol"; - } - else if (type === unknownType) { - var fallbackPath = []; - serializeEntityName(node.typeName, fallbackPath); - return fallbackPath; - } - else if (type.symbol && type.symbol.valueDeclaration) { - return serializeEntityName(node.typeName); - } - else if (typeHasCallOrConstructSignatures(type)) { - return "Function"; - } - return "Object"; - } - /** Serializes a TypeNode to an appropriate JS constructor value. Used by the __metadata decorator. */ - function serializeTypeNode(node) { - // serialization of a TypeNode uses the following rules: - // - // * The serialized type of `void` is "void 0" (undefined). - // * The serialized type of a parenthesized type is the serialized type of its nested type. - // * The serialized type of a Function or Constructor type is "Function". - // * The serialized type of an Array or Tuple type is "Array". - // * The serialized type of `boolean` is "Boolean". - // * The serialized type of `string` or a string-literal type is "String". - // * The serialized type of a type reference is handled by `serializeTypeReferenceNode`. - // * The serialized type of any other type node is "Object". - if (node) { - switch (node.kind) { - case 99 /* VoidKeyword */: - return "void 0"; - case 152 /* ParenthesizedType */: - return serializeTypeNode(node.type); - case 145 /* FunctionType */: - case 146 /* ConstructorType */: - return "Function"; - case 149 /* ArrayType */: - case 150 /* TupleType */: - return "Array"; - case 113 /* BooleanKeyword */: - return "Boolean"; - case 123 /* StringKeyword */: - case 8 /* StringLiteral */: - return "String"; - case 121 /* NumberKeyword */: - return "Number"; - case 144 /* TypeReference */: - return serializeTypeReferenceNode(node); - case 147 /* TypeQuery */: - case 148 /* TypeLiteral */: - case 151 /* UnionType */: - case 112 /* AnyKeyword */: - break; - default: - ts.Debug.fail("Cannot serialize unexpected type node."); - break; - } - } - return "Object"; - } - /** Serializes the type of a declaration to an appropriate JS constructor value. Used by the __metadata decorator for a class member. */ - function serializeTypeOfNode(node) { - // serialization of the type of a declaration uses the following rules: - // - // * The serialized type of a ClassDeclaration is "Function" - // * The serialized type of a ParameterDeclaration is the serialized type of its type annotation. - // * The serialized type of a PropertyDeclaration is the serialized type of its type annotation. - // * The serialized type of an AccessorDeclaration is the serialized type of the return type annotation of its getter or parameter type annotation of its setter. - // * The serialized type of any other FunctionLikeDeclaration is "Function". - // * The serialized type of any other node is "void 0". - // - // For rules on serializing type annotations, see `serializeTypeNode`. - switch (node.kind) { - case 204 /* ClassDeclaration */: return "Function"; - case 134 /* PropertyDeclaration */: return serializeTypeNode(node.type); - case 131 /* Parameter */: return serializeTypeNode(node.type); - case 138 /* GetAccessor */: return serializeTypeNode(node.type); - case 139 /* SetAccessor */: return serializeTypeNode(getSetAccessorTypeAnnotationNode(node)); - } - if (ts.isFunctionLike(node)) { - return "Function"; - } - return "void 0"; - } - /** Serializes the parameter types of a function or the constructor of a class. Used by the __metadata decorator for a method or set accessor. */ - function serializeParameterTypesOfNode(node) { - // serialization of parameter types uses the following rules: - // - // * If the declaration is a class, the parameters of the first constructor with a body are used. - // * If the declaration is function-like and has a body, the parameters of the function are used. - // - // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. - if (node) { - var valueDeclaration; - if (node.kind === 204 /* ClassDeclaration */) { - valueDeclaration = ts.getFirstConstructorWithBody(node); - } - else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { - valueDeclaration = node; - } - if (valueDeclaration) { - var result; - var parameters = valueDeclaration.parameters; - var parameterCount = parameters.length; - if (parameterCount > 0) { - result = new Array(parameterCount); - for (var i = 0; i < parameterCount; i++) { - if (parameters[i].dotDotDotToken) { - var parameterType = parameters[i].type; - if (parameterType.kind === 149 /* ArrayType */) { - parameterType = parameterType.elementType; - } - else if (parameterType.kind === 144 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { - parameterType = parameterType.typeArguments[0]; - } - else { - parameterType = undefined; - } - result[i] = serializeTypeNode(parameterType); - } - else { - result[i] = serializeTypeOfNode(parameters[i]); - } - } - return result; - } - } - } - return emptyArray; - } - /** Serializes the return type of function. Used by the __metadata decorator for a method. */ - function serializeReturnTypeOfNode(node) { - if (node && ts.isFunctionLike(node)) { - return serializeTypeNode(node.type); - } - return "void 0"; - } function writeTypeOfDeclaration(declaration, enclosingDeclaration, flags, writer) { // Get type of the symbol if this is the valid symbol otherwise get type at location var symbol = getSymbolOfNode(declaration); @@ -23836,13 +25351,13 @@ var ts; } function getBlockScopedVariableId(n) { ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 155 /* BindingElement */ || (n.parent.kind === 201 /* VariableDeclaration */ && n.parent.name === n); + var isVariableDeclarationOrBindingElement = n.parent.kind === 160 /* BindingElement */ || (n.parent.kind === 208 /* VariableDeclaration */ && n.parent.name === n); var symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || getNodeLinks(n).resolvedSymbol || resolveName(n, n.text, 107455 /* Value */ | 8388608 /* Alias */, undefined, undefined); var isLetOrConst = symbol && (symbol.flags & 2 /* BlockScopedVariable */) && - symbol.valueDeclaration.parent.kind !== 226 /* CatchClause */; + symbol.valueDeclaration.parent.kind !== 241 /* CatchClause */; if (isLetOrConst) { // side-effect of calling this method: // assign id to symbol if it was not yet set @@ -23884,9 +25399,7 @@ var ts; collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, - serializeTypeOfNode: serializeTypeOfNode, - serializeParameterTypesOfNode: serializeParameterTypesOfNode, - serializeReturnTypeOfNode: serializeReturnTypeOfNode + getTypeReferenceSerializationKind: getTypeReferenceSerializationKind }; } function initializeTypeChecker() { @@ -23913,7 +25426,19 @@ var ts; globalNumberType = getGlobalType("Number"); globalBooleanType = getGlobalType("Boolean"); globalRegExpType = getGlobalType("RegExp"); + jsxElementType = getExportedTypeFromNamespace("JSX", JsxNames.Element); + getGlobalClassDecoratorType = ts.memoize(function () { return getGlobalType("ClassDecorator"); }); + getGlobalPropertyDecoratorType = ts.memoize(function () { return getGlobalType("PropertyDecorator"); }); + getGlobalMethodDecoratorType = ts.memoize(function () { return getGlobalType("MethodDecorator"); }); + getGlobalParameterDecoratorType = ts.memoize(function () { return getGlobalType("ParameterDecorator"); }); getGlobalTypedPropertyDescriptorType = ts.memoize(function () { return getGlobalType("TypedPropertyDescriptor", 1); }); + getGlobalPromiseType = ts.memoize(function () { return getGlobalType("Promise", 1); }); + tryGetGlobalPromiseType = ts.memoize(function () { return getGlobalSymbol("Promise", 793056 /* Type */, undefined) && getGlobalPromiseType(); }); + getGlobalPromiseLikeType = ts.memoize(function () { return getGlobalType("PromiseLike", 1); }); + getInstantiatedGlobalPromiseLikeType = ts.memoize(createInstantiatedPromiseLikeType); + getGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Promise"); }); + getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); + getGlobalThenableType = ts.memoize(createThenableType); // If we're in ES6 mode, load the TemplateStringsArray. // Otherwise, default to 'unknown' for the purposes of type checking in LS scenarios. if (languageVersion >= 2 /* ES6 */) { @@ -23937,6 +25462,24 @@ var ts; } anyArrayType = createArrayType(anyType); } + function createInstantiatedPromiseLikeType() { + var promiseLikeType = getGlobalPromiseLikeType(); + if (promiseLikeType !== emptyObjectType) { + return createTypeReference(promiseLikeType, [anyType]); + } + return emptyObjectType; + } + function createThenableType() { + // build the thenable type that is used to verify against a non-promise "thenable" operand to `await`. + var thenPropertySymbol = createSymbol(67108864 /* Transient */ | 4 /* Property */, "then"); + getSymbolLinks(thenPropertySymbol).type = globalFunctionType; + var thenableType = createObjectType(65536 /* Anonymous */); + thenableType.properties = [thenPropertySymbol]; + thenableType.members = createSymbolTable(thenableType.properties); + thenableType.callSignatures = []; + thenableType.constructSignatures = []; + return thenableType; + } // GRAMMAR CHECKING function checkGrammarDecorators(node) { if (!node.decorators) { @@ -23948,7 +25491,7 @@ var ts; else if (languageVersion < 1 /* ES5 */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); } - else if (node.kind === 138 /* GetAccessor */ || node.kind === 139 /* SetAccessor */) { + else if (node.kind === 142 /* GetAccessor */ || node.kind === 143 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -23958,33 +25501,38 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 137 /* Constructor */: - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 142 /* IndexSignature */: - case 208 /* ModuleDeclaration */: - case 212 /* ImportDeclaration */: - case 211 /* ImportEqualsDeclaration */: - case 218 /* ExportDeclaration */: - case 217 /* ExportAssignment */: - case 131 /* Parameter */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 141 /* Constructor */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 146 /* IndexSignature */: + case 215 /* ModuleDeclaration */: + case 219 /* ImportDeclaration */: + case 218 /* ImportEqualsDeclaration */: + case 225 /* ExportDeclaration */: + case 224 /* ExportAssignment */: + case 135 /* Parameter */: break; - case 204 /* ClassDeclaration */: - case 205 /* InterfaceDeclaration */: - case 183 /* VariableStatement */: - case 203 /* FunctionDeclaration */: - case 206 /* TypeAliasDeclaration */: - if (node.modifiers && node.parent.kind !== 209 /* ModuleBlock */ && node.parent.kind !== 230 /* SourceFile */) { + case 210 /* FunctionDeclaration */: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 115 /* AsyncKeyword */) && + node.parent.kind !== 216 /* ModuleBlock */ && node.parent.kind !== 245 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 207 /* EnumDeclaration */: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 70 /* ConstKeyword */) && - node.parent.kind !== 209 /* ModuleBlock */ && node.parent.kind !== 230 /* SourceFile */) { + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: + case 190 /* VariableStatement */: + case 213 /* TypeAliasDeclaration */: + if (node.modifiers && node.parent.kind !== 216 /* ModuleBlock */ && node.parent.kind !== 245 /* SourceFile */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + break; + case 214 /* EnumDeclaration */: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 71 /* ConstKeyword */) && + node.parent.kind !== 216 /* ModuleBlock */ && node.parent.kind !== 245 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -23994,19 +25542,19 @@ var ts; if (!node.modifiers) { return; } - var lastStatic, lastPrivate, lastProtected, lastDeclare; + var lastStatic, lastPrivate, lastProtected, lastDeclare, lastAsync; var flags = 0; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; switch (modifier.kind) { - case 108 /* PublicKeyword */: - case 107 /* ProtectedKeyword */: - case 106 /* PrivateKeyword */: + case 109 /* PublicKeyword */: + case 108 /* ProtectedKeyword */: + case 107 /* PrivateKeyword */: var text = void 0; - if (modifier.kind === 108 /* PublicKeyword */) { + if (modifier.kind === 109 /* PublicKeyword */) { text = "public"; } - else if (modifier.kind === 107 /* ProtectedKeyword */) { + else if (modifier.kind === 108 /* ProtectedKeyword */) { text = "protected"; lastProtected = modifier; } @@ -24020,74 +25568,159 @@ var ts; else if (flags & 128 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (node.parent.kind === 209 /* ModuleBlock */ || node.parent.kind === 230 /* SourceFile */) { + else if (flags & 512 /* Async */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); + } + else if (node.parent.kind === 216 /* ModuleBlock */ || node.parent.kind === 245 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } + else if (flags & 256 /* Abstract */) { + if (modifier.kind === 107 /* PrivateKeyword */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); + } + else { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract"); + } + } flags |= ts.modifierToFlag(modifier.kind); break; - case 109 /* StaticKeyword */: + case 110 /* StaticKeyword */: if (flags & 128 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (node.parent.kind === 209 /* ModuleBlock */ || node.parent.kind === 230 /* SourceFile */) { + else if (flags & 512 /* Async */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); + } + else if (node.parent.kind === 216 /* ModuleBlock */ || node.parent.kind === 245 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 131 /* Parameter */) { + else if (node.kind === 135 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } + else if (flags & 256 /* Abstract */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); + } flags |= 128 /* Static */; lastStatic = modifier; break; - case 78 /* ExportKeyword */: + case 79 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } else if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (node.parent.kind === 204 /* ClassDeclaration */) { + else if (flags & 256 /* Abstract */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); + } + else if (flags & 512 /* Async */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); + } + else if (node.parent.kind === 211 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 131 /* Parameter */) { + else if (node.kind === 135 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 115 /* DeclareKeyword */: + case 119 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (node.parent.kind === 204 /* ClassDeclaration */) { + else if (flags & 512 /* Async */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); + } + else if (node.parent.kind === 211 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 131 /* Parameter */) { + else if (node.kind === 135 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 209 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 216 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; + case 112 /* AbstractKeyword */: + if (flags & 256 /* Abstract */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); + } + if (node.kind !== 211 /* ClassDeclaration */) { + if (node.kind !== 140 /* MethodDeclaration */) { + return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); + } + if (!(node.parent.kind === 211 /* ClassDeclaration */ && node.parent.flags & 256 /* Abstract */)) { + return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); + } + if (flags & 128 /* Static */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); + } + if (flags & 32 /* Private */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); + } + } + flags |= 256 /* Abstract */; + break; + case 115 /* AsyncKeyword */: + if (flags & 512 /* Async */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); + } + else if (flags & 2 /* Ambient */ || ts.isInAmbientContext(node.parent)) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); + } + else if (node.kind === 135 /* Parameter */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); + } + flags |= 512 /* Async */; + lastAsync = modifier; + break; } } - if (node.kind === 137 /* Constructor */) { + if (node.kind === 141 /* Constructor */) { if (flags & 128 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } + if (flags & 256 /* Abstract */) { + return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); + } else if (flags & 64 /* Protected */) { return grammarErrorOnNode(lastProtected, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected"); } else if (flags & 32 /* Private */) { return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } + else if (flags & 512 /* Async */) { + return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); + } + return; } - else if ((node.kind === 212 /* ImportDeclaration */ || node.kind === 211 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { - return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare"); + else if ((node.kind === 219 /* ImportDeclaration */ || node.kind === 218 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 131 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 135 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } + if (flags & 512 /* Async */) { + return checkGrammarAsyncModifier(node, lastAsync); + } + } + function checkGrammarAsyncModifier(node, asyncModifier) { + if (languageVersion < 2 /* ES6 */) { + return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); + } + switch (node.kind) { + case 140 /* MethodDeclaration */: + case 210 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: + if (!node.asteriskToken) { + return false; + } + break; + } + return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); } function checkGrammarForDisallowedTrailingComma(list) { if (list && list.hasTrailingComma) { @@ -24149,7 +25782,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 166 /* ArrowFunction */) { + if (node.kind === 171 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -24172,7 +25805,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); } - if (parameter.flags & 499 /* Modifier */) { + if (parameter.flags & 2035 /* Modifier */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); } if (parameter.questionToken) { @@ -24184,7 +25817,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 !== 123 /* StringKeyword */ && parameter.type.kind !== 121 /* NumberKeyword */) { + if (parameter.type.kind !== 127 /* StringKeyword */ && parameter.type.kind !== 125 /* NumberKeyword */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -24192,7 +25825,7 @@ var ts; } } function checkGrammarForIndexSignatureModifier(node) { - if (node.flags & 499 /* Modifier */) { + if (node.flags & 2035 /* Modifier */) { grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_not_permitted_on_index_signature_members); } } @@ -24212,20 +25845,20 @@ var ts; return checkGrammarForDisallowedTrailingComma(typeArguments) || checkGrammarForAtLeastOneTypeArgument(node, typeArguments); } - function checkGrammarForOmittedArgument(node, arguments) { - if (arguments) { + function checkGrammarForOmittedArgument(node, args) { + if (args) { var sourceFile = ts.getSourceFileOfNode(node); - for (var _i = 0; _i < arguments.length; _i++) { - var arg = arguments[_i]; - if (arg.kind === 178 /* OmittedExpression */) { + for (var _i = 0; _i < args.length; _i++) { + var arg = args[_i]; + if (arg.kind === 184 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } } } - function checkGrammarArguments(node, arguments) { - return checkGrammarForDisallowedTrailingComma(arguments) || - checkGrammarForOmittedArgument(node, arguments); + function checkGrammarArguments(node, args) { + return checkGrammarForDisallowedTrailingComma(args) || + checkGrammarForOmittedArgument(node, args); } function checkGrammarHeritageClause(node) { var types = node.types; @@ -24244,7 +25877,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 === 79 /* ExtendsKeyword */) { + if (heritageClause.token === 80 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -24257,7 +25890,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 102 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 103 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -24273,14 +25906,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 79 /* ExtendsKeyword */) { + if (heritageClause.token === 80 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 102 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 103 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -24291,19 +25924,19 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 129 /* ComputedPropertyName */) { + if (node.kind !== 133 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 172 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 23 /* CommaToken */) { + if (computedPropertyName.expression.kind === 178 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 23 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 203 /* FunctionDeclaration */ || - node.kind === 165 /* FunctionExpression */ || - node.kind === 136 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 210 /* FunctionDeclaration */ || + node.kind === 170 /* FunctionExpression */ || + node.kind === 140 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -24328,11 +25961,11 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccesor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var name_15 = prop.name; - if (prop.kind === 178 /* OmittedExpression */ || - name_15.kind === 129 /* ComputedPropertyName */) { + var name_16 = prop.name; + if (prop.kind === 184 /* OmittedExpression */ || + name_16.kind === 133 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it - checkGrammarComputedPropertyName(name_15); + checkGrammarComputedPropertyName(name_16); continue; } // ECMA-262 11.1.5 Object Initialiser @@ -24344,70 +25977,91 @@ var ts; // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; - if (prop.kind === 227 /* PropertyAssignment */ || prop.kind === 228 /* ShorthandPropertyAssignment */) { + if (prop.kind === 242 /* PropertyAssignment */ || prop.kind === 243 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_15.kind === 7 /* NumericLiteral */) { - checkGrammarNumericLiteral(name_15); + if (name_16.kind === 7 /* NumericLiteral */) { + checkGrammarNumericLiteral(name_16); } currentKind = Property; } - else if (prop.kind === 136 /* MethodDeclaration */) { + else if (prop.kind === 140 /* MethodDeclaration */) { currentKind = Property; } - else if (prop.kind === 138 /* GetAccessor */) { + else if (prop.kind === 142 /* GetAccessor */) { currentKind = GetAccessor; } - else if (prop.kind === 139 /* SetAccessor */) { + else if (prop.kind === 143 /* SetAccessor */) { currentKind = SetAccesor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - if (!ts.hasProperty(seen, name_15.text)) { - seen[name_15.text] = currentKind; + if (!ts.hasProperty(seen, name_16.text)) { + seen[name_16.text] = currentKind; } else { - var existingKind = seen[name_15.text]; + var existingKind = seen[name_16.text]; if (currentKind === Property && existingKind === Property) { continue; } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[name_15.text] = currentKind | existingKind; + seen[name_16.text] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_15, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_16, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_15, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_16, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } } + function checkGrammarJsxElement(node) { + var seen = {}; + for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { + var attr = _a[_i]; + if (attr.kind === 236 /* JsxSpreadAttribute */) { + continue; + } + var jsxAttr = attr; + var name_17 = jsxAttr.name; + if (!ts.hasProperty(seen, name_17.text)) { + seen[name_17.text] = true; + } + else { + return grammarErrorOnNode(name_17, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + } + var initializer = jsxAttr.initializer; + if (initializer && initializer.kind === 237 /* JsxExpression */ && !initializer.expression) { + return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); + } + } + } function checkGrammarForInOrForOfStatement(forInOrOfStatement) { if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 202 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 209 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 190 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 197 /* ForInStatement */ ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = variableList.declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 190 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 197 /* ForInStatement */ ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 190 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 197 /* ForInStatement */ ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -24430,10 +26084,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 138 /* GetAccessor */ && accessor.parameters.length) { + else if (kind === 142 /* GetAccessor */ && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 139 /* SetAccessor */) { + else if (kind === 143 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -24445,7 +26099,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); } - else if (parameter.flags & 499 /* Modifier */) { + else if (parameter.flags & 2035 /* Modifier */) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } else if (parameter.questionToken) { @@ -24458,17 +26112,17 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 129 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 133 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } function checkGrammarMethod(node) { - if (checkGrammarDisallowedModifiersInBlockOrObjectLiteralExpression(node) || + if (checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) || checkGrammarFunctionLikeDeclaration(node) || checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 157 /* ObjectLiteralExpression */) { + if (node.parent.kind === 162 /* ObjectLiteralExpression */) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -24492,22 +26146,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 === 205 /* InterfaceDeclaration */) { + else if (node.parent.kind === 212 /* InterfaceDeclaration */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } - else if (node.parent.kind === 148 /* TypeLiteral */) { + else if (node.parent.kind === 152 /* TypeLiteral */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 189 /* ForStatement */: - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: - case 187 /* DoStatement */: - case 188 /* WhileStatement */: + case 196 /* ForStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: + case 194 /* DoStatement */: + case 195 /* WhileStatement */: return true; - case 197 /* LabeledStatement */: + case 204 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -24519,11 +26173,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 197 /* LabeledStatement */: + case 204 /* LabeledStatement */: if (node.label && current.label.text === node.label.text) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 192 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 199 /* ContinueStatement */ && !isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -24531,8 +26185,8 @@ var ts; return false; } break; - case 196 /* SwitchStatement */: - if (node.kind === 193 /* BreakStatement */ && !node.label) { + case 203 /* SwitchStatement */: + if (node.kind === 200 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -24547,13 +26201,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 193 /* BreakStatement */ + var message = node.kind === 200 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 193 /* BreakStatement */ + var message = node.kind === 200 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -24565,7 +26219,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 === 154 /* ArrayBindingPattern */ || node.name.kind === 153 /* ObjectBindingPattern */) { + if (node.name.kind === 159 /* ArrayBindingPattern */ || node.name.kind === 158 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -24575,7 +26229,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 190 /* ForInStatement */ && node.parent.parent.kind !== 191 /* ForOfStatement */) { + if (node.parent.parent.kind !== 197 /* ForInStatement */ && node.parent.parent.kind !== 198 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { // Error on equals token which immediate precedes the initializer @@ -24602,7 +26256,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 65 /* Identifier */) { + if (name.kind === 66 /* Identifier */) { if (name.text === "let") { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } @@ -24611,7 +26265,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 178 /* OmittedExpression */) { + if (element.kind !== 184 /* OmittedExpression */) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -24628,15 +26282,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 186 /* IfStatement */: - case 187 /* DoStatement */: - case 188 /* WhileStatement */: - case 195 /* WithStatement */: - case 189 /* ForStatement */: - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: + case 193 /* IfStatement */: + case 194 /* DoStatement */: + case 195 /* WhileStatement */: + case 202 /* WithStatement */: + case 196 /* ForStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: return false; - case 197 /* LabeledStatement */: + case 204 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -24652,9 +26306,9 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 170 /* PrefixUnaryExpression */) { + if (expression.kind === 176 /* PrefixUnaryExpression */) { var unaryExpression = expression; - if (unaryExpression.operator === 33 /* PlusToken */ || unaryExpression.operator === 34 /* MinusToken */) { + if (unaryExpression.operator === 34 /* PlusToken */ || unaryExpression.operator === 35 /* MinusToken */) { expression = unaryExpression.operand; } } @@ -24669,7 +26323,7 @@ var ts; return false; } function checkGrammarEnumDeclaration(enumDecl) { - var enumIsConst = (enumDecl.flags & 8192 /* Const */) !== 0; + var enumIsConst = (enumDecl.flags & 32768 /* Const */) !== 0; var hasError = false; // skip checks below for const enums - they allow arbitrary initializers as long as they can be evaluated to constant expressions. // since all values are known in compile time - it is not necessary to check that constant enum section precedes computed enum members. @@ -24681,7 +26335,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 129 /* ComputedPropertyName */) { + if (node.name.kind === 133 /* ComputedPropertyName */) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else if (inAmbientContext) { @@ -24723,6 +26377,10 @@ var ts; return true; } } + function isEvalOrArgumentsIdentifier(node) { + return node.kind === 66 /* Identifier */ && + (node.text === "eval" || node.text === "arguments"); + } function checkGrammarConstructorTypeParameters(node) { if (node.typeParameters) { return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); @@ -24740,12 +26398,12 @@ var ts; return true; } } - else if (node.parent.kind === 205 /* InterfaceDeclaration */) { + else if (node.parent.kind === 212 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 148 /* TypeLiteral */) { + else if (node.parent.kind === 152 /* TypeLiteral */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -24765,13 +26423,13 @@ var ts; // export_opt ExternalImportDeclaration // export_opt AmbientDeclaration // - if (node.kind === 205 /* InterfaceDeclaration */ || - node.kind === 212 /* ImportDeclaration */ || - node.kind === 211 /* ImportEqualsDeclaration */ || - node.kind === 218 /* ExportDeclaration */ || - node.kind === 217 /* ExportAssignment */ || + if (node.kind === 212 /* InterfaceDeclaration */ || + node.kind === 219 /* ImportDeclaration */ || + node.kind === 218 /* ImportEqualsDeclaration */ || + node.kind === 225 /* ExportDeclaration */ || + node.kind === 224 /* ExportAssignment */ || (node.flags & 2 /* Ambient */) || - (node.flags & (1 /* Export */ | 256 /* Default */))) { + (node.flags & (1 /* Export */ | 1024 /* Default */))) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); @@ -24779,7 +26437,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 === 183 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 190 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -24805,7 +26463,7 @@ var ts; // to prevent noisyness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 182 /* Block */ || node.parent.kind === 209 /* ModuleBlock */ || node.parent.kind === 230 /* SourceFile */) { + if (node.parent.kind === 189 /* Block */ || node.parent.kind === 216 /* ModuleBlock */ || node.parent.kind === 245 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -24818,7 +26476,7 @@ var ts; } function checkGrammarNumericLiteral(node) { // Grammar checking - if (node.flags & 16384 /* OctalLiteral */ && languageVersion >= 1 /* ES5 */) { + if (node.flags & 65536 /* OctalLiteral */ && languageVersion >= 1 /* ES5 */) { return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); } } @@ -24847,7 +26505,6 @@ var ts; function emitDeclarations(host, resolver, diagnostics, jsFilePath, root) { var newLine = host.getNewLine(); var compilerOptions = host.getCompilerOptions(); - var languageVersion = compilerOptions.target || 0 /* ES3 */; var write; var writeLine; var increaseIndent; @@ -24872,7 +26529,7 @@ var ts; ts.forEach(root.referencedFiles, function (fileReference) { var referencedFile = ts.tryResolveScriptReference(host, root, fileReference); // All the references that are not going to be part of same file - if (referencedFile && ((referencedFile.flags & 2048 /* DeclarationFile */) || + if (referencedFile && ((referencedFile.flags & 8192 /* DeclarationFile */) || ts.shouldEmitToOwnFile(referencedFile, compilerOptions) || !addedGlobalFileReference)) { writeReferencePath(referencedFile); @@ -24888,7 +26545,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 212 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 219 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -24964,10 +26621,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 201 /* VariableDeclaration */) { + if (declaration.kind === 208 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 215 /* NamedImports */ || declaration.kind === 216 /* ImportSpecifier */ || declaration.kind === 213 /* ImportClause */) { + else if (declaration.kind === 222 /* NamedImports */ || declaration.kind === 223 /* ImportSpecifier */ || declaration.kind === 220 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -24985,8 +26642,8 @@ var ts; // Writing of function bar would mark alias declaration foo as visible but we haven't yet visited that declaration so do nothing, // we would write alias foo declaration when we visit it since it would now be marked as visible if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 212 /* ImportDeclaration */) { - // we have to create asynchronous output only after we have collected complete information + if (moduleElementEmitInfo.node.kind === 219 /* ImportDeclaration */) { + // we have to create asynchronous output only after we have collected complete information // because it is possible to enable multiple bindings as asynchronously visible moduleElementEmitInfo.isVisible = true; } @@ -24995,12 +26652,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 208 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 215 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 208 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 215 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -25092,60 +26749,64 @@ var ts; } function emitType(type) { switch (type.kind) { - case 112 /* AnyKeyword */: - case 123 /* StringKeyword */: - case 121 /* NumberKeyword */: - case 113 /* BooleanKeyword */: - case 124 /* SymbolKeyword */: - case 99 /* VoidKeyword */: + case 114 /* AnyKeyword */: + case 127 /* StringKeyword */: + case 125 /* NumberKeyword */: + case 117 /* BooleanKeyword */: + case 128 /* SymbolKeyword */: + case 100 /* VoidKeyword */: case 8 /* StringLiteral */: return writeTextOfNode(currentSourceFile, type); - case 179 /* ExpressionWithTypeArguments */: + case 185 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(type); - case 144 /* TypeReference */: + case 148 /* TypeReference */: return emitTypeReference(type); - case 147 /* TypeQuery */: + case 151 /* TypeQuery */: return emitTypeQuery(type); - case 149 /* ArrayType */: + case 153 /* ArrayType */: return emitArrayType(type); - case 150 /* TupleType */: + case 154 /* TupleType */: return emitTupleType(type); - case 151 /* UnionType */: + case 155 /* UnionType */: return emitUnionType(type); - case 152 /* ParenthesizedType */: + case 156 /* IntersectionType */: + return emitIntersectionType(type); + case 157 /* ParenthesizedType */: return emitParenType(type); - case 145 /* FunctionType */: - case 146 /* ConstructorType */: + case 149 /* FunctionType */: + case 150 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 148 /* TypeLiteral */: + case 152 /* TypeLiteral */: return emitTypeLiteral(type); - case 65 /* Identifier */: + case 66 /* Identifier */: return emitEntityName(type); - case 128 /* QualifiedName */: + case 132 /* QualifiedName */: return emitEntityName(type); + case 147 /* TypePredicate */: + return emitTypePredicate(type); + } + function writeEntityName(entityName) { + if (entityName.kind === 66 /* Identifier */) { + writeTextOfNode(currentSourceFile, entityName); + } + else { + var left = entityName.kind === 132 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 132 /* QualifiedName */ ? entityName.right : entityName.name; + writeEntityName(left); + write("."); + writeTextOfNode(currentSourceFile, right); + } } function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 211 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 218 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); - function writeEntityName(entityName) { - if (entityName.kind === 65 /* Identifier */) { - writeTextOfNode(currentSourceFile, entityName); - } - else { - var left = entityName.kind === 128 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 128 /* QualifiedName */ ? entityName.right : entityName.name; - writeEntityName(left); - write("."); - writeTextOfNode(currentSourceFile, right); - } - } } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 65 /* Identifier */ || node.expression.kind === 158 /* PropertyAccessExpression */); + ts.Debug.assert(node.expression.kind === 66 /* Identifier */ || node.expression.kind === 163 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -25162,6 +26823,11 @@ var ts; write(">"); } } + function emitTypePredicate(type) { + writeTextOfNode(currentSourceFile, type.parameterName); + write(" is "); + emitType(type.type); + } function emitTypeQuery(type) { write("typeof "); emitEntityName(type.exprName); @@ -25178,6 +26844,9 @@ var ts; function emitUnionType(type) { emitSeparatedList(type.types, " | ", emitType); } + function emitIntersectionType(type) { + emitSeparatedList(type.types, " & ", emitType); + } function emitParenType(type) { write("("); emitType(type.type); @@ -25211,14 +26880,14 @@ var ts; } var count = 0; while (true) { - var name_16 = baseName + "_" + (++count); - if (!ts.hasProperty(currentSourceFile.identifiers, name_16)) { - return name_16; + var name_18 = baseName + "_" + (++count); + if (!ts.hasProperty(currentSourceFile.identifiers, name_18)) { + return name_18; } } } function emitExportAssignment(node) { - if (node.expression.kind === 65 /* Identifier */) { + if (node.expression.kind === 66 /* Identifier */) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentSourceFile, node.expression); } @@ -25238,7 +26907,7 @@ var ts; write(";"); writeLine(); // Make all the declarations visible for the export name - if (node.expression.kind === 65 /* Identifier */) { + if (node.expression.kind === 66 /* Identifier */) { var nodes = resolver.collectLinkedAliases(node.expression); // write each of these declarations asynchronously writeAsynchronousModuleElements(nodes); @@ -25257,10 +26926,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 211 /* ImportEqualsDeclaration */ || - (node.parent.kind === 230 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 218 /* ImportEqualsDeclaration */ || + (node.parent.kind === 245 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 230 /* SourceFile */) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 245 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -25270,7 +26939,7 @@ var ts; }); } else { - if (node.kind === 212 /* ImportDeclaration */) { + if (node.kind === 219 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -25288,23 +26957,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 203 /* FunctionDeclaration */: + case 210 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 183 /* VariableStatement */: + case 190 /* VariableStatement */: return writeVariableStatement(node); - case 205 /* InterfaceDeclaration */: + case 212 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 204 /* ClassDeclaration */: + case 211 /* ClassDeclaration */: return writeClassDeclaration(node); - case 206 /* TypeAliasDeclaration */: + case 213 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 207 /* EnumDeclaration */: + case 214 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 211 /* ImportEqualsDeclaration */: + case 218 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 212 /* ImportDeclaration */: + case 219 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -25317,10 +26986,10 @@ var ts; if (node.flags & 1 /* Export */) { write("export "); } - if (node.flags & 256 /* Default */) { + if (node.flags & 1024 /* Default */) { write("default "); } - else if (node.kind !== 205 /* InterfaceDeclaration */) { + else if (node.kind !== 212 /* InterfaceDeclaration */) { write("declare "); } } @@ -25335,9 +27004,12 @@ var ts; if (node.flags & 128 /* Static */) { write("static "); } + if (node.flags & 256 /* Abstract */) { + write("abstract "); + } } function writeImportEqualsDeclaration(node) { - // note usage of writer. methods instead of aliases created, just to make sure we are using + // note usage of writer. methods instead of aliases created, just to make sure we are using // correct writer especially to handle asynchronous alias writing emitJsDocComments(node); if (node.flags & 1 /* Export */) { @@ -25366,7 +27038,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 214 /* NamespaceImport */) { + if (namedBindings.kind === 221 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -25376,7 +27048,7 @@ var ts; } function writeImportDeclaration(node) { if (!node.importClause && !(node.flags & 1 /* Export */)) { - // do not write non-exported import declarations that don't have import clauses + // do not write non-exported import declarations that don't have import clauses return; } emitJsDocComments(node); @@ -25394,7 +27066,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 214 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 221 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -25445,14 +27117,14 @@ var ts; function writeModuleDeclaration(node) { emitJsDocComments(node); emitModuleElementDeclarationFlags(node); - if (node.flags & 32768 /* Namespace */) { + if (node.flags & 131072 /* Namespace */) { write("namespace "); } else { write("module "); } writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 209 /* ModuleBlock */) { + while (node.body.kind !== 216 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -25513,7 +27185,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 136 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); + return node.parent.kind === 140 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -25524,15 +27196,15 @@ var ts; // If there is constraint present and this is not a type parameter of the private method emit the constraint if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 145 /* FunctionType */ || - node.parent.kind === 146 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 148 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 136 /* MethodDeclaration */ || - node.parent.kind === 135 /* MethodSignature */ || - node.parent.kind === 145 /* FunctionType */ || - node.parent.kind === 146 /* ConstructorType */ || - node.parent.kind === 140 /* CallSignature */ || - node.parent.kind === 141 /* ConstructSignature */); + if (node.parent.kind === 149 /* FunctionType */ || + node.parent.kind === 150 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 152 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 140 /* MethodDeclaration */ || + node.parent.kind === 139 /* MethodSignature */ || + node.parent.kind === 149 /* FunctionType */ || + node.parent.kind === 150 /* ConstructorType */ || + node.parent.kind === 144 /* CallSignature */ || + node.parent.kind === 145 /* ConstructSignature */); emitType(node.constraint); } else { @@ -25543,31 +27215,31 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 204 /* ClassDeclaration */: + case 211 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 205 /* InterfaceDeclaration */: + case 212 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 141 /* ConstructSignature */: + case 145 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 140 /* CallSignature */: + case 144 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 204 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 211 /* ClassDeclaration */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 203 /* FunctionDeclaration */: + case 210 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -25598,7 +27270,7 @@ var ts; function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 204 /* ClassDeclaration */) { + if (node.parent.parent.kind === 211 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : @@ -25628,6 +27300,9 @@ var ts; } emitJsDocComments(node); emitModuleElementDeclarationFlags(node); + if (node.flags & 256 /* Abstract */) { + write("abstract "); + } write("class "); writeTextOfNode(currentSourceFile, node.name); var prevEnclosingDeclaration = enclosingDeclaration; @@ -25679,7 +27354,7 @@ var ts; function emitVariableDeclaration(node) { // If we are emitting property it isn't moduleElement and hence we already know it needs to be emitted // so there is no check needed to see if declaration is visible - if (node.kind !== 201 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 208 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -25689,10 +27364,10 @@ var ts; // what we want, namely the name expression enclosed in brackets. writeTextOfNode(currentSourceFile, node.name); // If optional property emit ? - if ((node.kind === 134 /* PropertyDeclaration */ || node.kind === 133 /* PropertySignature */) && ts.hasQuestionToken(node)) { + if ((node.kind === 138 /* PropertyDeclaration */ || node.kind === 137 /* PropertySignature */) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 134 /* PropertyDeclaration */ || node.kind === 133 /* PropertySignature */) && node.parent.kind === 148 /* TypeLiteral */) { + if ((node.kind === 138 /* PropertyDeclaration */ || node.kind === 137 /* PropertySignature */) && node.parent.kind === 152 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32 /* Private */)) { @@ -25701,14 +27376,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 201 /* VariableDeclaration */) { + if (node.kind === 208 /* VariableDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 134 /* PropertyDeclaration */ || node.kind === 133 /* PropertySignature */) { + else if (node.kind === 138 /* PropertyDeclaration */ || node.kind === 137 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. if (node.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? @@ -25717,7 +27392,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 === 204 /* ClassDeclaration */) { + else if (node.parent.kind === 211 /* ClassDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -25749,7 +27424,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 178 /* OmittedExpression */) { + if (element.kind !== 184 /* OmittedExpression */) { elements.push(element); } } @@ -25819,7 +27494,7 @@ var ts; var type = getTypeAnnotationFromAccessor(node); if (!type) { // couldn't get type for the first accessor, try the another one - var anotherAccessor = node.kind === 138 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 142 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -25832,7 +27507,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 138 /* GetAccessor */ + return accessor.kind === 142 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -25841,7 +27516,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 139 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 143 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named if (accessorWithTypeAnnotation.parent.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? @@ -25891,17 +27566,17 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 203 /* FunctionDeclaration */) { + if (node.kind === 210 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 136 /* MethodDeclaration */) { + else if (node.kind === 140 /* MethodDeclaration */) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 203 /* FunctionDeclaration */) { + if (node.kind === 210 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 137 /* Constructor */) { + else if (node.kind === 141 /* Constructor */) { write("constructor"); } else { @@ -25919,11 +27594,11 @@ var ts; } function emitSignatureDeclaration(node) { // Construct signature or constructor type write new Signature - if (node.kind === 141 /* ConstructSignature */ || node.kind === 146 /* ConstructorType */) { + if (node.kind === 145 /* ConstructSignature */ || node.kind === 150 /* ConstructorType */) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 142 /* IndexSignature */) { + if (node.kind === 146 /* IndexSignature */) { write("["); } else { @@ -25933,22 +27608,22 @@ var ts; enclosingDeclaration = node; // Parameters emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 142 /* IndexSignature */) { + if (node.kind === 146 /* IndexSignature */) { write("]"); } else { write(")"); } // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 145 /* FunctionType */ || node.kind === 146 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 148 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 149 /* FunctionType */ || node.kind === 150 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 152 /* TypeLiteral */) { // Emit type literal signature return type only if specified if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 137 /* Constructor */ && !(node.flags & 32 /* Private */)) { + else if (node.kind !== 141 /* Constructor */ && !(node.flags & 32 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -25959,26 +27634,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 141 /* ConstructSignature */: + case 145 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 140 /* CallSignature */: + case 144 /* CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 142 /* IndexSignature */: + case 146 /* IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: if (node.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -25986,7 +27661,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 === 204 /* ClassDeclaration */) { + else if (node.parent.kind === 211 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -26000,7 +27675,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 203 /* FunctionDeclaration */: + case 210 /* FunctionDeclaration */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -26035,9 +27710,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 145 /* FunctionType */ || - node.parent.kind === 146 /* ConstructorType */ || - node.parent.parent.kind === 148 /* TypeLiteral */) { + if (node.parent.kind === 149 /* FunctionType */ || + node.parent.kind === 150 /* ConstructorType */ || + node.parent.parent.kind === 152 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32 /* Private */)) { @@ -26053,24 +27728,24 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 137 /* Constructor */: + case 141 /* Constructor */: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 141 /* ConstructSignature */: + case 145 /* ConstructSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 140 /* CallSignature */: + case 144 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -26078,7 +27753,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 === 204 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 211 /* ClassDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -26091,7 +27766,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 203 /* FunctionDeclaration */: + case 210 /* FunctionDeclaration */: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -26103,12 +27778,12 @@ var ts; } function emitBindingPattern(bindingPattern) { // We have to explicitly emit square bracket and bracket because these tokens are not store inside the node. - if (bindingPattern.kind === 153 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 158 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 154 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 159 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -26127,7 +27802,7 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 178 /* OmittedExpression */) { + if (bindingElement.kind === 184 /* OmittedExpression */) { // If bindingElement is an omittedExpression (i.e. containing elision), // we will emit blank space (although this may differ from users' original code, // it allows emitSeparatedList to write separator appropriately) @@ -26136,7 +27811,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 155 /* BindingElement */) { + else if (bindingElement.kind === 160 /* BindingElement */) { if (bindingElement.propertyName) { // bindingElement has propertyName property in the following case: // { y: [a,b,c] ...} -> bindingPattern will have a property called propertyName for "y" @@ -26161,7 +27836,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 65 /* Identifier */); + ts.Debug.assert(bindingElement.name.kind === 66 /* Identifier */); // If the node is just an identifier, we will simply emit the text associated with the node's name // Example: // original: function foo({y = 10, x}) {} @@ -26177,45 +27852,45 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 203 /* FunctionDeclaration */: - case 208 /* ModuleDeclaration */: - case 211 /* ImportEqualsDeclaration */: - case 205 /* InterfaceDeclaration */: - case 204 /* ClassDeclaration */: - case 206 /* TypeAliasDeclaration */: - case 207 /* EnumDeclaration */: + case 210 /* FunctionDeclaration */: + case 215 /* ModuleDeclaration */: + case 218 /* ImportEqualsDeclaration */: + case 212 /* InterfaceDeclaration */: + case 211 /* ClassDeclaration */: + case 213 /* TypeAliasDeclaration */: + case 214 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 183 /* VariableStatement */: + case 190 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 212 /* ImportDeclaration */: + case 219 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible return emitModuleElement(node, !node.importClause); - case 218 /* ExportDeclaration */: + case 225 /* ExportDeclaration */: return emitExportDeclaration(node); - case 137 /* Constructor */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 141 /* Constructor */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: return writeFunctionDeclaration(node); - case 141 /* ConstructSignature */: - case 140 /* CallSignature */: - case 142 /* IndexSignature */: + case 145 /* ConstructSignature */: + case 144 /* CallSignature */: + case 146 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: return emitAccessorDeclaration(node); - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: return emitPropertyDeclaration(node); - case 229 /* EnumMember */: + case 244 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 217 /* ExportAssignment */: + case 224 /* ExportAssignment */: return emitExportAssignment(node); - case 230 /* SourceFile */: + case 245 /* SourceFile */: return emitSourceFile(node); } } function writeReferencePath(referencedFile) { - var declFileName = referencedFile.flags & 2048 /* DeclarationFile */ + var declFileName = referencedFile.flags & 8192 /* DeclarationFile */ ? referencedFile.fileName // Declaration file, use declaration file name : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") // Own output file so get the .d.ts file @@ -26278,15 +27953,18 @@ var ts; 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};"; // emit output for the __param helper function 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 /* ES3 */; var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; var diagnostics = []; var newLine = host.getNewLine(); + var jsxDesugaring = host.getCompilerOptions().jsx !== 1 /* Preserve */; + var shouldEmitJsx = function (s) { return (s.languageVariant === 1 /* JSX */ && !jsxDesugaring); }; if (targetSourceFile === undefined) { ts.forEach(host.getSourceFiles(), function (sourceFile) { if (ts.shouldEmitToOwnFile(sourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, ".js"); + var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js"); emitFile(jsFilePath, sourceFile); } }); @@ -26297,7 +27975,7 @@ var ts; else { // targetSourceFile is specified (e.g calling emitter from language service or calling getSemanticDiagnostic from language service) if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ts.forEach(host.getSourceFiles(), shouldEmitJsx) ? ".jsx" : ".js"); emitFile(jsFilePath, targetSourceFile); } else if (!ts.isDeclarationFile(targetSourceFile) && compilerOptions.out) { @@ -26351,6 +28029,7 @@ var ts; var extendsEmitted = false; var decorateEmitted = false; var paramEmitted = false; + var awaiterEmitted = false; var tempFlags = 0; var tempVariables; var tempParameters; @@ -26415,10 +28094,10 @@ var ts; // Note that names generated by makeTempVariableName and makeUniqueName will never conflict. function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name = flags === 268435456 /* _i */ ? "_i" : "_n"; - if (isUniqueName(name)) { + var name_19 = flags === 268435456 /* _i */ ? "_i" : "_n"; + if (isUniqueName(name_19)) { tempFlags |= flags; - return name; + return name_19; } } while (true) { @@ -26426,9 +28105,9 @@ var ts; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { - var name_17 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); - if (isUniqueName(name_17)) { - return name_17; + var name_20 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); + if (isUniqueName(name_20)) { + return name_20; } } } @@ -26470,19 +28149,19 @@ var ts; } function generateNameForNode(node) { switch (node.kind) { - case 65 /* Identifier */: + case 66 /* Identifier */: return makeUniqueName(node.text); - case 208 /* ModuleDeclaration */: - case 207 /* EnumDeclaration */: + case 215 /* ModuleDeclaration */: + case 214 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 212 /* ImportDeclaration */: - case 218 /* ExportDeclaration */: + case 219 /* ImportDeclaration */: + case 225 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 203 /* FunctionDeclaration */: - case 204 /* ClassDeclaration */: - case 217 /* ExportAssignment */: + case 210 /* FunctionDeclaration */: + case 211 /* ClassDeclaration */: + case 224 /* ExportAssignment */: return generateNameForExportDefault(); - case 177 /* ClassExpression */: + case 183 /* ClassExpression */: return generateNameForClassExpression(); } } @@ -26653,8 +28332,8 @@ var ts; // Child scopes are always shown with a dot (even if they have no name), // unless it is a computed property. Then it is shown with brackets, // but the brackets are included in the name. - var name_18 = node.name; - if (!name_18 || name_18.kind !== 129 /* ComputedPropertyName */) { + var name_21 = node.name; + if (!name_21 || name_21.kind !== 133 /* ComputedPropertyName */) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -26672,21 +28351,21 @@ var ts; // The scope was already given a name use it recordScopeNameStart(scopeName); } - else if (node.kind === 203 /* FunctionDeclaration */ || - node.kind === 165 /* FunctionExpression */ || - node.kind === 136 /* MethodDeclaration */ || - node.kind === 135 /* MethodSignature */ || - node.kind === 138 /* GetAccessor */ || - node.kind === 139 /* SetAccessor */ || - node.kind === 208 /* ModuleDeclaration */ || - node.kind === 204 /* ClassDeclaration */ || - node.kind === 207 /* EnumDeclaration */) { + else if (node.kind === 210 /* FunctionDeclaration */ || + node.kind === 170 /* FunctionExpression */ || + node.kind === 140 /* MethodDeclaration */ || + node.kind === 139 /* MethodSignature */ || + node.kind === 142 /* GetAccessor */ || + node.kind === 143 /* SetAccessor */ || + node.kind === 215 /* ModuleDeclaration */ || + node.kind === 211 /* ClassDeclaration */ || + node.kind === 214 /* EnumDeclaration */) { // Declaration and has associated name use it if (node.name) { - var name_19 = node.name; + var name_22 = node.name; // For computed property names, the text will include the brackets - scopeName = name_19.kind === 129 /* ComputedPropertyName */ - ? ts.getTextOfNode(name_19) + scopeName = name_22.kind === 133 /* ComputedPropertyName */ + ? ts.getTextOfNode(name_22) : node.name.text; } recordScopeNameStart(scopeName); @@ -26795,7 +28474,7 @@ var ts; if (ts.nodeIsSynthesized(node)) { return emitNodeWithoutSourceMap(node); } - if (node.kind !== 230 /* SourceFile */) { + if (node.kind !== 245 /* SourceFile */) { recordEmitNodeStartSpan(node); emitNodeWithoutSourceMap(node); recordEmitNodeEndSpan(node); @@ -26820,7 +28499,7 @@ var ts; } // Create a temporary variable with a unique unused name. function createTempVariable(flags) { - var result = ts.createSynthesizedNode(65 /* Identifier */); + var result = ts.createSynthesizedNode(66 /* Identifier */); result.text = makeTempVariableName(flags); return result; } @@ -27058,10 +28737,10 @@ var ts; write("("); emit(tempVariable); // Now we emit the expressions - if (node.template.kind === 174 /* TemplateExpression */) { + if (node.template.kind === 180 /* TemplateExpression */) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 172 /* BinaryExpression */ + var needsParens = templateSpan.expression.kind === 178 /* BinaryExpression */ && templateSpan.expression.operatorToken.kind === 23 /* CommaToken */; emitParenthesizedIf(templateSpan.expression, needsParens); }); @@ -27096,7 +28775,7 @@ var ts; // ("abc" + 1) << (2 + "") // rather than // "abc" + (1 << 2) + "" - var needsParens = templateSpan.expression.kind !== 164 /* ParenthesizedExpression */ + var needsParens = templateSpan.expression.kind !== 169 /* ParenthesizedExpression */ && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; if (i > 0 || headEmitted) { // If this is the first span and the head was not emitted, then this templateSpan's @@ -27138,11 +28817,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 160 /* CallExpression */: - case 161 /* NewExpression */: + case 165 /* CallExpression */: + case 166 /* NewExpression */: return parent.expression === template; - case 162 /* TaggedTemplateExpression */: - case 164 /* ParenthesizedExpression */: + case 167 /* TaggedTemplateExpression */: + case 169 /* ParenthesizedExpression */: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; @@ -27163,20 +28842,20 @@ var ts; // TODO (drosen): Note that we need to account for the upcoming 'yield' and // spread ('...') unary operators that are anticipated for ES6. switch (expression.kind) { - case 172 /* BinaryExpression */: + case 178 /* BinaryExpression */: switch (expression.operatorToken.kind) { - case 35 /* AsteriskToken */: - case 36 /* SlashToken */: - case 37 /* PercentToken */: + case 36 /* AsteriskToken */: + case 37 /* SlashToken */: + case 38 /* PercentToken */: return 1 /* GreaterThan */; - case 33 /* PlusToken */: - case 34 /* MinusToken */: + case 34 /* PlusToken */: + case 35 /* MinusToken */: return 0 /* EqualTo */; default: return -1 /* LessThan */; } - case 175 /* YieldExpression */: - case 173 /* ConditionalExpression */: + case 181 /* YieldExpression */: + case 179 /* ConditionalExpression */: return -1 /* LessThan */; default: return 1 /* GreaterThan */; @@ -27187,17 +28866,211 @@ var ts; emit(span.expression); emit(span.literal); } + function jsxEmitReact(node) { + /// Emit a tag name, which is either '"div"' for lower-cased names, or + /// 'Div' for upper-cased or dotted names + function emitTagName(name) { + if (name.kind === 66 /* Identifier */ && ts.isIntrinsicJsxName(name.text)) { + write('"'); + emit(name); + write('"'); + } + else { + emit(name); + } + } + /// Emit an attribute name, which is quoted if it needs to be quoted. Because + /// these emit into an object literal property name, we don't need to be worried + /// about keywords, just non-identifier characters + function emitAttributeName(name) { + if (/[A-Za-z_]+[\w*]/.test(name.text)) { + write('"'); + emit(name); + write('"'); + } + else { + emit(name); + } + } + /// Emit an name/value pair for an attribute (e.g. "x: 3") + function emitJsxAttribute(node) { + emitAttributeName(node.name); + write(": "); + if (node.initializer) { + emit(node.initializer); + } + else { + write("true"); + } + } + function emitJsxElement(openingNode, children) { + // Call React.createElement(tag, ... + emitLeadingComments(openingNode); + write("React.createElement("); + emitTagName(openingNode.tagName); + write(", "); + // Attribute list + if (openingNode.attributes.length === 0) { + // When there are no attributes, React wants "null" + write("null"); + } + else { + // Either emit one big object literal (no spread attribs), or + // a call to React.__spread + var attrs = openingNode.attributes; + if (ts.forEach(attrs, function (attr) { return attr.kind === 236 /* JsxSpreadAttribute */; })) { + write("React.__spread("); + var haveOpenedObjectLiteral = false; + for (var i_2 = 0; i_2 < attrs.length; i_2++) { + if (attrs[i_2].kind === 236 /* JsxSpreadAttribute */) { + // If this is the first argument, we need to emit a {} as the first argument + if (i_2 === 0) { + write("{}, "); + } + if (haveOpenedObjectLiteral) { + write("}"); + haveOpenedObjectLiteral = false; + } + if (i_2 > 0) { + write(", "); + } + emit(attrs[i_2].expression); + } + else { + ts.Debug.assert(attrs[i_2].kind === 235 /* JsxAttribute */); + if (haveOpenedObjectLiteral) { + write(", "); + } + else { + haveOpenedObjectLiteral = true; + if (i_2 > 0) { + write(", "); + } + write("{"); + } + emitJsxAttribute(attrs[i_2]); + } + } + if (haveOpenedObjectLiteral) + write("}"); + write(")"); // closing paren to React.__spread( + } + else { + // One object literal with all the attributes in them + write("{"); + for (var i = 0; i < attrs.length; i++) { + if (i > 0) { + write(", "); + } + emitJsxAttribute(attrs[i]); + } + write("}"); + } + } + // Children + if (children) { + for (var i = 0; i < children.length; i++) { + // Don't emit empty expressions + if (children[i].kind === 237 /* JsxExpression */ && !(children[i].expression)) { + continue; + } + // Don't emit empty strings + if (children[i].kind === 233 /* JsxText */) { + var text = getTextToEmit(children[i]); + if (text !== undefined) { + write(', "'); + write(text); + write('"'); + } + } + else { + write(", "); + emit(children[i]); + } + } + } + // Closing paren + write(")"); // closes "React.createElement(" + emitTrailingComments(openingNode); + } + if (node.kind === 230 /* JsxElement */) { + emitJsxElement(node.openingElement, node.children); + } + else { + ts.Debug.assert(node.kind === 231 /* JsxSelfClosingElement */); + emitJsxElement(node); + } + } + function jsxEmitPreserve(node) { + function emitJsxAttribute(node) { + emit(node.name); + 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 === 236 /* JsxSpreadAttribute */) { + emitJsxSpreadAttribute(attribs[i]); + } + else { + ts.Debug.assert(attribs[i].kind === 235 /* JsxAttribute */); + emitJsxAttribute(attribs[i]); + } + } + } + function emitJsxOpeningOrSelfClosingElement(node) { + write("<"); + emit(node.tagName); + if (node.attributes.length > 0 || (node.kind === 231 /* JsxSelfClosingElement */)) { + write(" "); + } + emitAttributes(node.attributes); + if (node.kind === 231 /* JsxSelfClosingElement */) { + 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 === 230 /* JsxElement */) { + emitJsxElement(node); + } + else { + ts.Debug.assert(node.kind === 231 /* JsxSelfClosingElement */); + emitJsxOpeningOrSelfClosingElement(node); + } + } // This function specifically handles numeric/string literals for enum and accessor 'identifiers'. // In a sense, it does not actually emit identifiers as much as it declares a name for a specific property. // For example, this is utilized when feeding in a result to Object.defineProperty. function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 155 /* BindingElement */); + ts.Debug.assert(node.kind !== 160 /* BindingElement */); if (node.kind === 8 /* StringLiteral */) { emitLiteral(node); } - else if (node.kind === 129 /* ComputedPropertyName */) { + else if (node.kind === 133 /* ComputedPropertyName */) { // if this is a decorated computed property, we will need to capture the result - // of the property expression so that we can apply decorators later. This is to ensure + // of the property expression so that we can apply decorators later. This is to ensure // we don't introduce unintended side effects: // // class C { @@ -27239,64 +29112,70 @@ var ts; function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 156 /* ArrayLiteralExpression */: - case 172 /* BinaryExpression */: - case 160 /* CallExpression */: - case 223 /* CaseClause */: - case 129 /* ComputedPropertyName */: - case 173 /* ConditionalExpression */: - case 132 /* Decorator */: - case 167 /* DeleteExpression */: - case 187 /* DoStatement */: - case 159 /* ElementAccessExpression */: - case 217 /* ExportAssignment */: - case 185 /* ExpressionStatement */: - case 179 /* ExpressionWithTypeArguments */: - case 189 /* ForStatement */: - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: - case 186 /* IfStatement */: - case 161 /* NewExpression */: - case 164 /* ParenthesizedExpression */: - case 171 /* PostfixUnaryExpression */: - case 170 /* PrefixUnaryExpression */: - case 194 /* ReturnStatement */: - case 228 /* ShorthandPropertyAssignment */: - case 176 /* SpreadElementExpression */: - case 196 /* SwitchStatement */: - case 162 /* TaggedTemplateExpression */: - case 180 /* TemplateSpan */: - case 198 /* ThrowStatement */: - case 163 /* TypeAssertionExpression */: - case 168 /* TypeOfExpression */: - case 169 /* VoidExpression */: - case 188 /* WhileStatement */: - case 195 /* WithStatement */: - case 175 /* YieldExpression */: + case 161 /* ArrayLiteralExpression */: + case 178 /* BinaryExpression */: + case 165 /* CallExpression */: + case 238 /* CaseClause */: + case 133 /* ComputedPropertyName */: + case 179 /* ConditionalExpression */: + case 136 /* Decorator */: + case 172 /* DeleteExpression */: + case 194 /* DoStatement */: + case 164 /* ElementAccessExpression */: + case 224 /* ExportAssignment */: + case 192 /* ExpressionStatement */: + case 185 /* ExpressionWithTypeArguments */: + case 196 /* ForStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: + case 193 /* IfStatement */: + case 231 /* JsxSelfClosingElement */: + case 232 /* JsxOpeningElement */: + case 166 /* NewExpression */: + case 169 /* ParenthesizedExpression */: + case 177 /* PostfixUnaryExpression */: + case 176 /* PrefixUnaryExpression */: + case 201 /* ReturnStatement */: + case 243 /* ShorthandPropertyAssignment */: + case 182 /* SpreadElementExpression */: + case 203 /* SwitchStatement */: + case 167 /* TaggedTemplateExpression */: + case 187 /* TemplateSpan */: + case 205 /* ThrowStatement */: + case 168 /* TypeAssertionExpression */: + case 173 /* TypeOfExpression */: + case 174 /* VoidExpression */: + case 195 /* WhileStatement */: + case 202 /* WithStatement */: + case 181 /* YieldExpression */: return true; - case 155 /* BindingElement */: - case 229 /* EnumMember */: - case 131 /* Parameter */: - case 227 /* PropertyAssignment */: - case 134 /* PropertyDeclaration */: - case 201 /* VariableDeclaration */: + case 160 /* BindingElement */: + case 244 /* EnumMember */: + case 135 /* Parameter */: + case 242 /* PropertyAssignment */: + case 138 /* PropertyDeclaration */: + case 208 /* VariableDeclaration */: return parent.initializer === node; - case 158 /* PropertyAccessExpression */: + case 163 /* PropertyAccessExpression */: return parent.expression === node; - case 166 /* ArrowFunction */: - case 165 /* FunctionExpression */: + case 171 /* ArrowFunction */: + case 170 /* FunctionExpression */: return parent.body === node; - case 211 /* ImportEqualsDeclaration */: + case 218 /* ImportEqualsDeclaration */: return parent.moduleReference === node; - case 128 /* QualifiedName */: + case 132 /* QualifiedName */: return parent.left === node; } return false; } function emitExpressionIdentifier(node) { + if (resolver.getNodeCheckFlags(node) & 2048 /* LexicalArguments */) { + write("_arguments"); + return; + } var container = resolver.getReferencedExportContainer(node); if (container) { - if (container.kind === 230 /* SourceFile */) { + if (container.kind === 245 /* SourceFile */) { // Identifier references module export if (languageVersion < 2 /* ES6 */ && compilerOptions.module !== 4 /* System */) { write("exports."); @@ -27311,13 +29190,13 @@ var ts; else if (languageVersion < 2 /* ES6 */) { var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { - if (declaration.kind === 213 /* ImportClause */) { + if (declaration.kind === 220 /* ImportClause */) { // Identifier references default import write(getGeneratedNameForNode(declaration.parent)); write(languageVersion === 0 /* ES3 */ ? '["default"]' : ".default"); return; } - else if (declaration.kind === 216 /* ImportSpecifier */) { + else if (declaration.kind === 223 /* ImportSpecifier */) { // Identifier references named import write(getGeneratedNameForNode(declaration.parent.parent.parent)); write("."); @@ -27337,10 +29216,10 @@ var ts; if (languageVersion < 2 /* ES6 */) { var parent_7 = node.parent; switch (parent_7.kind) { - case 155 /* BindingElement */: - case 204 /* ClassDeclaration */: - case 207 /* EnumDeclaration */: - case 201 /* VariableDeclaration */: + case 160 /* BindingElement */: + case 211 /* ClassDeclaration */: + case 214 /* EnumDeclaration */: + case 208 /* VariableDeclaration */: return parent_7.name === node && resolver.isNestedRedeclaration(parent_7); } } @@ -27374,7 +29253,7 @@ var ts; } else { var flags = resolver.getNodeCheckFlags(node); - if (flags & 16 /* SuperInstance */) { + if (flags & 256 /* SuperInstance */) { write("_super.prototype"); } else { @@ -27415,7 +29294,7 @@ var ts; emit(node.expression); } function emitYieldExpression(node) { - write(ts.tokenToString(110 /* YieldKeyword */)); + write(ts.tokenToString(111 /* YieldKeyword */)); if (node.asteriskToken) { write("*"); } @@ -27424,14 +29303,35 @@ var ts; emit(node.expression); } } + function emitAwaitExpression(node) { + var needsParenthesis = needsParenthesisForAwaitExpressionAsYield(node); + if (needsParenthesis) { + write("("); + } + write(ts.tokenToString(111 /* YieldKeyword */)); + write(" "); + emit(node.expression); + if (needsParenthesis) { + write(")"); + } + } + function needsParenthesisForAwaitExpressionAsYield(node) { + if (node.parent.kind === 178 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + return true; + } + else if (node.parent.kind === 179 /* ConditionalExpression */ && node.parent.condition === node) { + return true; + } + return false; + } function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { - case 65 /* Identifier */: - case 156 /* ArrayLiteralExpression */: - case 158 /* PropertyAccessExpression */: - case 159 /* ElementAccessExpression */: - case 160 /* CallExpression */: - case 164 /* ParenthesizedExpression */: + case 66 /* Identifier */: + case 161 /* ArrayLiteralExpression */: + case 163 /* PropertyAccessExpression */: + case 164 /* ElementAccessExpression */: + case 165 /* CallExpression */: + case 169 /* ParenthesizedExpression */: // This list is not exhaustive and only includes those cases that are relevant // to the check in emitArrayLiteral. More cases can be added as needed. return false; @@ -27451,17 +29351,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 176 /* SpreadElementExpression */) { + if (e.kind === 182 /* SpreadElementExpression */) { e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 156 /* ArrayLiteralExpression */) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 161 /* ArrayLiteralExpression */) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 176 /* SpreadElementExpression */) { + while (i < length && elements[i].kind !== 182 /* SpreadElementExpression */) { i++; } write("["); @@ -27484,7 +29384,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 176 /* SpreadElementExpression */; + return node.kind === 182 /* SpreadElementExpression */; } function emitArrayLiteral(node) { var elements = node.elements; @@ -27497,7 +29397,7 @@ var ts; write("]"); } else { - emitListWithSpread(elements, true, (node.flags & 512 /* MultiLine */) !== 0, + emitListWithSpread(elements, true, (node.flags & 2048 /* MultiLine */) !== 0, /*trailingComma*/ elements.hasTrailingComma, true); } } @@ -27516,7 +29416,7 @@ var ts; emitLinePreservingList(node, properties, languageVersion >= 1 /* ES5 */, true); } else { - var multiLine = (node.flags & 512 /* MultiLine */) !== 0; + var multiLine = (node.flags & 2048 /* MultiLine */) !== 0; if (!multiLine) { write(" "); } @@ -27535,7 +29435,7 @@ var ts; write("}"); } function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { - var multiLine = (node.flags & 512 /* MultiLine */) !== 0; + var multiLine = (node.flags & 2048 /* MultiLine */) !== 0; var properties = node.properties; write("("); if (multiLine) { @@ -27554,7 +29454,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 138 /* GetAccessor */ || property.kind === 139 /* SetAccessor */) { + if (property.kind === 142 /* GetAccessor */ || property.kind === 143 /* SetAccessor */) { // TODO (drosen): Reconcile with 'emitMemberFunctions'. var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { @@ -27606,13 +29506,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 227 /* PropertyAssignment */) { + if (property.kind === 242 /* PropertyAssignment */) { emit(property.initializer); } - else if (property.kind === 228 /* ShorthandPropertyAssignment */) { + else if (property.kind === 243 /* ShorthandPropertyAssignment */) { emitExpressionIdentifier(property.name); } - else if (property.kind === 136 /* MethodDeclaration */) { + else if (property.kind === 140 /* MethodDeclaration */) { emitFunctionDeclaration(property); } else { @@ -27646,7 +29546,7 @@ var ts; // Everything until that point can be emitted as part of the initial object literal. var numInitialNonComputedProperties = numProperties; for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 129 /* ComputedPropertyName */) { + if (properties[i].name.kind === 133 /* ComputedPropertyName */) { numInitialNonComputedProperties = i; break; } @@ -27662,21 +29562,21 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(172 /* BinaryExpression */, startsOnNewLine); + var result = ts.createSynthesizedNode(178 /* BinaryExpression */, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(158 /* PropertyAccessExpression */); + var result = ts.createSynthesizedNode(163 /* PropertyAccessExpression */); result.expression = parenthesizeForAccess(expression); result.dotToken = ts.createSynthesizedNode(20 /* DotToken */); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(159 /* ElementAccessExpression */); + var result = ts.createSynthesizedNode(164 /* ElementAccessExpression */); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; @@ -27684,7 +29584,7 @@ var ts; function parenthesizeForAccess(expr) { // When diagnosing whether the expression needs parentheses, the decision should be based // on the innermost expression in a chain of nested type assertions. - while (expr.kind === 163 /* TypeAssertionExpression */) { + while (expr.kind === 168 /* TypeAssertionExpression */ || expr.kind === 186 /* AsExpression */) { expr = expr.expression; } // isLeftHandSideExpression is almost the correct criterion for when it is not necessary @@ -27696,11 +29596,11 @@ var ts; // 1.x -> not the same as (1).x // if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 161 /* NewExpression */ && + expr.kind !== 166 /* NewExpression */ && expr.kind !== 7 /* NumericLiteral */) { return expr; } - var node = ts.createSynthesizedNode(164 /* ParenthesizedExpression */); + var node = ts.createSynthesizedNode(169 /* ParenthesizedExpression */); node.expression = expr; return node; } @@ -27727,7 +29627,7 @@ var ts; // Return true if identifier resolves to an exported member of a namespace function isNamespaceExportReference(node) { var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 230 /* SourceFile */; + return container && container.kind !== 245 /* SourceFile */; } function emitShorthandPropertyAssignment(node) { // The name property of a short-hand property assignment is considered an expression position, so here @@ -27757,15 +29657,15 @@ var ts; if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 158 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 163 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; } return false; } - // Returns 'true' if the code was actually indented, false otherwise. - // If the code is not indented, an optional valueToWriteWhenNotIndenting will be + // Returns 'true' if the code was actually indented, false otherwise. + // If the code is not indented, an optional valueToWriteWhenNotIndenting will be // emitted instead. function indentIfOnDifferentLines(parent, node1, node2, valueToWriteWhenNotIndenting) { var realNodesAreOnDifferentLines = !ts.nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2); @@ -27789,7 +29689,18 @@ var ts; } emit(node.expression); var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); - write("."); + // 1 .toString is a valid property access, emit a space after the literal + var shouldEmitSpace; + if (!indentedBeforeDot && node.expression.kind === 7 /* NumericLiteral */) { + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); + shouldEmitSpace = text.indexOf(ts.tokenToString(20 /* DotToken */)) < 0; + } + if (shouldEmitSpace) { + write(" ."); + } + else { + write("."); + } var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); emit(node.name); decreaseIndentIf(indentedBeforeDot, indentedAfterDot); @@ -27799,6 +29710,40 @@ var ts; write("."); emit(node.right); } + function emitQualifiedNameAsExpression(node, useFallback) { + if (node.left.kind === 66 /* Identifier */) { + emitEntityNameAsExpression(node.left, useFallback); + } + else if (useFallback) { + var temp = createAndRecordTempVariable(0 /* Auto */); + write("("); + emitNodeWithoutSourceMap(temp); + write(" = "); + emitEntityNameAsExpression(node.left, true); + write(") && "); + emitNodeWithoutSourceMap(temp); + } + else { + emitEntityNameAsExpression(node.left, false); + } + write("."); + emitNodeWithoutSourceMap(node.right); + } + function emitEntityNameAsExpression(node, useFallback) { + switch (node.kind) { + case 66 /* Identifier */: + if (useFallback) { + write("typeof "); + emitExpressionIdentifier(node); + write(" !== 'undefined' && "); + } + emitExpressionIdentifier(node); + break; + case 132 /* QualifiedName */: + emitQualifiedNameAsExpression(node, useFallback); + break; + } + } function emitIndexedAccess(node) { if (tryEmitConstantValue(node)) { return; @@ -27809,16 +29754,16 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 176 /* SpreadElementExpression */; }); + return ts.forEach(elements, function (e) { return e.kind === 182 /* SpreadElementExpression */; }); } function skipParentheses(node) { - while (node.kind === 164 /* ParenthesizedExpression */ || node.kind === 163 /* TypeAssertionExpression */) { + while (node.kind === 169 /* ParenthesizedExpression */ || node.kind === 168 /* TypeAssertionExpression */ || node.kind === 186 /* AsExpression */) { node = node.expression; } return node; } function emitCallTarget(node) { - if (node.kind === 65 /* Identifier */ || node.kind === 93 /* ThisKeyword */ || node.kind === 91 /* SuperKeyword */) { + if (node.kind === 66 /* Identifier */ || node.kind === 94 /* ThisKeyword */ || node.kind === 92 /* SuperKeyword */) { emit(node); return node; } @@ -27833,20 +29778,20 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 158 /* PropertyAccessExpression */) { + if (expr.kind === 163 /* PropertyAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 159 /* ElementAccessExpression */) { + else if (expr.kind === 164 /* ElementAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); write("]"); } - else if (expr.kind === 91 /* SuperKeyword */) { + else if (expr.kind === 92 /* SuperKeyword */) { target = expr; write("_super"); } @@ -27855,7 +29800,7 @@ var ts; } write(".apply("); if (target) { - if (target.kind === 91 /* SuperKeyword */) { + if (target.kind === 92 /* SuperKeyword */) { // Calls of form super(...) and super.foo(...) emitThis(target); } @@ -27878,13 +29823,13 @@ var ts; return; } var superCall = false; - if (node.expression.kind === 91 /* SuperKeyword */) { + if (node.expression.kind === 92 /* SuperKeyword */) { emitSuper(node.expression); superCall = true; } else { emit(node.expression); - superCall = node.expression.kind === 158 /* PropertyAccessExpression */ && node.expression.expression.kind === 91 /* SuperKeyword */; + superCall = node.expression.kind === 163 /* PropertyAccessExpression */ && node.expression.expression.kind === 92 /* SuperKeyword */; } if (superCall && languageVersion < 2 /* ES6 */) { write(".call("); @@ -27953,12 +29898,12 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 166 /* ArrowFunction */) { - if (node.expression.kind === 163 /* TypeAssertionExpression */) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 171 /* ArrowFunction */) { + if (node.expression.kind === 168 /* TypeAssertionExpression */ || node.expression.kind === 186 /* AsExpression */) { var operand = node.expression.expression; // Make sure we consider all nested cast expressions, e.g.: // (-A).x; - while (operand.kind === 163 /* TypeAssertionExpression */) { + while (operand.kind === 168 /* TypeAssertionExpression */ || operand.kind === 186 /* AsExpression */) { operand = operand.expression; } // We have an expression of the form: (SubExpr) @@ -27969,14 +29914,14 @@ var ts; // (typeof A).toString() should be emitted as (typeof A).toString() and not typeof A.toString() // new (A()) should be emitted as new (A()) and not new A() // (function foo() { })() should be emitted as an IIF (function foo(){})() and not declaration function foo(){} () - if (operand.kind !== 170 /* PrefixUnaryExpression */ && - operand.kind !== 169 /* VoidExpression */ && - operand.kind !== 168 /* TypeOfExpression */ && - operand.kind !== 167 /* DeleteExpression */ && - operand.kind !== 171 /* PostfixUnaryExpression */ && - operand.kind !== 161 /* NewExpression */ && - !(operand.kind === 160 /* CallExpression */ && node.parent.kind === 161 /* NewExpression */) && - !(operand.kind === 165 /* FunctionExpression */ && node.parent.kind === 160 /* CallExpression */)) { + if (operand.kind !== 176 /* PrefixUnaryExpression */ && + operand.kind !== 174 /* VoidExpression */ && + operand.kind !== 173 /* TypeOfExpression */ && + operand.kind !== 172 /* DeleteExpression */ && + operand.kind !== 177 /* PostfixUnaryExpression */ && + operand.kind !== 166 /* NewExpression */ && + !(operand.kind === 165 /* CallExpression */ && node.parent.kind === 166 /* NewExpression */) && + !(operand.kind === 170 /* FunctionExpression */ && node.parent.kind === 165 /* CallExpression */)) { emit(operand); return; } @@ -27987,25 +29932,25 @@ var ts; write(")"); } function emitDeleteExpression(node) { - write(ts.tokenToString(74 /* DeleteKeyword */)); + write(ts.tokenToString(75 /* DeleteKeyword */)); write(" "); emit(node.expression); } function emitVoidExpression(node) { - write(ts.tokenToString(99 /* VoidKeyword */)); + write(ts.tokenToString(100 /* VoidKeyword */)); write(" "); emit(node.expression); } function emitTypeOfExpression(node) { - write(ts.tokenToString(97 /* TypeOfKeyword */)); + write(ts.tokenToString(98 /* TypeOfKeyword */)); write(" "); emit(node.expression); } function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { - if (!isCurrentFileSystemExternalModule() || node.kind !== 65 /* Identifier */ || ts.nodeIsSynthesized(node)) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 66 /* Identifier */ || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 201 /* VariableDeclaration */ || node.parent.kind === 155 /* BindingElement */); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 208 /* VariableDeclaration */ || node.parent.kind === 160 /* BindingElement */); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); @@ -28035,12 +29980,12 @@ var ts; // the resulting expression a prefix increment operation. And in the second, it will make the resulting // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. - if (node.operand.kind === 170 /* PrefixUnaryExpression */) { + if (node.operand.kind === 176 /* PrefixUnaryExpression */) { var operand = node.operand; - if (node.operator === 33 /* PlusToken */ && (operand.operator === 33 /* PlusToken */ || operand.operator === 38 /* PlusPlusToken */)) { + if (node.operator === 34 /* PlusToken */ && (operand.operator === 34 /* PlusToken */ || operand.operator === 39 /* PlusPlusToken */)) { write(" "); } - else if (node.operator === 34 /* MinusToken */ && (operand.operator === 34 /* MinusToken */ || operand.operator === 39 /* MinusMinusToken */)) { + else if (node.operator === 35 /* MinusToken */ && (operand.operator === 35 /* MinusToken */ || operand.operator === 40 /* MinusMinusToken */)) { write(" "); } } @@ -28060,7 +30005,7 @@ var ts; write("\", "); write(ts.tokenToString(node.operator)); emit(node.operand); - if (node.operator === 38 /* PlusPlusToken */) { + if (node.operator === 39 /* PlusPlusToken */) { write(") - 1)"); } else { @@ -28091,10 +30036,10 @@ var ts; } var current = node; while (current) { - if (current.kind === 230 /* SourceFile */) { + if (current.kind === 245 /* SourceFile */) { return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 209 /* ModuleBlock */) { + else if (ts.isFunctionLike(current) || current.kind === 216 /* ModuleBlock */) { return false; } else { @@ -28103,13 +30048,13 @@ var ts; } } function emitBinaryExpression(node) { - if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 53 /* EqualsToken */ && - (node.left.kind === 157 /* ObjectLiteralExpression */ || node.left.kind === 156 /* ArrayLiteralExpression */)) { - emitDestructuring(node, node.parent.kind === 185 /* ExpressionStatement */); + if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 54 /* EqualsToken */ && + (node.left.kind === 162 /* ObjectLiteralExpression */ || node.left.kind === 161 /* ArrayLiteralExpression */)) { + emitDestructuring(node, node.parent.kind === 192 /* ExpressionStatement */); } else { - var exportChanged = node.operatorToken.kind >= 53 /* FirstAssignment */ && - node.operatorToken.kind <= 64 /* LastAssignment */ && + var exportChanged = node.operatorToken.kind >= 54 /* FirstAssignment */ && + node.operatorToken.kind <= 65 /* LastAssignment */ && isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); if (exportChanged) { // emit assignment 'x y' as 'exports("x", x y)' @@ -28144,7 +30089,7 @@ var ts; emit(node.whenFalse); decreaseIndentIf(indentedBeforeColon, indentedAfterColon); } - // Helper function to decrease the indent if we previously indented. Allows multiple + // Helper function to decrease the indent if we previously indented. Allows multiple // previous indent values to be considered at a time. This also allows caller to just // call this once, passing in all their appropriate indent values, instead of needing // to call this helper function multiple times. @@ -28157,7 +30102,7 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 182 /* Block */) { + if (node && node.kind === 189 /* Block */) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } @@ -28172,12 +30117,12 @@ var ts; emitToken(14 /* OpenBraceToken */, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 209 /* ModuleBlock */) { - ts.Debug.assert(node.parent.kind === 208 /* ModuleDeclaration */); + if (node.kind === 216 /* ModuleBlock */) { + ts.Debug.assert(node.parent.kind === 215 /* ModuleDeclaration */); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 209 /* ModuleBlock */) { + if (node.kind === 216 /* ModuleBlock */) { emitTempDeclarations(true); } decreaseIndent(); @@ -28186,7 +30131,7 @@ var ts; scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 182 /* Block */) { + if (node.kind === 189 /* Block */) { write(" "); emit(node); } @@ -28198,11 +30143,11 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 166 /* ArrowFunction */); + emitParenthesizedIf(node.expression, node.expression.kind === 171 /* ArrowFunction */); write(";"); } function emitIfStatement(node) { - var endPos = emitToken(84 /* IfKeyword */, node.pos); + var endPos = emitToken(85 /* IfKeyword */, node.pos); write(" "); endPos = emitToken(16 /* OpenParenToken */, endPos); emit(node.expression); @@ -28210,8 +30155,8 @@ var ts; emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - emitToken(76 /* ElseKeyword */, node.thenStatement.end); - if (node.elseStatement.kind === 186 /* IfStatement */) { + emitToken(77 /* ElseKeyword */, node.thenStatement.end); + if (node.elseStatement.kind === 193 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -28223,7 +30168,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 182 /* Block */) { + if (node.statement.kind === 189 /* Block */) { write(" "); } else { @@ -28249,13 +30194,13 @@ var ts; // variables in variable declaration list were already hoisted return false; } - var tokenKind = 98 /* VarKeyword */; + var tokenKind = 99 /* VarKeyword */; if (decl && languageVersion >= 2 /* ES6 */) { if (ts.isLet(decl)) { - tokenKind = 104 /* LetKeyword */; + tokenKind = 105 /* LetKeyword */; } else if (ts.isConst(decl)) { - tokenKind = 70 /* ConstKeyword */; + tokenKind = 71 /* ConstKeyword */; } } if (startPos !== undefined) { @@ -28264,13 +30209,13 @@ var ts; } else { switch (tokenKind) { - case 98 /* VarKeyword */: + case 99 /* VarKeyword */: write("var "); break; - case 104 /* LetKeyword */: + case 105 /* LetKeyword */: write("let "); break; - case 70 /* ConstKeyword */: + case 71 /* ConstKeyword */: write("const "); break; } @@ -28295,10 +30240,10 @@ var ts; return started; } function emitForStatement(node) { - var endPos = emitToken(82 /* ForKeyword */, node.pos); + var endPos = emitToken(83 /* ForKeyword */, node.pos); write(" "); endPos = emitToken(16 /* OpenParenToken */, endPos); - if (node.initializer && node.initializer.kind === 202 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 209 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); if (startIsEmitted) { @@ -28319,13 +30264,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 /* ES6 */ && node.kind === 191 /* ForOfStatement */) { + if (languageVersion < 2 /* ES6 */ && node.kind === 198 /* ForOfStatement */) { return emitDownLevelForOfStatement(node); } - var endPos = emitToken(82 /* ForKeyword */, node.pos); + var endPos = emitToken(83 /* ForKeyword */, node.pos); write(" "); endPos = emitToken(16 /* OpenParenToken */, endPos); - if (node.initializer.kind === 202 /* VariableDeclarationList */) { + if (node.initializer.kind === 209 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); @@ -28335,7 +30280,7 @@ var ts; else { emit(node.initializer); } - if (node.kind === 190 /* ForInStatement */) { + if (node.kind === 197 /* ForInStatement */) { write(" in "); } else { @@ -28366,7 +30311,7 @@ var ts; // 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(82 /* ForKeyword */, node.pos); + var endPos = emitToken(83 /* ForKeyword */, node.pos); write(" "); endPos = emitToken(16 /* OpenParenToken */, endPos); // Do not emit the LHS let declaration yet, because it might contain destructuring. @@ -28377,7 +30322,7 @@ var ts; // for (let v of arr) { } // // we don't want to emit a temporary variable for the RHS, just use it directly. - var rhsIsIdentifier = node.expression.kind === 65 /* Identifier */; + var rhsIsIdentifier = node.expression.kind === 66 /* Identifier */; var counter = createTempVariable(268435456 /* _i */); var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0 /* Auto */); // This is the let keyword for the counter and rhsReference. The let keyword for @@ -28420,7 +30365,7 @@ var ts; // let v = _a[_i]; var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 202 /* VariableDeclarationList */) { + if (node.initializer.kind === 209 /* VariableDeclarationList */) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -28449,8 +30394,8 @@ var ts; else { // Initializer is an expression. Emit the expression in the body, so that it's // evaluated on every iteration. - var assignmentExpression = createBinaryExpression(node.initializer, 53 /* EqualsToken */, rhsIterationValue, false); - if (node.initializer.kind === 156 /* ArrayLiteralExpression */ || node.initializer.kind === 157 /* ObjectLiteralExpression */) { + var assignmentExpression = createBinaryExpression(node.initializer, 54 /* EqualsToken */, rhsIterationValue, false); + if (node.initializer.kind === 161 /* ArrayLiteralExpression */ || node.initializer.kind === 162 /* ObjectLiteralExpression */) { // This is a destructuring pattern, so call emitDestructuring instead of emit. Calling emit will not work, because it will cause // the BinaryExpression to be passed in instead of the expression statement, which will cause emitDestructuring to crash. emitDestructuring(assignmentExpression, true, undefined); @@ -28461,7 +30406,7 @@ var ts; } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 182 /* Block */) { + if (node.statement.kind === 189 /* Block */) { emitLines(node.statement.statements); } else { @@ -28473,12 +30418,12 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 193 /* BreakStatement */ ? 66 /* BreakKeyword */ : 71 /* ContinueKeyword */, node.pos); + emitToken(node.kind === 200 /* BreakStatement */ ? 67 /* BreakKeyword */ : 72 /* ContinueKeyword */, node.pos); emitOptional(" ", node.label); write(";"); } function emitReturnStatement(node) { - emitToken(90 /* ReturnKeyword */, node.pos); + emitToken(91 /* ReturnKeyword */, node.pos); emitOptional(" ", node.expression); write(";"); } @@ -28489,7 +30434,7 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var endPos = emitToken(92 /* SwitchKeyword */, node.pos); + var endPos = emitToken(93 /* SwitchKeyword */, node.pos); write(" "); emitToken(16 /* OpenParenToken */, endPos); emit(node.expression); @@ -28518,7 +30463,7 @@ var ts; ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 223 /* CaseClause */) { + if (node.kind === 238 /* CaseClause */) { write("case "); emit(node.expression); write(":"); @@ -28553,7 +30498,7 @@ var ts; } function emitCatchClause(node) { writeLine(); - var endPos = emitToken(68 /* CatchKeyword */, node.pos); + var endPos = emitToken(69 /* CatchKeyword */, node.pos); write(" "); emitToken(16 /* OpenParenToken */, endPos); emit(node.variableDeclaration); @@ -28562,7 +30507,7 @@ var ts; emitBlock(node.block); } function emitDebuggerStatement(node) { - emitToken(72 /* DebuggerKeyword */, node.pos); + emitToken(73 /* DebuggerKeyword */, node.pos); write(";"); } function emitLabelledStatement(node) { @@ -28573,7 +30518,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 208 /* ModuleDeclaration */); + } while (node && node.kind !== 215 /* ModuleDeclaration */); return node; } function emitContainingModuleName(node) { @@ -28598,7 +30543,7 @@ var ts; function createVoidZero() { var zero = ts.createSynthesizedNode(7 /* NumericLiteral */); zero.text = "0"; - var result = ts.createSynthesizedNode(169 /* VoidExpression */); + var result = ts.createSynthesizedNode(174 /* VoidExpression */); result.expression = zero; return result; } @@ -28611,7 +30556,7 @@ var ts; // emit export default as // export("default", ) write(exportFunctionForFile + "(\""); - if (node.flags & 256 /* Default */) { + if (node.flags & 1024 /* Default */) { write("default"); } else { @@ -28622,7 +30567,7 @@ var ts; write(")"); } else { - if (node.flags & 256 /* Default */) { + if (node.flags & 1024 /* Default */) { if (languageVersion === 0 /* ES3 */) { write("exports[\"default\"]"); } @@ -28674,15 +30619,15 @@ var ts; // Also temporary variables should be explicitly allocated for source level declarations when module target is system // because actual variable declarations are hoisted var canDefineTempVariablesInPlace = false; - if (root.kind === 201 /* VariableDeclaration */) { + if (root.kind === 208 /* VariableDeclaration */) { var isExported = ts.getCombinedNodeFlags(root) & 1 /* Export */; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 131 /* Parameter */) { + else if (root.kind === 135 /* Parameter */) { canDefineTempVariablesInPlace = true; } - if (root.kind === 172 /* BinaryExpression */) { + if (root.kind === 178 /* BinaryExpression */) { emitAssignmentExpression(root); } else { @@ -28693,7 +30638,7 @@ var ts; if (emitCount++) { write(", "); } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 201 /* VariableDeclaration */ || name.parent.kind === 155 /* BindingElement */); + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 208 /* VariableDeclaration */ || name.parent.kind === 160 /* BindingElement */); var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); if (exportChanged) { write(exportFunctionForFile + "(\""); @@ -28713,7 +30658,7 @@ var ts; } } function ensureIdentifier(expr) { - if (expr.kind !== 65 /* Identifier */) { + if (expr.kind !== 66 /* Identifier */) { var identifier = createTempVariable(0 /* Auto */); if (!canDefineTempVariablesInPlace) { recordTempDeclaration(identifier); @@ -28728,18 +30673,18 @@ var ts; // we need to generate a temporary variable value = ensureIdentifier(value); // Return the expression 'value === void 0 ? defaultValue : value' - var equals = ts.createSynthesizedNode(172 /* BinaryExpression */); + var equals = ts.createSynthesizedNode(178 /* BinaryExpression */); equals.left = value; - equals.operatorToken = ts.createSynthesizedNode(30 /* EqualsEqualsEqualsToken */); + equals.operatorToken = ts.createSynthesizedNode(31 /* EqualsEqualsEqualsToken */); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(173 /* ConditionalExpression */); + var cond = ts.createSynthesizedNode(179 /* ConditionalExpression */); cond.condition = condition; - cond.questionToken = ts.createSynthesizedNode(50 /* QuestionToken */); + cond.questionToken = ts.createSynthesizedNode(51 /* QuestionToken */); cond.whenTrue = whenTrue; - cond.colonToken = ts.createSynthesizedNode(51 /* ColonToken */); + cond.colonToken = ts.createSynthesizedNode(52 /* ColonToken */); cond.whenFalse = whenFalse; return cond; } @@ -28753,14 +30698,14 @@ var ts; // otherwise occur when the identifier is emitted. var syntheticName = ts.createSynthesizedNode(propName.kind); syntheticName.text = propName.text; - if (syntheticName.kind !== 65 /* Identifier */) { + if (syntheticName.kind !== 66 /* Identifier */) { return createElementAccessExpression(object, syntheticName); } return createPropertyAccessExpression(object, syntheticName); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(160 /* CallExpression */); - var sliceIdentifier = ts.createSynthesizedNode(65 /* Identifier */); + var call = ts.createSynthesizedNode(165 /* CallExpression */); + var sliceIdentifier = ts.createSynthesizedNode(66 /* Identifier */); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); call.arguments = ts.createSynthesizedNodeArray(); @@ -28776,7 +30721,7 @@ var ts; } for (var _a = 0; _a < properties.length; _a++) { var p = properties[_a]; - if (p.kind === 227 /* PropertyAssignment */ || p.kind === 228 /* ShorthandPropertyAssignment */) { + if (p.kind === 242 /* PropertyAssignment */ || p.kind === 243 /* ShorthandPropertyAssignment */) { var propName = p.name; emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); } @@ -28791,8 +30736,8 @@ var ts; } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 178 /* OmittedExpression */) { - if (e.kind !== 176 /* SpreadElementExpression */) { + if (e.kind !== 184 /* OmittedExpression */) { + if (e.kind !== 182 /* SpreadElementExpression */) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); } else if (i === elements.length - 1) { @@ -28802,14 +30747,14 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 172 /* BinaryExpression */ && target.operatorToken.kind === 53 /* EqualsToken */) { + if (target.kind === 178 /* BinaryExpression */ && target.operatorToken.kind === 54 /* EqualsToken */) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 157 /* ObjectLiteralExpression */) { + if (target.kind === 162 /* ObjectLiteralExpression */) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 156 /* ArrayLiteralExpression */) { + else if (target.kind === 161 /* ArrayLiteralExpression */) { emitArrayLiteralAssignment(target, value); } else { @@ -28823,14 +30768,14 @@ var ts; emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 164 /* ParenthesizedExpression */) { + if (root.parent.kind !== 169 /* ParenthesizedExpression */) { write("("); } value = ensureIdentifier(value); emitDestructuringAssignment(target, value); write(", "); emit(value); - if (root.parent.kind !== 164 /* ParenthesizedExpression */) { + if (root.parent.kind !== 169 /* ParenthesizedExpression */) { write(")"); } } @@ -28854,12 +30799,12 @@ var ts; } for (var i = 0; i < elements.length; i++) { var element = elements[i]; - if (pattern.kind === 153 /* ObjectBindingPattern */) { + if (pattern.kind === 158 /* ObjectBindingPattern */) { // Rewrite element to a declaration with an initializer that fetches property var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } - else if (element.kind !== 178 /* OmittedExpression */) { + else if (element.kind !== 184 /* OmittedExpression */) { if (!element.dotDotDotToken) { // Rewrite element to a declaration that accesses array element at index i emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); @@ -28894,12 +30839,12 @@ var ts; // for (...) { var = void 0; } // this is necessary to preserve ES6 semantic in scenarios like // for (...) { let x; console.log(x); x = 1 } // assignment on one iteration should not affect other iterations - var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 256 /* BlockScopedBindingInLoop */) && - (getCombinedFlagsForIdentifier(node.name) & 4096 /* Let */); + var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 16384 /* BlockScopedBindingInLoop */) && + (getCombinedFlagsForIdentifier(node.name) & 16384 /* Let */); // NOTE: default initialization should not be added to let bindings in for-in\for-of statements if (isUninitializedLet && - node.parent.parent.kind !== 190 /* ForInStatement */ && - node.parent.parent.kind !== 191 /* ForOfStatement */) { + node.parent.parent.kind !== 197 /* ForInStatement */ && + node.parent.parent.kind !== 198 /* ForOfStatement */) { initializer = createVoidZero(); } } @@ -28917,11 +30862,11 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 178 /* OmittedExpression */) { + if (node.kind === 184 /* OmittedExpression */) { return; } var name = node.name; - if (name.kind === 65 /* Identifier */) { + if (name.kind === 66 /* Identifier */) { emitExportMemberAssignments(name); } else if (ts.isBindingPattern(name)) { @@ -28929,7 +30874,7 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 201 /* VariableDeclaration */ && node.parent.kind !== 155 /* BindingElement */)) { + if (!node.parent || (node.parent.kind !== 208 /* VariableDeclaration */ && node.parent.kind !== 160 /* BindingElement */)) { return 0; } return ts.getCombinedNodeFlags(node.parent); @@ -28937,7 +30882,7 @@ var ts; function isES6ExportedDeclaration(node) { return !!(node.flags & 1 /* Export */) && languageVersion >= 2 /* ES6 */ && - node.parent.kind === 230 /* SourceFile */; + node.parent.kind === 245 /* SourceFile */; } function emitVariableStatement(node) { var startIsEmitted = false; @@ -28988,12 +30933,12 @@ var ts; function emitParameter(node) { if (languageVersion < 2 /* ES6 */) { if (ts.isBindingPattern(node.name)) { - var name_20 = createTempVariable(0 /* Auto */); + var name_23 = createTempVariable(0 /* Auto */); if (!tempParameters) { tempParameters = []; } - tempParameters.push(name_20); - emit(name_20); + tempParameters.push(name_23); + emit(name_23); } else { emit(node.name); @@ -29010,32 +30955,46 @@ var ts; function emitDefaultValueAssignments(node) { if (languageVersion < 2 /* ES6 */) { var tempIndex = 0; - ts.forEach(node.parameters, function (p) { + ts.forEach(node.parameters, function (parameter) { // A rest parameter cannot have a binding pattern or an initializer, // so let's just ignore it. - if (p.dotDotDotToken) { + if (parameter.dotDotDotToken) { return; } - if (ts.isBindingPattern(p.name)) { - writeLine(); - write("var "); - emitDestructuring(p, false, tempParameters[tempIndex]); - write(";"); - tempIndex++; + var paramName = parameter.name, initializer = parameter.initializer; + if (ts.isBindingPattern(paramName)) { + // In cases where a binding pattern is simply '[]' or '{}', + // we usually don't want to emit a var declaration; however, in the presence + // of an initializer, we must emit that expression to preserve side effects. + 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 (p.initializer) { + else if (initializer) { writeLine(); - emitStart(p); + emitStart(parameter); write("if ("); - emitNodeWithoutSourceMap(p.name); + emitNodeWithoutSourceMap(paramName); write(" === void 0)"); - emitEnd(p); + emitEnd(parameter); write(" { "); - emitStart(p); - emitNodeWithoutSourceMap(p.name); + emitStart(parameter); + emitNodeWithoutSourceMap(paramName); write(" = "); - emitNodeWithoutSourceMap(p.initializer); - emitEnd(p); + emitNodeWithoutSourceMap(initializer); + emitEnd(parameter); write("; }"); } }); @@ -29084,12 +31043,12 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 138 /* GetAccessor */ ? "get " : "set "); + write(node.kind === 142 /* GetAccessor */ ? "get " : "set "); emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 166 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; + return node.kind === 171 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; } function emitDeclarationName(node) { if (node.name) { @@ -29100,11 +31059,11 @@ var ts; } } function shouldEmitFunctionName(node) { - if (node.kind === 165 /* FunctionExpression */) { + if (node.kind === 170 /* FunctionExpression */) { // Emit name if one is present return !!node.name; } - if (node.kind === 203 /* FunctionDeclaration */) { + if (node.kind === 210 /* FunctionDeclaration */) { // Emit name if one is present, or emit generated name in down-level case (for export default case) return !!node.name || languageVersion < 2 /* ES6 */; } @@ -29113,7 +31072,7 @@ var ts; if (ts.nodeIsMissing(node.body)) { return emitOnlyPinnedOrTripleSlashComments(node); } - if (node.kind !== 136 /* MethodDeclaration */ && node.kind !== 135 /* MethodSignature */) { + if (node.kind !== 140 /* MethodDeclaration */ && node.kind !== 139 /* MethodSignature */) { // Methods will emit the comments as part of emitting method declaration emitLeadingComments(node); } @@ -29122,7 +31081,7 @@ var ts; if (!shouldEmitAsArrowFunction(node)) { if (isES6ExportedDeclaration(node)) { write("export "); - if (node.flags & 256 /* Default */) { + if (node.flags & 1024 /* Default */) { write("default "); } } @@ -29136,10 +31095,10 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 /* ES6 */ && node.kind === 203 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { + if (languageVersion < 2 /* ES6 */ && node.kind === 210 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - if (node.kind !== 136 /* MethodDeclaration */ && node.kind !== 135 /* MethodSignature */) { + if (node.kind !== 140 /* MethodDeclaration */ && node.kind !== 139 /* MethodSignature */) { emitTrailingComments(node); } } @@ -29170,6 +31129,137 @@ var ts; } emitSignatureParameters(node); } + function emitAsyncFunctionBodyForES6(node) { + var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); + var isArrowFunction = node.kind === 171 /* ArrowFunction */; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096 /* CaptureArguments */) !== 0; + var args; + // An async function is emit as an outer function that calls an inner + // generator function. To preserve lexical bindings, we pass the current + // `this` and `arguments` objects to `__awaiter`. The generator function + // passed to `__awaiter` is executed inside of the callback to the + // promise constructor. + // + // The emit for an async arrow without a lexical `arguments` binding might be: + // + // // input + // let a = async (b) => { await b; } + // + // // output + // let a = (b) => __awaiter(this, void 0, void 0, function* () { + // yield b; + // }); + // + // The emit for an async arrow with a lexical `arguments` binding might be: + // + // // input + // let a = async (b) => { await arguments[0]; } + // + // // output + // let a = (b) => __awaiter(this, arguments, void 0, function* (arguments) { + // yield arguments[0]; + // }); + // + // The emit for an async function expression without a lexical `arguments` binding + // might be: + // + // // input + // let a = async function (b) { + // await b; + // } + // + // // output + // let a = function (b) { + // return __awaiter(this, void 0, void 0, function* () { + // yield b; + // }); + // } + // + // The emit for an async function expression with a lexical `arguments` binding + // might be: + // + // // input + // let a = async function (b) { + // await arguments[0]; + // } + // + // // output + // let a = function (b) { + // return __awaiter(this, arguments, void 0, function* (_arguments) { + // yield _arguments[0]; + // }); + // } + // + // The emit for an async function expression with a lexical `arguments` binding + // and a return type annotation might be: + // + // // input + // let a = async function (b): MyPromise { + // await arguments[0]; + // } + // + // // output + // let a = function (b) { + // return __awaiter(this, arguments, MyPromise, function* (_arguments) { + // yield _arguments[0]; + // }); + // } + // + // If this is not an async arrow, emit the opening brace of the function body + // and the start of the return statement. + 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"); + } + // Emit the call to __awaiter. + if (hasLexicalArguments) { + write(", function* (_arguments)"); + } + else { + write(", function* ()"); + } + // Emit the signature and body for the inner generator function. + emitFunctionBody(node); + write(")"); + // If this is not an async arrow, emit the closing brace of the outer function body. + if (!isArrowFunction) { + write(";"); + decreaseIndent(); + writeLine(); + write("}"); + } + } + function emitFunctionBody(node) { + if (!node.body) { + // There can be no body when there are parse errors. Just emit an empty block + // in that case. + write(" { }"); + } + else { + if (node.body.kind === 189 /* Block */) { + emitBlockFunctionBody(node, node.body); + } + else { + emitExpressionFunctionBody(node, node.body); + } + } + } function emitSignatureAndBody(node) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; @@ -29185,16 +31275,12 @@ var ts; else { emitSignatureParameters(node); } - if (!node.body) { - // There can be no body when there are parse errors. Just emit an empty block - // in that case. - write(" { }"); - } - else if (node.body.kind === 182 /* Block */) { - emitBlockFunctionBody(node, node.body); + var isAsync = ts.isAsyncFunctionLike(node); + if (isAsync && languageVersion === 2 /* ES6 */) { + emitAsyncFunctionBodyForES6(node); } else { - emitExpressionFunctionBody(node, node.body); + emitFunctionBody(node); } if (!isES6ExportedDeclaration(node)) { emitExportMemberAssignment(node); @@ -29210,21 +31296,21 @@ var ts; emitRestParameter(node); } function emitExpressionFunctionBody(node, body) { - if (languageVersion < 2 /* ES6 */) { + if (languageVersion < 2 /* ES6 */ || node.flags & 512 /* Async */) { emitDownLevelExpressionFunctionBody(node, body); return; } - // For es6 and higher we can emit the expression as is. However, in the case + // For es6 and higher we can emit the expression as is. However, in the case // where the expression might end up looking like a block when emitted, we'll // also wrap it in parentheses first. For example if you have: a => {} // then we need to generate: a => ({}) write(" "); // Unwrap all type assertions. var current = body; - while (current.kind === 163 /* TypeAssertionExpression */) { + while (current.kind === 168 /* TypeAssertionExpression */) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 157 /* ObjectLiteralExpression */); + emitParenthesizedIf(body, current.kind === 162 /* ObjectLiteralExpression */); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -29300,11 +31386,11 @@ var ts; function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 185 /* ExpressionStatement */) { + if (statement && statement.kind === 192 /* ExpressionStatement */) { var expr = statement.expression; - if (expr && expr.kind === 160 /* CallExpression */) { + if (expr && expr.kind === 165 /* CallExpression */) { var func = expr.expression; - if (func && func.kind === 91 /* SuperKeyword */) { + if (func && func.kind === 92 /* SuperKeyword */) { return statement; } } @@ -29334,7 +31420,7 @@ var ts; emitNodeWithoutSourceMap(memberName); write("]"); } - else if (memberName.kind === 129 /* ComputedPropertyName */) { + else if (memberName.kind === 133 /* ComputedPropertyName */) { emitComputedPropertyName(memberName); } else { @@ -29346,7 +31432,7 @@ var ts; var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 134 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { + if (member.kind === 138 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { properties.push(member); } } @@ -29386,11 +31472,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 181 /* SemicolonClassElement */) { + if (member.kind === 188 /* SemicolonClassElement */) { writeLine(); write(";"); } - else if (member.kind === 136 /* MethodDeclaration */ || node.kind === 135 /* MethodSignature */) { + else if (member.kind === 140 /* MethodDeclaration */ || node.kind === 139 /* MethodSignature */) { if (!member.body) { return emitOnlyPinnedOrTripleSlashComments(member); } @@ -29409,7 +31495,7 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 138 /* GetAccessor */ || member.kind === 139 /* SetAccessor */) { + else if (member.kind === 142 /* GetAccessor */ || member.kind === 143 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -29459,22 +31545,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 136 /* MethodDeclaration */ || node.kind === 135 /* MethodSignature */) && !member.body) { + if ((member.kind === 140 /* MethodDeclaration */ || node.kind === 139 /* MethodSignature */) && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - else if (member.kind === 136 /* MethodDeclaration */ || - member.kind === 138 /* GetAccessor */ || - member.kind === 139 /* SetAccessor */) { + else if (member.kind === 140 /* MethodDeclaration */ || + member.kind === 142 /* GetAccessor */ || + member.kind === 143 /* SetAccessor */) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 128 /* Static */) { write("static "); } - if (member.kind === 138 /* GetAccessor */) { + if (member.kind === 142 /* GetAccessor */) { write("get "); } - else if (member.kind === 139 /* SetAccessor */) { + else if (member.kind === 143 /* SetAccessor */) { write("set "); } if (member.asteriskToken) { @@ -29485,7 +31571,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 181 /* SemicolonClassElement */) { + else if (member.kind === 188 /* SemicolonClassElement */) { writeLine(); write(";"); } @@ -29510,11 +31596,11 @@ var ts; var hasInstancePropertyWithInitializer = false; // Emit the constructor overload pinned comments ts.forEach(node.members, function (member) { - if (member.kind === 137 /* Constructor */ && !member.body) { + if (member.kind === 141 /* Constructor */ && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } // Check if there is any non-static property assignment - if (member.kind === 134 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { + if (member.kind === 138 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -29622,7 +31708,7 @@ var ts; } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 204 /* ClassDeclaration */) { + if (node.kind === 211 /* ClassDeclaration */) { if (thisNodeIsDecorated) { // To preserve the correct runtime semantics when decorators are applied to the class, // the emit needs to follow one of the following rules: @@ -29676,7 +31762,7 @@ var ts; // _default = __decorate([dec], _default); // export default _default; // - if (isES6ExportedDeclaration(node) && !(node.flags & 256 /* Default */)) { + if (isES6ExportedDeclaration(node) && !(node.flags & 1024 /* Default */)) { write("export "); } write("let "); @@ -29685,15 +31771,15 @@ var ts; } else if (isES6ExportedDeclaration(node)) { write("export "); - if (node.flags & 256 /* Default */) { + if (node.flags & 1024 /* Default */) { write("default "); } } } // If the class has static properties, and it's a class expression, then we'll need - // to specialize the emit a bit. for a class expression of the form: + // to specialize the emit a bit. for a class expression of the form: // - // class C { static a = 1; static b = 2; ... } + // class C { static a = 1; static b = 2; ... } // // We'll emit: // @@ -29702,7 +31788,7 @@ var ts; // This keeps the expression as an expression, while ensuring that the static parts // of it have been initialized by the time it is used. var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 177 /* ClassExpression */; + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 183 /* ClassExpression */; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0 /* Auto */); @@ -29713,7 +31799,7 @@ var ts; } write("class"); // check if this is an "export default class" as it may not have a name. Do not emit the name if the class is decorated. - if ((node.name || !(node.flags & 256 /* Default */)) && !thisNodeIsDecorated) { + if ((node.name || !(node.flags & 1024 /* Default */)) && !thisNodeIsDecorated) { write(" "); emitDeclarationName(node); } @@ -29777,7 +31863,7 @@ var ts; emitEnd(node); write(";"); } - else if (isES6ExportedDeclaration(node) && (node.flags & 256 /* Default */) && thisNodeIsDecorated) { + else if (isES6ExportedDeclaration(node) && (node.flags & 1024 /* Default */) && thisNodeIsDecorated) { // if this is a top level default export of decorated class, write the export after the declaration. writeLine(); write("export default "); @@ -29786,7 +31872,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 204 /* ClassDeclaration */) { + if (node.kind === 211 /* ClassDeclaration */) { // source file level classes in system modules are hoisted so 'var's for them are already defined if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); @@ -29845,11 +31931,11 @@ var ts; emit(baseTypeNode.expression); } write(")"); - if (node.kind === 204 /* ClassDeclaration */) { + if (node.kind === 211 /* ClassDeclaration */) { write(";"); } emitEnd(node); - if (node.kind === 204 /* ClassDeclaration */) { + if (node.kind === 211 /* ClassDeclaration */) { emitExportMemberAssignment(node); } if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile && node.name) { @@ -29941,7 +32027,7 @@ var ts; else { decorators = member.decorators; // we only decorate the parameters here if this is a method - if (member.kind === 136 /* MethodDeclaration */) { + if (member.kind === 140 /* MethodDeclaration */) { functionLikeMember = member; } } @@ -29955,7 +32041,7 @@ var ts; // // The emit for a method is: // - // Object.defineProperty(C.prototype, "method", + // Object.defineProperty(C.prototype, "method", // __decorate([ // dec, // __param(0, dec2), @@ -29963,10 +32049,10 @@ var ts; // __metadata("design:paramtypes", [Object]), // __metadata("design:returntype", void 0) // ], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method"))); - // + // // The emit for an accessor is: // - // Object.defineProperty(C.prototype, "accessor", + // Object.defineProperty(C.prototype, "accessor", // __decorate([ // dec // ], C.prototype, "accessor", Object.getOwnPropertyDescriptor(C.prototype, "accessor"))); @@ -29979,7 +32065,7 @@ var ts; // writeLine(); emitStart(member); - if (member.kind !== 134 /* PropertyDeclaration */) { + if (member.kind !== 138 /* PropertyDeclaration */) { write("Object.defineProperty("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -30009,7 +32095,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); - if (member.kind !== 134 /* PropertyDeclaration */) { + if (member.kind !== 138 /* PropertyDeclaration */) { write(", Object.getOwnPropertyDescriptor("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -30048,112 +32134,259 @@ var ts; } function shouldEmitTypeMetadata(node) { // This method determines whether to emit the "design:type" metadata based on the node's kind. - // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata + // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 136 /* MethodDeclaration */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 134 /* PropertyDeclaration */: + case 140 /* MethodDeclaration */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 138 /* PropertyDeclaration */: return true; } return false; } function shouldEmitReturnTypeMetadata(node) { // This method determines whether to emit the "design:returntype" metadata based on the node's kind. - // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata + // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 136 /* MethodDeclaration */: + case 140 /* MethodDeclaration */: return true; } return false; } function shouldEmitParamTypesMetadata(node) { // This method determines whether to emit the "design:paramtypes" metadata based on the node's kind. - // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata + // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 204 /* ClassDeclaration */: - case 136 /* MethodDeclaration */: - case 139 /* SetAccessor */: + case 211 /* ClassDeclaration */: + case 140 /* MethodDeclaration */: + case 143 /* SetAccessor */: return true; } return false; } + /** Serializes the type of a declaration to an appropriate JS constructor value. Used by the __metadata decorator for a class member. */ + function emitSerializedTypeOfNode(node) { + // serialization of the type of a declaration uses the following rules: + // + // * The serialized type of a ClassDeclaration is "Function" + // * The serialized type of a ParameterDeclaration is the serialized type of its type annotation. + // * The serialized type of a PropertyDeclaration is the serialized type of its type annotation. + // * The serialized type of an AccessorDeclaration is the serialized type of the return type annotation of its getter or parameter type annotation of its setter. + // * The serialized type of any other FunctionLikeDeclaration is "Function". + // * The serialized type of any other node is "void 0". + // + // For rules on serializing type annotations, see `serializeTypeNode`. + switch (node.kind) { + case 211 /* ClassDeclaration */: + write("Function"); + return; + case 138 /* PropertyDeclaration */: + emitSerializedTypeNode(node.type); + return; + case 135 /* Parameter */: + emitSerializedTypeNode(node.type); + return; + case 142 /* GetAccessor */: + emitSerializedTypeNode(node.type); + return; + case 143 /* SetAccessor */: + emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); + return; + } + if (ts.isFunctionLike(node)) { + write("Function"); + return; + } + write("void 0"); + } + function emitSerializedTypeNode(node) { + switch (node.kind) { + case 100 /* VoidKeyword */: + write("void 0"); + return; + case 157 /* ParenthesizedType */: + emitSerializedTypeNode(node.type); + return; + case 149 /* FunctionType */: + case 150 /* ConstructorType */: + write("Function"); + return; + case 153 /* ArrayType */: + case 154 /* TupleType */: + write("Array"); + return; + case 147 /* TypePredicate */: + case 117 /* BooleanKeyword */: + write("Boolean"); + return; + case 127 /* StringKeyword */: + case 8 /* StringLiteral */: + write("String"); + return; + case 125 /* NumberKeyword */: + write("Number"); + return; + case 128 /* SymbolKeyword */: + write("Symbol"); + return; + case 148 /* TypeReference */: + emitSerializedTypeReferenceNode(node); + return; + case 151 /* TypeQuery */: + case 152 /* TypeLiteral */: + case 155 /* UnionType */: + case 156 /* IntersectionType */: + case 114 /* AnyKeyword */: + break; + default: + ts.Debug.fail("Cannot serialize unexpected type node."); + break; + } + write("Object"); + } + /** Serializes a TypeReferenceNode to an appropriate JS constructor value. Used by the __metadata decorator. */ + function emitSerializedTypeReferenceNode(node) { + var typeName = node.typeName; + var result = resolver.getTypeReferenceSerializationKind(node); + switch (result) { + case ts.TypeReferenceSerializationKind.Unknown: + var temp = createAndRecordTempVariable(0 /* Auto */); + 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 /* ES6 */) { + write("typeof Symbol === 'function' ? Symbol : Object"); + } + else { + write("Symbol"); + } + break; + case ts.TypeReferenceSerializationKind.TypeWithCallSignature: + write("Function"); + break; + case ts.TypeReferenceSerializationKind.ObjectType: + write("Object"); + break; + } + } + /** Serializes the parameter types of a function or the constructor of a class. Used by the __metadata decorator for a method or set accessor. */ + function emitSerializedParameterTypesOfNode(node) { + // serialization of parameter types uses the following rules: + // + // * If the declaration is a class, the parameters of the first constructor with a body are used. + // * If the declaration is function-like and has a body, the parameters of the function are used. + // + // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. + if (node) { + var valueDeclaration; + if (node.kind === 211 /* ClassDeclaration */) { + 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 === 153 /* ArrayType */) { + parameterType = parameterType.elementType; + } + else if (parameterType.kind === 148 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + parameterType = parameterType.typeArguments[0]; + } + else { + parameterType = undefined; + } + emitSerializedTypeNode(parameterType); + } + else { + emitSerializedTypeOfNode(parameters[i]); + } + } + } + } + } + } + /** Serializes the return type of function. Used by the __metadata decorator for a method. */ + function emitSerializedReturnTypeOfNode(node) { + if (node && ts.isFunctionLike(node)) { + emitSerializedTypeNode(node.type); + return; + } + write("void 0"); + } function emitSerializedTypeMetadata(node, writeComma) { // This method emits the serialized type metadata for a decorator target. // The caller should have already tested whether the node has decorators. var argumentsWritten = 0; if (compilerOptions.emitDecoratorMetadata) { if (shouldEmitTypeMetadata(node)) { - var serializedType = resolver.serializeTypeOfNode(node); - if (serializedType) { - if (writeComma) { - write(", "); - } - writeLine(); - write("__metadata('design:type', "); - emitSerializedType(node, serializedType); - write(")"); - argumentsWritten++; + if (writeComma) { + write(", "); } + writeLine(); + write("__metadata('design:type', "); + emitSerializedTypeOfNode(node); + write(")"); + argumentsWritten++; } if (shouldEmitParamTypesMetadata(node)) { - var serializedTypes = resolver.serializeParameterTypesOfNode(node); - if (serializedTypes) { - if (writeComma || argumentsWritten) { - write(", "); - } - writeLine(); - write("__metadata('design:paramtypes', ["); - for (var i = 0; i < serializedTypes.length; ++i) { - if (i > 0) { - write(", "); - } - emitSerializedType(node, serializedTypes[i]); - } - write("])"); - argumentsWritten++; + if (writeComma || argumentsWritten) { + write(", "); } + writeLine(); + write("__metadata('design:paramtypes', ["); + emitSerializedParameterTypesOfNode(node); + write("])"); + argumentsWritten++; } if (shouldEmitReturnTypeMetadata(node)) { - var serializedType = resolver.serializeReturnTypeOfNode(node); - if (serializedType) { - if (writeComma || argumentsWritten) { - write(", "); - } - writeLine(); - write("__metadata('design:returntype', "); - emitSerializedType(node, serializedType); - write(")"); - argumentsWritten++; + if (writeComma || argumentsWritten) { + write(", "); } + writeLine(); + write("__metadata('design:returntype', "); + emitSerializedReturnTypeOfNode(node); + write(")"); + argumentsWritten++; } } return argumentsWritten; } - function serializeTypeNameSegment(location, path, index) { - switch (index) { - case 0: - return "typeof " + path[index] + " !== 'undefined' && " + path[index]; - case 1: - return serializeTypeNameSegment(location, path, index - 1) + "." + path[index]; - default: - var temp = createAndRecordTempVariable(0 /* Auto */).text; - return "(" + temp + " = " + serializeTypeNameSegment(location, path, index - 1) + ") && " + temp + "." + path[index]; - } - } - function emitSerializedType(location, name) { - if (typeof name === "string") { - write(name); - return; - } - else { - ts.Debug.assert(name.length > 0, "Invalid serialized type name"); - write("(" + serializeTypeNameSegment(location, name, name.length - 1) + ") || Object"); - } - } function emitInterfaceDeclaration(node) { emitOnlyPinnedOrTripleSlashComments(node); } @@ -30252,7 +32485,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 208 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 215 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -30261,7 +32494,7 @@ var ts; return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); } function isModuleMergedWithES6Class(node) { - return languageVersion === 2 /* ES6 */ && !!(resolver.getNodeCheckFlags(node) & 2048 /* LexicalModuleMergesWithClass */); + return languageVersion === 2 /* ES6 */ && !!(resolver.getNodeCheckFlags(node) & 32768 /* LexicalModuleMergesWithClass */); } function emitModuleDeclaration(node) { // Emit only if this module is non-ambient. @@ -30288,7 +32521,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 209 /* ModuleBlock */) { + if (node.body.kind === 216 /* ModuleBlock */) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; tempFlags = 0; @@ -30321,7 +32554,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.name.kind === 65 /* Identifier */ && node.parent === currentSourceFile) { + if (!isES6ExportedDeclaration(node) && node.name.kind === 66 /* Identifier */ && node.parent === currentSourceFile) { if (compilerOptions.module === 4 /* System */ && (node.flags & 1 /* Export */)) { writeLine(); write(exportFunctionForFile + "(\""); @@ -30346,16 +32579,16 @@ var ts; } } function getNamespaceDeclarationNode(node) { - if (node.kind === 211 /* ImportEqualsDeclaration */) { + if (node.kind === 218 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 214 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 221 /* NamespaceImport */) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 212 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; + return node.kind === 219 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -30383,7 +32616,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 214 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 221 /* NamespaceImport */) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -30409,7 +32642,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 211 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; + var isExportedImport = node.kind === 218 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (compilerOptions.module !== 2 /* AMD */) { emitLeadingComments(node); @@ -30428,7 +32661,7 @@ var ts; // import { x, y } from "foo" // import d, * as x from "foo" // import d, { x, y } from "foo" - var isNakedImport = 212 /* ImportDeclaration */ && !node.importClause; + var isNakedImport = 219 /* ImportDeclaration */ && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -30592,8 +32825,8 @@ var ts; write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 203 /* FunctionDeclaration */ && - expression.kind !== 204 /* ClassDeclaration */) { + if (expression.kind !== 210 /* FunctionDeclaration */ && + expression.kind !== 211 /* ClassDeclaration */) { write(";"); } emitEnd(node); @@ -30629,7 +32862,7 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 212 /* ImportDeclaration */: + case 219 /* ImportDeclaration */: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, true)) { // import "mod" @@ -30639,13 +32872,13 @@ var ts; externalImports.push(node); } break; - case 211 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 222 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { + case 218 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 229 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { // import x = require("mod") where x is referenced externalImports.push(node); } break; - case 218 /* ExportDeclaration */: + case 225 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -30661,12 +32894,12 @@ var ts; // export { x, y } for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { var specifier = _d[_c]; - var name_21 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_21] || (exportSpecifiers[name_21] = [])).push(specifier); + var name_24 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_24] || (exportSpecifiers[name_24] = [])).push(specifier); } } break; - case 217 /* ExportAssignment */: + case 224 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; @@ -30692,10 +32925,10 @@ var ts; if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); } - if (node.kind === 212 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 219 /* ImportDeclaration */ && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 218 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 225 /* ExportDeclaration */ && node.moduleSpecifier) { return getGeneratedNameForNode(node); } } @@ -30715,8 +32948,8 @@ var ts; for (var _a = 0; _a < externalImports.length; _a++) { var importNode = externalImports[_a]; // do not create variable declaration for exports and imports that lack import clause - var skipNode = importNode.kind === 218 /* ExportDeclaration */ || - (importNode.kind === 212 /* ImportDeclaration */ && !importNode.importClause); + var skipNode = importNode.kind === 225 /* ExportDeclaration */ || + (importNode.kind === 219 /* ImportDeclaration */ && !importNode.importClause); if (skipNode) { continue; } @@ -30749,7 +32982,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0; _a < externalImports.length; _a++) { var externalImport = externalImports[_a]; - if (externalImport.kind === 218 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 225 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -30781,7 +33014,7 @@ var ts; } for (var _d = 0; _d < externalImports.length; _d++) { var externalImport = externalImports[_d]; - if (externalImport.kind !== 218 /* ExportDeclaration */) { + if (externalImport.kind !== 225 /* ExportDeclaration */) { continue; } var exportDecl = externalImport; @@ -30824,8 +33057,8 @@ var ts; } function writeExportedName(node) { // do not record default exports - // they are local to module and never overwritten (explicitly skipped) by star export - if (node.kind !== 65 /* Identifier */ && node.flags & 256 /* Default */) { + // they are local to module and never overwritten (explicitly skipped) by star export + if (node.kind !== 66 /* Identifier */ && node.flags & 1024 /* Default */) { return; } if (started) { @@ -30836,7 +33069,7 @@ var ts; } writeLine(); write("'"); - if (node.kind === 65 /* Identifier */) { + if (node.kind === 66 /* Identifier */) { emitNodeWithoutSourceMap(node); } else { @@ -30846,7 +33079,7 @@ var ts; } } function processTopLevelVariableAndFunctionDeclarations(node) { - // per ES6 spec: + // per ES6 spec: // 15.2.1.16.4 ModuleDeclarationInstantiation() Concrete Method // - var declarations are initialized to undefined - 14.a.ii // - function/generator declarations are instantiated - 16.a.iv @@ -30865,12 +33098,12 @@ var ts; var seen = {}; for (var i = 0; i < hoistedVars.length; ++i) { var local = hoistedVars[i]; - var name_22 = local.kind === 65 /* Identifier */ + var name_25 = local.kind === 66 /* Identifier */ ? local : local.name; - if (name_22) { + if (name_25) { // do not emit duplicate entries (in case of declaration merging) in the list of hoisted variables - var text = ts.unescapeIdentifier(name_22.text); + var text = ts.unescapeIdentifier(name_25.text); if (ts.hasProperty(seen, text)) { continue; } @@ -30881,13 +33114,13 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 204 /* ClassDeclaration */ || local.kind === 208 /* ModuleDeclaration */ || local.kind === 207 /* EnumDeclaration */) { + if (local.kind === 211 /* ClassDeclaration */ || local.kind === 215 /* ModuleDeclaration */ || local.kind === 214 /* EnumDeclaration */) { emitDeclarationName(local); } else { emit(local); } - var flags = ts.getCombinedNodeFlags(local.kind === 65 /* Identifier */ ? local.parent : local); + var flags = ts.getCombinedNodeFlags(local.kind === 66 /* Identifier */ ? local.parent : local); if (flags & 1 /* Export */) { if (!exportedDeclarations) { exportedDeclarations = []; @@ -30915,21 +33148,21 @@ var ts; if (node.flags & 2 /* Ambient */) { return; } - if (node.kind === 203 /* FunctionDeclaration */) { + if (node.kind === 210 /* FunctionDeclaration */) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 204 /* ClassDeclaration */) { + if (node.kind === 211 /* ClassDeclaration */) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 207 /* EnumDeclaration */) { + if (node.kind === 214 /* EnumDeclaration */) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -30938,7 +33171,7 @@ var ts; } return; } - if (node.kind === 208 /* ModuleDeclaration */) { + if (node.kind === 215 /* ModuleDeclaration */) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -30947,17 +33180,17 @@ var ts; } return; } - if (node.kind === 201 /* VariableDeclaration */ || node.kind === 155 /* BindingElement */) { + if (node.kind === 208 /* VariableDeclaration */ || node.kind === 160 /* BindingElement */) { if (shouldHoistVariable(node, false)) { - var name_23 = node.name; - if (name_23.kind === 65 /* Identifier */) { + var name_26 = node.name; + if (name_26.kind === 66 /* Identifier */) { if (!hoistedVars) { hoistedVars = []; } - hoistedVars.push(name_23); + hoistedVars.push(name_26); } else { - ts.forEachChild(name_23, visit); + ts.forEachChild(name_26, visit); } } return; @@ -30978,10 +33211,10 @@ var ts; // hoist variable if // - it is not block scoped // - it is top level block scoped - // if block scoped variables are nested in some another block then + // if block scoped variables are nested in some another block then // no other functions can use them except ones that are defined at least in the same block - return (ts.getCombinedNodeFlags(node) & 12288 /* BlockScoped */) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 230 /* SourceFile */; + return (ts.getCombinedNodeFlags(node) & 49152 /* BlockScoped */) === 0 || + ts.getEnclosingBlockScopeContainer(node).kind === 245 /* SourceFile */; } function isCurrentFileSystemExternalModule() { return compilerOptions.module === 4 /* System */ && ts.isExternalModule(currentSourceFile); @@ -31052,21 +33285,21 @@ var ts; var parameterName = "_" + importVariableName; write("function (" + parameterName + ") {"); switch (importNode.kind) { - case 212 /* ImportDeclaration */: + case 219 /* ImportDeclaration */: if (!importNode.importClause) { // 'import "..."' case // module is imported only for side-effects, setter body will be empty break; } // fall-through - case 211 /* ImportEqualsDeclaration */: + case 218 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== ""); increaseIndent(); writeLine(); // save import into the local write(importVariableName + " = " + parameterName + ";"); writeLine(); - var defaultName = importNode.kind === 212 /* ImportDeclaration */ + var defaultName = importNode.kind === 219 /* ImportDeclaration */ ? importNode.importClause.name : importNode.name; if (defaultName) { @@ -31078,10 +33311,10 @@ var ts; emitExportMemberAssignments(defaultName); writeLine(); } - if (importNode.kind === 212 /* ImportDeclaration */ && + if (importNode.kind === 219 /* ImportDeclaration */ && importNode.importClause.namedBindings) { var namedBindings = importNode.importClause.namedBindings; - if (namedBindings.kind === 214 /* NamespaceImport */) { + if (namedBindings.kind === 221 /* NamespaceImport */) { // emit re-export for namespace // import * as n from 'foo' // export {n} @@ -31101,7 +33334,7 @@ var ts; } decreaseIndent(); break; - case 218 /* ExportDeclaration */: + case 225 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== ""); increaseIndent(); if (importNode.exportClause) { @@ -31144,10 +33377,10 @@ var ts; // - imports/exports are not emitted for system modules // - function declarations are not emitted because they were already hoisted switch (statement.kind) { - case 218 /* ExportDeclaration */: - case 212 /* ImportDeclaration */: - case 211 /* ImportEqualsDeclaration */: - case 203 /* FunctionDeclaration */: + case 225 /* ExportDeclaration */: + case 219 /* ImportDeclaration */: + case 218 /* ImportEqualsDeclaration */: + case 210 /* FunctionDeclaration */: continue; } writeLine(); @@ -31162,14 +33395,15 @@ var ts; // System modules has the following shape // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) // 'exports' here is a function 'exports(name: string, value: T): T' that is used to publish exported values. - // 'exports' returns its 'value' argument so in most cases expressions + // 'exports' returns its 'value' argument so in most cases expressions // that mutate exported values can be rewritten as: - // expr -> exports('name', expr). - // The only exception in this rule is postfix unary operators, + // expr -> exports('name', expr). + // The only exception in this rule is postfix unary operators, // see comment to 'emitPostfixUnaryExpression' for more details ts.Debug.assert(!exportFunctionForFile); // make sure that name of 'exports' function does not conflict with existing identifiers exportFunctionForFile = makeUniqueName("exports"); + writeLine(); write("System.register("); if (node.moduleName) { write("\"" + node.moduleName + "\", "); @@ -31203,12 +33437,12 @@ var ts; // 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 = []; // names of modules with corresponding parameter in the - // factory function. - var unaliasedModuleNames = []; // names of modules with no corresponding parameters in - // factory function. - var importAliasNames = []; // names of the parameters in the factory function; these - // parameters need to match the indexes of the corresponding + // names of modules with corresponding parameter in the factory function + var aliasedModuleNames = []; + // names of modules with no corresponding parameters in factory function + var unaliasedModuleNames = []; + var importAliasNames = []; // names of the parameters in the factory function; these + // parameters need to match the indexes of the corresponding // module names in aliasedModuleNames. // Fill in amd-dependency tags for (var _a = 0, _b = node.amdDependencies; _a < _b.length; _a++) { @@ -31301,7 +33535,7 @@ var ts; emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(true); - // Emit exportDefault if it exists will happen as part + // Emit exportDefault if it exists will happen as part // or normal statement emit. } function emitExportEquals(emitAsReturn) { @@ -31314,6 +33548,91 @@ var ts; emitEnd(exportEquals); } } + function emitJsxElement(node) { + switch (compilerOptions.jsx) { + case 2 /* React */: + jsxEmitReact(node); + break; + case 1 /* Preserve */: + // Fall back to preserve if None was specified (we'll error earlier) + default: + jsxEmitPreserve(node); + break; + } + } + function trimReactWhitespace(node) { + var result = undefined; + var text = ts.getTextOfNode(node); + var firstNonWhitespace = 0; + var lastNonWhitespace = -1; + // JSX trims whitespace at the end and beginning of lines, except that the + // start/end of a tag is considered a start/end of a line only if that line is + // on the same line as the closing tag. See examples in tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx + 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; + } + return result; + } + function getTextToEmit(node) { + switch (compilerOptions.jsx) { + case 2 /* React */: + var text = trimReactWhitespace(node); + if (text.length === 0) { + return undefined; + } + else { + return text; + } + case 1 /* Preserve */: + default: + return ts.getTextOfNode(node, true); + } + } + function emitJsxText(node) { + switch (compilerOptions.jsx) { + case 2 /* React */: + write('"'); + write(trimReactWhitespace(node)); + write('"'); + break; + case 1 /* Preserve */: + default: + write(ts.getTextOfNode(node, true)); + break; + } + } + function emitJsxExpression(node) { + if (node.expression) { + switch (compilerOptions.jsx) { + case 1 /* Preserve */: + default: + write('{'); + emit(node.expression); + write('}'); + break; + case 2 /* React */: + emit(node.expression); + break; + } + } + } function emitDirectivePrologues(statements, startWithNewLine) { for (var i = 0; i < statements.length; ++i) { if (ts.isPrologueDirective(statements[i])) { @@ -31353,17 +33672,21 @@ var ts; writeLines(extendsHelper); extendsEmitted = true; } - if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 512 /* EmitDecorate */) { + if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 16 /* EmitDecorate */) { writeLines(decorateHelper); if (compilerOptions.emitDecoratorMetadata) { writeLines(metadataHelper); } decorateEmitted = true; } - if (!paramEmitted && resolver.getNodeCheckFlags(node) & 1024 /* EmitParam */) { + if (!paramEmitted && resolver.getNodeCheckFlags(node) & 32 /* EmitParam */) { writeLines(paramHelper); paramEmitted = true; } + if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & 64 /* EmitAwaiter */) { + writeLines(awaiterHelper); + awaiterEmitted = true; + } } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { if (languageVersion >= 2 /* ES6 */) { @@ -31413,31 +33736,31 @@ var ts; switch (node.kind) { // All of these entities are emitted in a specialized fashion. As such, we allow // the specialized methods for each to handle the comments on the nodes. - case 205 /* InterfaceDeclaration */: - case 203 /* FunctionDeclaration */: - case 212 /* ImportDeclaration */: - case 211 /* ImportEqualsDeclaration */: - case 206 /* TypeAliasDeclaration */: - case 217 /* ExportAssignment */: + case 212 /* InterfaceDeclaration */: + case 210 /* FunctionDeclaration */: + case 219 /* ImportDeclaration */: + case 218 /* ImportEqualsDeclaration */: + case 213 /* TypeAliasDeclaration */: + case 224 /* ExportAssignment */: return false; - case 183 /* VariableStatement */: + case 190 /* VariableStatement */: return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: // Only emit the leading/trailing comments for a module if we're actually // emitting the module as well. return shouldEmitModuleDeclaration(node); - case 207 /* EnumDeclaration */: + case 214 /* EnumDeclaration */: // Only emit the leading/trailing comments for an enum if we're actually // emitting the module as well. return shouldEmitEnumDeclaration(node); } - // If this is the expression body of an arrow function that we're down-leveling, + // If this is the expression body of an arrow function that we're down-leveling, // then we don't want to emit comments when we emit the body. It will have already // been taken care of when we emitted the 'return' statement for the function // expression body. - if (node.kind !== 182 /* Block */ && + if (node.kind !== 189 /* Block */ && node.parent && - node.parent.kind === 166 /* ArrowFunction */ && + node.parent.kind === 171 /* ArrowFunction */ && node.parent.body === node && compilerOptions.target <= 1 /* ES5 */) { return false; @@ -31448,25 +33771,25 @@ var ts; function emitJavaScriptWorker(node) { // Check if the node can be emitted regardless of the ScriptTarget switch (node.kind) { - case 65 /* Identifier */: + case 66 /* Identifier */: return emitIdentifier(node); - case 131 /* Parameter */: + case 135 /* Parameter */: return emitParameter(node); - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: return emitMethod(node); - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: return emitAccessor(node); - case 93 /* ThisKeyword */: + case 94 /* ThisKeyword */: return emitThis(node); - case 91 /* SuperKeyword */: + case 92 /* SuperKeyword */: return emitSuper(node); - case 89 /* NullKeyword */: + case 90 /* NullKeyword */: return write("null"); - case 95 /* TrueKeyword */: + case 96 /* TrueKeyword */: return write("true"); - case 80 /* FalseKeyword */: + case 81 /* FalseKeyword */: return write("false"); case 7 /* NumericLiteral */: case 8 /* StringLiteral */: @@ -31476,131 +33799,142 @@ var ts; case 12 /* TemplateMiddle */: case 13 /* TemplateTail */: return emitLiteral(node); - case 174 /* TemplateExpression */: + case 180 /* TemplateExpression */: return emitTemplateExpression(node); - case 180 /* TemplateSpan */: + case 187 /* TemplateSpan */: return emitTemplateSpan(node); - case 128 /* QualifiedName */: + case 230 /* JsxElement */: + case 231 /* JsxSelfClosingElement */: + return emitJsxElement(node); + case 233 /* JsxText */: + return emitJsxText(node); + case 237 /* JsxExpression */: + return emitJsxExpression(node); + case 132 /* QualifiedName */: return emitQualifiedName(node); - case 153 /* ObjectBindingPattern */: + case 158 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 154 /* ArrayBindingPattern */: + case 159 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 155 /* BindingElement */: + case 160 /* BindingElement */: return emitBindingElement(node); - case 156 /* ArrayLiteralExpression */: + case 161 /* ArrayLiteralExpression */: return emitArrayLiteral(node); - case 157 /* ObjectLiteralExpression */: + case 162 /* ObjectLiteralExpression */: return emitObjectLiteral(node); - case 227 /* PropertyAssignment */: + case 242 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 228 /* ShorthandPropertyAssignment */: + case 243 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 129 /* ComputedPropertyName */: + case 133 /* ComputedPropertyName */: return emitComputedPropertyName(node); - case 158 /* PropertyAccessExpression */: + case 163 /* PropertyAccessExpression */: return emitPropertyAccess(node); - case 159 /* ElementAccessExpression */: + case 164 /* ElementAccessExpression */: return emitIndexedAccess(node); - case 160 /* CallExpression */: + case 165 /* CallExpression */: return emitCallExpression(node); - case 161 /* NewExpression */: + case 166 /* NewExpression */: return emitNewExpression(node); - case 162 /* TaggedTemplateExpression */: + case 167 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 163 /* TypeAssertionExpression */: + case 168 /* TypeAssertionExpression */: return emit(node.expression); - case 164 /* ParenthesizedExpression */: + case 186 /* AsExpression */: + return emit(node.expression); + case 169 /* ParenthesizedExpression */: return emitParenExpression(node); - case 203 /* FunctionDeclaration */: - case 165 /* FunctionExpression */: - case 166 /* ArrowFunction */: + case 210 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: return emitFunctionDeclaration(node); - case 167 /* DeleteExpression */: + case 172 /* DeleteExpression */: return emitDeleteExpression(node); - case 168 /* TypeOfExpression */: + case 173 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 169 /* VoidExpression */: + case 174 /* VoidExpression */: return emitVoidExpression(node); - case 170 /* PrefixUnaryExpression */: + case 175 /* AwaitExpression */: + return emitAwaitExpression(node); + case 176 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 171 /* PostfixUnaryExpression */: + case 177 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 172 /* BinaryExpression */: + case 178 /* BinaryExpression */: return emitBinaryExpression(node); - case 173 /* ConditionalExpression */: + case 179 /* ConditionalExpression */: return emitConditionalExpression(node); - case 176 /* SpreadElementExpression */: + case 182 /* SpreadElementExpression */: return emitSpreadElementExpression(node); - case 175 /* YieldExpression */: + case 181 /* YieldExpression */: return emitYieldExpression(node); - case 178 /* OmittedExpression */: + case 184 /* OmittedExpression */: return; - case 182 /* Block */: - case 209 /* ModuleBlock */: + case 189 /* Block */: + case 216 /* ModuleBlock */: return emitBlock(node); - case 183 /* VariableStatement */: + case 190 /* VariableStatement */: return emitVariableStatement(node); - case 184 /* EmptyStatement */: + case 191 /* EmptyStatement */: return write(";"); - case 185 /* ExpressionStatement */: + case 192 /* ExpressionStatement */: return emitExpressionStatement(node); - case 186 /* IfStatement */: + case 193 /* IfStatement */: return emitIfStatement(node); - case 187 /* DoStatement */: + case 194 /* DoStatement */: return emitDoStatement(node); - case 188 /* WhileStatement */: + case 195 /* WhileStatement */: return emitWhileStatement(node); - case 189 /* ForStatement */: + case 196 /* ForStatement */: return emitForStatement(node); - case 191 /* ForOfStatement */: - case 190 /* ForInStatement */: + case 198 /* ForOfStatement */: + case 197 /* ForInStatement */: return emitForInOrForOfStatement(node); - case 192 /* ContinueStatement */: - case 193 /* BreakStatement */: + case 199 /* ContinueStatement */: + case 200 /* BreakStatement */: return emitBreakOrContinueStatement(node); - case 194 /* ReturnStatement */: + case 201 /* ReturnStatement */: return emitReturnStatement(node); - case 195 /* WithStatement */: + case 202 /* WithStatement */: return emitWithStatement(node); - case 196 /* SwitchStatement */: + case 203 /* SwitchStatement */: return emitSwitchStatement(node); - case 223 /* CaseClause */: - case 224 /* DefaultClause */: + case 238 /* CaseClause */: + case 239 /* DefaultClause */: return emitCaseOrDefaultClause(node); - case 197 /* LabeledStatement */: + case 204 /* LabeledStatement */: return emitLabelledStatement(node); - case 198 /* ThrowStatement */: + case 205 /* ThrowStatement */: return emitThrowStatement(node); - case 199 /* TryStatement */: + case 206 /* TryStatement */: return emitTryStatement(node); - case 226 /* CatchClause */: + case 241 /* CatchClause */: return emitCatchClause(node); - case 200 /* DebuggerStatement */: + case 207 /* DebuggerStatement */: return emitDebuggerStatement(node); - case 201 /* VariableDeclaration */: + case 208 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 177 /* ClassExpression */: + case 183 /* ClassExpression */: return emitClassExpression(node); - case 204 /* ClassDeclaration */: + case 211 /* ClassDeclaration */: return emitClassDeclaration(node); - case 205 /* InterfaceDeclaration */: + case 212 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 207 /* EnumDeclaration */: + case 214 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 229 /* EnumMember */: + case 244 /* EnumMember */: return emitEnumMember(node); - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 212 /* ImportDeclaration */: + case 219 /* ImportDeclaration */: return emitImportDeclaration(node); - case 211 /* ImportEqualsDeclaration */: + case 218 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 218 /* ExportDeclaration */: + case 225 /* ExportDeclaration */: return emitExportDeclaration(node); - case 217 /* ExportAssignment */: + case 224 /* ExportAssignment */: return emitExportAssignment(node); - case 230 /* SourceFile */: + case 245 /* SourceFile */: return emitSourceFileNode(node); } } @@ -31632,7 +33966,7 @@ var ts; function getLeadingCommentsToEmit(node) { // Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments if (node.parent) { - if (node.parent.kind === 230 /* SourceFile */ || node.pos !== node.parent.pos) { + if (node.parent.kind === 245 /* SourceFile */ || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { // get comments without detached comments return getLeadingCommentsWithoutDetachedComments(); @@ -31647,7 +33981,7 @@ var ts; function getTrailingCommentsToEmit(node) { // Emit the trailing comments only if the parent's pos doesn't match because parent should take care of emitting these comments if (node.parent) { - if (node.parent.kind === 230 /* SourceFile */ || node.end !== node.parent.end) { + if (node.parent.kind === 245 /* SourceFile */ || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } @@ -31843,10 +34177,10 @@ var ts; }; } ts.createCompilerHost = createCompilerHost; - function getPreEmitDiagnostics(program, sourceFile) { - var diagnostics = program.getOptionsDiagnostics().concat(program.getSyntacticDiagnostics(sourceFile), program.getGlobalDiagnostics(), program.getSemanticDiagnostics(sourceFile)); + function getPreEmitDiagnostics(program, sourceFile, cancellationToken) { + var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (program.getCompilerOptions().declaration) { - diagnostics.concat(program.getDeclarationDiagnostics(sourceFile)); + diagnostics.concat(program.getDeclarationDiagnostics(sourceFile, cancellationToken)); } return ts.sortAndDeduplicateDiagnostics(diagnostics); } @@ -31947,10 +34281,15 @@ var ts; function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false)); } - function emit(sourceFile, writeFileCallback) { + function emit(sourceFile, writeFileCallback, cancellationToken) { + var _this = this; + return runWithCancellationToken(function () { return emitWorker(_this, sourceFile, writeFileCallback, cancellationToken); }); + } + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken) { // If the noEmitOnError flag is set, then check if we have any errors so far. If so, - // immediately bail out. - if (options.noEmitOnError && getPreEmitDiagnostics(this).length > 0) { + // immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we + // get any preEmit diagnostics, not just the ones + if (options.noEmitOnError && getPreEmitDiagnostics(program, undefined, cancellationToken).length > 0) { return { diagnostics: [], sourceMaps: undefined, emitSkipped: true }; } // Create the emit resolver outside of the "emitTime" tracking code below. That way @@ -31970,43 +34309,71 @@ var ts; function getSourceFile(fileName) { return filesByName.get(fileName); } - function getDiagnosticsHelper(sourceFile, getDiagnostics) { + function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) { if (sourceFile) { - return getDiagnostics(sourceFile); + return getDiagnostics(sourceFile, cancellationToken); } var allDiagnostics = []; ts.forEach(program.getSourceFiles(), function (sourceFile) { - ts.addRange(allDiagnostics, getDiagnostics(sourceFile)); + if (cancellationToken) { + cancellationToken.throwIfCancellationRequested(); + } + ts.addRange(allDiagnostics, getDiagnostics(sourceFile, cancellationToken)); }); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } - function getSyntacticDiagnostics(sourceFile) { - return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile); + function getSyntacticDiagnostics(sourceFile, cancellationToken) { + return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile, cancellationToken); } - function getSemanticDiagnostics(sourceFile) { - return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile); + function getSemanticDiagnostics(sourceFile, cancellationToken) { + return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile, cancellationToken); } - function getDeclarationDiagnostics(sourceFile) { - return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile); + function getDeclarationDiagnostics(sourceFile, cancellationToken) { + return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken); } - function getSyntacticDiagnosticsForFile(sourceFile) { + function getSyntacticDiagnosticsForFile(sourceFile, cancellationToken) { return sourceFile.parseDiagnostics; } - function getSemanticDiagnosticsForFile(sourceFile) { - var typeChecker = getDiagnosticsProducingTypeChecker(); - ts.Debug.assert(!!sourceFile.bindDiagnostics); - var bindDiagnostics = sourceFile.bindDiagnostics; - var checkDiagnostics = typeChecker.getDiagnostics(sourceFile); - var programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName); - return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics); - } - function getDeclarationDiagnosticsForFile(sourceFile) { - if (!ts.isDeclarationFile(sourceFile)) { - var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile); - // Don't actually write any files since we're just getting diagnostics. - var writeFile = function () { }; - return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); + function runWithCancellationToken(func) { + try { + return func(); } + catch (e) { + if (e instanceof ts.OperationCanceledException) { + // We were canceled while performing the operation. Because our type checker + // might be a bad state, we need to throw it away. + // + // Note: we are overly agressive here. We do not actually *have* to throw away + // the "noDiagnosticsTypeChecker". However, for simplicity, i'd like to keep + // the lifetimes of these two TypeCheckers the same. Also, we generally only + // cancel when the user has made a change anyways. And, in that case, we (the + // program instance) will get thrown away anyways. So trying to keep one of + // these type checkers alive doesn't serve much purpose. + noDiagnosticsTypeChecker = undefined; + diagnosticsProducingTypeChecker = undefined; + } + throw e; + } + } + function getSemanticDiagnosticsForFile(sourceFile, cancellationToken) { + return runWithCancellationToken(function () { + var typeChecker = getDiagnosticsProducingTypeChecker(); + ts.Debug.assert(!!sourceFile.bindDiagnostics); + var bindDiagnostics = sourceFile.bindDiagnostics; + var checkDiagnostics = typeChecker.getDiagnostics(sourceFile, cancellationToken); + var programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName); + return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics); + }); + } + function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) { + return runWithCancellationToken(function () { + if (!ts.isDeclarationFile(sourceFile)) { + var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); + // Don't actually write any files since we're just getting diagnostics. + var writeFile_1 = function () { }; + return ts.getDeclarationDiagnostics(getEmitHost(writeFile_1), resolver, sourceFile); + } + }); } function getOptionsDiagnostics() { var allDiagnostics = []; @@ -32027,7 +34394,6 @@ var ts; function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var start; var length; - var extensions; var diagnosticArgument; if (refEnd !== undefined && refPos !== undefined) { start = refPos; @@ -32132,7 +34498,7 @@ var ts; } function processImportedModules(file, basePath) { ts.forEach(file.statements, function (node) { - if (node.kind === 212 /* ImportDeclaration */ || node.kind === 211 /* ImportEqualsDeclaration */ || node.kind === 218 /* ExportDeclaration */) { + if (node.kind === 219 /* ImportDeclaration */ || node.kind === 218 /* ImportEqualsDeclaration */ || node.kind === 225 /* ExportDeclaration */) { var moduleNameExpr = ts.getExternalModuleName(node); if (moduleNameExpr && moduleNameExpr.kind === 8 /* StringLiteral */) { var moduleNameText = moduleNameExpr.text; @@ -32153,9 +34519,9 @@ var ts; } } } - else if (node.kind === 208 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { + else if (node.kind === 215 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { // TypeScript 1.0 spec (April 2014): 12.1.6 - // An AmbientExternalModuleDeclaration declares an external module. + // An AmbientExternalModuleDeclaration declares an external module. // This type of declaration is permitted only in the global module. // The StringLiteral must specify a top - level external module name. // Relative external module names are not permitted @@ -32166,7 +34532,7 @@ var ts; var moduleName = nameLiteral.text; if (moduleName) { // TypeScript 1.0 spec (April 2014): 12.1.6 - // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules + // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules // only through top - level external module names. Relative external module names are not permitted. var searchName = ts.normalizePath(ts.combinePaths(basePath, moduleName)); ts.forEach(ts.supportedExtensions, function (extension) { return findModuleSourceFile(searchName + extension, nameLiteral); }); @@ -32284,7 +34650,7 @@ var ts; } } else if (firstExternalModuleSourceFile && languageVersion < 2 /* ES6 */ && !options.module) { - // We cannot use createDiagnosticFromNode because nodes do not have parents yet + // We cannot use createDiagnosticFromNode because nodes do not have parents yet var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); diagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); } @@ -32307,7 +34673,7 @@ var ts; commonSourceDirectory = computeCommonSourceDirectory(files); } if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== ts.directorySeparator) { - // Make sure directory path ends with directory separator so this string can directly + // Make sure directory path ends with directory separator so this string can directly // used to replace with "" to get the relative path of the source file and the relative path doesn't // start with / making it rooted path commonSourceDirectory += ts.directorySeparator; @@ -32325,6 +34691,10 @@ var ts; !options.experimentalDecorators) { diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified)); } + if (options.experimentalAsyncFunctions && + options.target !== 2 /* ES6 */) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower)); + } } } ts.createProgram = createProgram; @@ -32369,6 +34739,16 @@ var ts; name: "inlineSources", type: "boolean" }, + { + name: "jsx", + type: { + "preserve": 1 /* Preserve */, + "react": 2 /* React */ + }, + paramType: ts.Diagnostics.KIND, + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, + error: ts.Diagnostics.Argument_for_jsx_must_be_preserve_or_react + }, { name: "listFiles", type: "boolean" @@ -32524,6 +34904,11 @@ 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", @@ -32585,10 +34970,10 @@ var ts; break; // If not a primitive, the possible types are specified in what is effectively a map of options. default: - var map = opt.type; + var map_2 = opt.type; var key = (args[i++] || "").toLowerCase(); - if (ts.hasProperty(map, key)) { - options[opt.name] = map[key]; + if (ts.hasProperty(map_2, key)) { + options[opt.name] = map_2[key]; } else { errors.push(ts.createCompilerDiagnostic(opt.error)); @@ -32645,8 +35030,9 @@ var ts; * @param fileName The path to the config file */ function readConfigFile(fileName) { + var text = ''; try { - var text = ts.sys.readFile(fileName); + text = ts.sys.readFile(fileName); } catch (e) { return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; @@ -32731,11 +35117,22 @@ var ts; } else { var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; - var sysFiles = host.readDirectory(basePath, ".ts", exclude); + var sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)); for (var i = 0; i < sysFiles.length; i++) { - var name = sysFiles[i]; - if (!ts.fileExtensionIs(name, ".d.ts") || !ts.contains(sysFiles, name.substr(0, name.length - 5) + ".ts")) { - fileNames.push(name); + var name_27 = sysFiles[i]; + if (ts.fileExtensionIs(name_27, ".d.ts")) { + var baseName = name_27.substr(0, name_27.length - ".d.ts".length); + if (!ts.contains(sysFiles, baseName + ".tsx") && !ts.contains(sysFiles, baseName + ".ts")) { + fileNames.push(name_27); + } + } + else if (ts.fileExtensionIs(name_27, ".ts")) { + if (!ts.contains(sysFiles, name_27 + "x")) { + fileNames.push(name_27); + } + } + else { + fileNames.push(name_27); } } } @@ -32816,7 +35213,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 166 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 171 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; @@ -32828,7 +35225,7 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 182 /* Block */: + case 189 /* Block */: if (!ts.isFunctionBlock(n)) { var parent_8 = n.parent; var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); @@ -32836,18 +35233,18 @@ var ts; // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collaps the block, but consider its hint span // to be the entire span of the parent. - if (parent_8.kind === 187 /* DoStatement */ || - parent_8.kind === 190 /* ForInStatement */ || - parent_8.kind === 191 /* ForOfStatement */ || - parent_8.kind === 189 /* ForStatement */ || - parent_8.kind === 186 /* IfStatement */ || - parent_8.kind === 188 /* WhileStatement */ || - parent_8.kind === 195 /* WithStatement */ || - parent_8.kind === 226 /* CatchClause */) { + if (parent_8.kind === 194 /* DoStatement */ || + parent_8.kind === 197 /* ForInStatement */ || + parent_8.kind === 198 /* ForOfStatement */ || + parent_8.kind === 196 /* ForStatement */ || + parent_8.kind === 193 /* IfStatement */ || + parent_8.kind === 195 /* WhileStatement */ || + parent_8.kind === 202 /* WithStatement */ || + parent_8.kind === 241 /* CatchClause */) { addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_8.kind === 199 /* TryStatement */) { + if (parent_8.kind === 206 /* TryStatement */) { // Could be the try-block, or the finally-block. var tryStatement = parent_8; if (tryStatement.tryBlock === n) { @@ -32855,7 +35252,7 @@ var ts; break; } else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 81 /* FinallyKeyword */, sourceFile); + var finallyKeyword = ts.findChildOfKind(tryStatement, 82 /* FinallyKeyword */, sourceFile); if (finallyKeyword) { addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); break; @@ -32874,23 +35271,23 @@ var ts; break; } // Fallthrough. - case 209 /* ModuleBlock */: { + case 216 /* ModuleBlock */: { var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 204 /* ClassDeclaration */: - case 205 /* InterfaceDeclaration */: - case 207 /* EnumDeclaration */: - case 157 /* ObjectLiteralExpression */: - case 210 /* CaseBlock */: { + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: + case 214 /* EnumDeclaration */: + case 162 /* ObjectLiteralExpression */: + case 217 /* CaseBlock */: { var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 156 /* ArrayLiteralExpression */: + case 161 /* ArrayLiteralExpression */: var openBracket = ts.findChildOfKind(n, 18 /* OpenBracketToken */, sourceFile); var closeBracket = ts.findChildOfKind(n, 19 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -32918,12 +35315,12 @@ var ts; ts.forEach(program.getSourceFiles(), function (sourceFile) { cancellationToken.throwIfCancellationRequested(); var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_24 in nameToDeclarations) { - var declarations = ts.getProperty(nameToDeclarations, name_24); + for (var name_28 in nameToDeclarations) { + var declarations = ts.getProperty(nameToDeclarations, name_28); if (declarations) { // First do a quick check to see if the name of the declaration matches the // last portion of the (possibly) dotted name they're searching for. - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_24); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_28); if (!matches) { continue; } @@ -32936,14 +35333,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_24); + matches = patternMatcher.getMatches(containers, name_28); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_24, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_28, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -32967,7 +35364,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 65 /* Identifier */ || + if (node.kind === 66 /* Identifier */ || node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) { return node.text; @@ -32981,7 +35378,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 129 /* ComputedPropertyName */) { + else if (declaration.name.kind === 133 /* ComputedPropertyName */) { return tryAddComputedPropertyName(declaration.name.expression, containers, true); } else { @@ -33002,7 +35399,7 @@ var ts; } return true; } - if (expression.kind === 158 /* PropertyAccessExpression */) { + if (expression.kind === 163 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -33015,7 +35412,7 @@ var ts; var containers = []; // First, if we started with a computed property name, then add all but the last // portion into the container array. - if (declaration.name.kind === 129 /* ComputedPropertyName */) { + if (declaration.name.kind === 133 /* ComputedPropertyName */) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { return undefined; } @@ -33091,17 +35488,17 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: // If we have a module declared as A.B.C, it is more "intuitive" // to say it only has a single layer of depth do { current = current.parent; - } while (current.kind === 208 /* ModuleDeclaration */); + } while (current.kind === 215 /* ModuleDeclaration */); // fall through - case 204 /* ClassDeclaration */: - case 207 /* EnumDeclaration */: - case 205 /* InterfaceDeclaration */: - case 203 /* FunctionDeclaration */: + case 211 /* ClassDeclaration */: + case 214 /* EnumDeclaration */: + case 212 /* InterfaceDeclaration */: + case 210 /* FunctionDeclaration */: indent++; } current = current.parent; @@ -33112,21 +35509,21 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 183 /* VariableStatement */: + case 190 /* VariableStatement */: ts.forEach(node.declarationList.declarations, visit); break; - case 153 /* ObjectBindingPattern */: - case 154 /* ArrayBindingPattern */: + case 158 /* ObjectBindingPattern */: + case 159 /* ArrayBindingPattern */: ts.forEach(node.elements, visit); break; - case 218 /* ExportDeclaration */: + case 225 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 212 /* ImportDeclaration */: + case 219 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -33138,7 +35535,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 214 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 221 /* NamespaceImport */) { childNodes.push(importClause.namedBindings); } else { @@ -33147,21 +35544,21 @@ var ts; } } break; - case 155 /* BindingElement */: - case 201 /* VariableDeclaration */: + case 160 /* BindingElement */: + case 208 /* VariableDeclaration */: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } // Fall through - case 204 /* ClassDeclaration */: - case 207 /* EnumDeclaration */: - case 205 /* InterfaceDeclaration */: - case 208 /* ModuleDeclaration */: - case 203 /* FunctionDeclaration */: - case 211 /* ImportEqualsDeclaration */: - case 216 /* ImportSpecifier */: - case 220 /* ExportSpecifier */: + case 211 /* ClassDeclaration */: + case 214 /* EnumDeclaration */: + case 212 /* InterfaceDeclaration */: + case 215 /* ModuleDeclaration */: + case 210 /* FunctionDeclaration */: + case 218 /* ImportEqualsDeclaration */: + case 223 /* ImportSpecifier */: + case 227 /* ExportSpecifier */: childNodes.push(node); break; } @@ -33209,17 +35606,17 @@ var ts; for (var _i = 0; _i < nodes.length; _i++) { var node = nodes[_i]; switch (node.kind) { - case 204 /* ClassDeclaration */: - case 207 /* EnumDeclaration */: - case 205 /* InterfaceDeclaration */: + case 211 /* ClassDeclaration */: + case 214 /* EnumDeclaration */: + case 212 /* InterfaceDeclaration */: topLevelNodes.push(node); break; - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 203 /* FunctionDeclaration */: + case 210 /* FunctionDeclaration */: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -33230,12 +35627,12 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 203 /* FunctionDeclaration */) { + if (functionDeclaration.kind === 210 /* FunctionDeclaration */) { // A function declaration is 'top level' if it contains any function declarations // within it. - if (functionDeclaration.body && functionDeclaration.body.kind === 182 /* Block */) { + if (functionDeclaration.body && functionDeclaration.body.kind === 189 /* Block */) { // Proper function declarations can only have identifier names - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 203 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 210 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { return true; } // Or if it is not parented by another function. i.e all functions @@ -33272,7 +35669,7 @@ var ts; } function merge(target, source) { // First, add any spans in the source to the target. - target.spans.push.apply(target.spans, source.spans); + ts.addRange(target.spans, source.spans); if (source.childItems) { if (!target.childItems) { target.childItems = []; @@ -33295,44 +35692,44 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 131 /* Parameter */: + case 135 /* Parameter */: if (ts.isBindingPattern(node.name)) { break; } - if ((node.flags & 499 /* Modifier */) === 0) { + if ((node.flags & 2035 /* Modifier */) === 0) { return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 138 /* GetAccessor */: + case 142 /* GetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); - case 139 /* SetAccessor */: + case 143 /* SetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 142 /* IndexSignature */: + case 146 /* IndexSignature */: return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 229 /* EnumMember */: + case 244 /* EnumMember */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 140 /* CallSignature */: + case 144 /* CallSignature */: return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 141 /* ConstructSignature */: + case 145 /* ConstructSignature */: return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 203 /* FunctionDeclaration */: + case 210 /* FunctionDeclaration */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 201 /* VariableDeclaration */: - case 155 /* BindingElement */: + case 208 /* VariableDeclaration */: + case 160 /* BindingElement */: var variableDeclarationNode; - var name_25; - if (node.kind === 155 /* BindingElement */) { - name_25 = node.name; + var name_29; + if (node.kind === 160 /* BindingElement */) { + name_29 = node.name; variableDeclarationNode = node; // binding elements are added only for variable declarations // bubble up to the containing variable declaration - while (variableDeclarationNode && variableDeclarationNode.kind !== 201 /* VariableDeclaration */) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 208 /* VariableDeclaration */) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -33340,24 +35737,24 @@ var ts; else { ts.Debug.assert(!ts.isBindingPattern(node.name)); variableDeclarationNode = node; - name_25 = node.name; + name_29 = node.name; } if (ts.isConst(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_25), ts.ScriptElementKind.constElement); + return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.constElement); } else if (ts.isLet(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_25), ts.ScriptElementKind.letElement); + return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.letElement); } else { - return createItem(node, getTextOfNode(name_25), ts.ScriptElementKind.variableElement); + return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.variableElement); } - case 137 /* Constructor */: + case 141 /* Constructor */: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 220 /* ExportSpecifier */: - case 216 /* ImportSpecifier */: - case 211 /* ImportEqualsDeclaration */: - case 213 /* ImportClause */: - case 214 /* NamespaceImport */: + case 227 /* ExportSpecifier */: + case 223 /* ImportSpecifier */: + case 218 /* ImportEqualsDeclaration */: + case 220 /* ImportClause */: + case 221 /* NamespaceImport */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -33387,17 +35784,17 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 230 /* SourceFile */: + case 245 /* SourceFile */: return createSourceFileItem(node); - case 204 /* ClassDeclaration */: + case 211 /* ClassDeclaration */: return createClassItem(node); - case 207 /* EnumDeclaration */: + case 214 /* EnumDeclaration */: return createEnumItem(node); - case 205 /* InterfaceDeclaration */: + case 212 /* InterfaceDeclaration */: return createIterfaceItem(node); - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: return createModuleItem(node); - case 203 /* FunctionDeclaration */: + case 210 /* FunctionDeclaration */: return createFunctionItem(node); } return undefined; @@ -33409,7 +35806,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 208 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 215 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -33421,7 +35818,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 === 182 /* Block */) { + if (node.body && node.body.kind === 189 /* Block */) { var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); return getNavigationBarItem(!node.name ? "default" : node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } @@ -33442,14 +35839,14 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 137 /* Constructor */ && member; + return member.kind === 141 /* Constructor */ && member; }); // Add the constructor parameters in as children of the class (for property parameters). // Note that *all non-binding pattern named* parameters will be added to the nodes array, but parameters that // are not properties will be filtered out later by createChildItem. var nodes = removeDynamicallyNamedProperties(node); if (constructor) { - nodes.push.apply(nodes, ts.filter(constructor.parameters, function (p) { return !ts.isBindingPattern(p.name); })); + ts.addRange(nodes, ts.filter(constructor.parameters, function (p) { return !ts.isBindingPattern(p.name); })); } childItems = getItemsWorker(sortNodes(nodes), createChildItem); } @@ -33466,7 +35863,7 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 129 /* ComputedPropertyName */; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 133 /* ComputedPropertyName */; }); } /** * Like removeComputedProperties, but retains the properties with well known symbol names @@ -33475,13 +35872,13 @@ var ts; return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 208 /* ModuleDeclaration */) { + while (node.body.kind === 215 /* ModuleDeclaration */) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 230 /* SourceFile */ + return node.kind === 245 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -34276,15 +36673,15 @@ var ts; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 160 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 165 /* CallExpression */) { return undefined; } // See if we can find some symbol with the call expression name that has call signatures. var callExpression = argumentInfo.invocation; var expression = callExpression.expression; - var name = expression.kind === 65 /* Identifier */ + var name = expression.kind === 66 /* Identifier */ ? expression - : expression.kind === 158 /* PropertyAccessExpression */ + : expression.kind === 163 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -34317,7 +36714,7 @@ var ts; * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 160 /* CallExpression */ || node.parent.kind === 161 /* NewExpression */) { + if (node.parent.kind === 165 /* CallExpression */ || node.parent.kind === 166 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: // 1. The token introduces a list, and should begin a sig help session @@ -34370,25 +36767,25 @@ var ts; }; } } - else if (node.kind === 10 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 162 /* TaggedTemplateExpression */) { + else if (node.kind === 10 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 167 /* TaggedTemplateExpression */) { // Check if we're actually inside the template; // otherwise we'll fall out and return undefined. if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, 0); } } - else if (node.kind === 11 /* TemplateHead */ && node.parent.parent.kind === 162 /* TaggedTemplateExpression */) { + else if (node.kind === 11 /* TemplateHead */ && node.parent.parent.kind === 167 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 174 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 180 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 180 /* TemplateSpan */ && node.parent.parent.parent.kind === 162 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 187 /* TemplateSpan */ && node.parent.parent.parent.kind === 167 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 174 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 180 /* TemplateExpression */); // If we're just after a template tail, don't show signature help. if (node.kind === 13 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { return undefined; @@ -34506,7 +36903,7 @@ var ts; // // This is because a Missing node has no width. However, what we actually want is to include trivia // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. - if (template.kind === 174 /* TemplateExpression */) { + if (template.kind === 180 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -34515,7 +36912,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 230 /* SourceFile */; n = n.parent) { + for (var n = node; n.kind !== 245 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -34572,23 +36969,23 @@ var ts; var prefixDisplayParts = []; var suffixDisplayParts = []; if (callTargetDisplayParts) { - prefixDisplayParts.push.apply(prefixDisplayParts, callTargetDisplayParts); + ts.addRange(prefixDisplayParts, callTargetDisplayParts); } if (isTypeParameterList) { prefixDisplayParts.push(ts.punctuationPart(24 /* LessThanToken */)); var typeParameters = candidateSignature.typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(25 /* GreaterThanToken */)); + suffixDisplayParts.push(ts.punctuationPart(26 /* GreaterThanToken */)); var parameterParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation); }); - suffixDisplayParts.push.apply(suffixDisplayParts, parameterParts); + ts.addRange(suffixDisplayParts, parameterParts); } else { var typeParameterParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); }); - prefixDisplayParts.push.apply(prefixDisplayParts, typeParameterParts); + ts.addRange(prefixDisplayParts, typeParameterParts); prefixDisplayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); var parameters = candidateSignature.parameters; signatureHelpParameters = parameters.length > 0 ? ts.map(parameters, createSignatureHelpParameterForParameter) : emptyArray; @@ -34597,7 +36994,7 @@ var ts; var returnTypeParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation); }); - suffixDisplayParts.push.apply(suffixDisplayParts, returnTypeParts); + ts.addRange(suffixDisplayParts, returnTypeParts); return { isVariadic: candidateSignature.hasRestParameter, prefixDisplayParts: prefixDisplayParts, @@ -34716,40 +37113,40 @@ var ts; return false; } switch (n.kind) { - case 204 /* ClassDeclaration */: - case 205 /* InterfaceDeclaration */: - case 207 /* EnumDeclaration */: - case 157 /* ObjectLiteralExpression */: - case 153 /* ObjectBindingPattern */: - case 148 /* TypeLiteral */: - case 182 /* Block */: - case 209 /* ModuleBlock */: - case 210 /* CaseBlock */: + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: + case 214 /* EnumDeclaration */: + case 162 /* ObjectLiteralExpression */: + case 158 /* ObjectBindingPattern */: + case 152 /* TypeLiteral */: + case 189 /* Block */: + case 216 /* ModuleBlock */: + case 217 /* CaseBlock */: return nodeEndsWith(n, 15 /* CloseBraceToken */, sourceFile); - case 226 /* CatchClause */: + case 241 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 161 /* NewExpression */: + case 166 /* NewExpression */: if (!n.arguments) { return true; } // fall through - case 160 /* CallExpression */: - case 164 /* ParenthesizedExpression */: - case 152 /* ParenthesizedType */: + case 165 /* CallExpression */: + case 169 /* ParenthesizedExpression */: + case 157 /* ParenthesizedType */: return nodeEndsWith(n, 17 /* CloseParenToken */, sourceFile); - case 145 /* FunctionType */: - case 146 /* ConstructorType */: + case 149 /* FunctionType */: + case 150 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 137 /* Constructor */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 203 /* FunctionDeclaration */: - case 165 /* FunctionExpression */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 141 /* ConstructSignature */: - case 140 /* CallSignature */: - case 166 /* ArrowFunction */: + case 141 /* Constructor */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 210 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 145 /* ConstructSignature */: + case 144 /* CallSignature */: + case 171 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -34759,63 +37156,63 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 17 /* CloseParenToken */, sourceFile); - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 186 /* IfStatement */: + case 193 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 185 /* ExpressionStatement */: + case 192 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile); - case 156 /* ArrayLiteralExpression */: - case 154 /* ArrayBindingPattern */: - case 159 /* ElementAccessExpression */: - case 129 /* ComputedPropertyName */: - case 150 /* TupleType */: + case 161 /* ArrayLiteralExpression */: + case 159 /* ArrayBindingPattern */: + case 164 /* ElementAccessExpression */: + case 133 /* ComputedPropertyName */: + case 154 /* TupleType */: return nodeEndsWith(n, 19 /* CloseBracketToken */, sourceFile); - case 142 /* IndexSignature */: + case 146 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 19 /* CloseBracketToken */, sourceFile); - case 223 /* CaseClause */: - case 224 /* DefaultClause */: + case 238 /* CaseClause */: + case 239 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicitly always consider them non-completed return false; - case 189 /* ForStatement */: - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: - case 188 /* WhileStatement */: + case 196 /* ForStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: + case 195 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 187 /* DoStatement */: + case 194 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - var hasWhileKeyword = findChildOfKind(n, 100 /* WhileKeyword */, sourceFile); + var hasWhileKeyword = findChildOfKind(n, 101 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 17 /* CloseParenToken */, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 147 /* TypeQuery */: + case 151 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 168 /* TypeOfExpression */: - case 167 /* DeleteExpression */: - case 169 /* VoidExpression */: - case 175 /* YieldExpression */: - case 176 /* SpreadElementExpression */: + case 173 /* TypeOfExpression */: + case 172 /* DeleteExpression */: + case 174 /* VoidExpression */: + case 181 /* YieldExpression */: + case 182 /* SpreadElementExpression */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 162 /* TaggedTemplateExpression */: + case 167 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 174 /* TemplateExpression */: + case 180 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 180 /* TemplateSpan */: + case 187 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 170 /* PrefixUnaryExpression */: + case 176 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 172 /* BinaryExpression */: + case 178 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 173 /* ConditionalExpression */: + case 179 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -34871,7 +37268,7 @@ var ts; // for the position of the relevant node (or comma). var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { // find syntax list that covers the span of the node - if (c.kind === 253 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 268 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -35005,7 +37402,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 230 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 245 /* SourceFile */); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. // Try to find the rightmost token in the file without filtering. @@ -35041,6 +37438,8 @@ var ts; result.push(ts.ScriptElementKindModifier.publicMemberModifier); if (flags & 128 /* Static */) result.push(ts.ScriptElementKindModifier.staticModifier); + if (flags & 256 /* Abstract */) + result.push(ts.ScriptElementKindModifier.abstractModifier); if (flags & 1 /* Export */) result.push(ts.ScriptElementKindModifier.exportedModifier); if (ts.isInAmbientContext(node)) @@ -35049,21 +37448,21 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 144 /* TypeReference */ || node.kind === 160 /* CallExpression */) { + if (node.kind === 148 /* TypeReference */ || node.kind === 165 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 204 /* ClassDeclaration */ || node.kind === 205 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 211 /* ClassDeclaration */ || node.kind === 212 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 127 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 131 /* LastToken */; } ts.isToken = isToken; function isWord(kind) { - return kind === 65 /* Identifier */ || ts.isKeyword(kind); + return kind === 66 /* Identifier */ || ts.isKeyword(kind); } ts.isWord = isWord; function isPropertyName(kind) { @@ -35074,7 +37473,7 @@ var ts; } ts.isComment = isComment; function isPunctuation(kind) { - return 14 /* FirstPunctuation */ <= kind && kind <= 64 /* LastPunctuation */; + return 14 /* FirstPunctuation */ <= kind && kind <= 65 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { @@ -35084,9 +37483,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 108 /* PublicKeyword */: - case 106 /* PrivateKeyword */: - case 107 /* ProtectedKeyword */: + case 109 /* PublicKeyword */: + case 107 /* PrivateKeyword */: + case 108 /* ProtectedKeyword */: return true; } return false; @@ -35114,7 +37513,7 @@ var ts; var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 131 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 135 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -35278,6 +37677,41 @@ var ts; }); } ts.signatureToDisplayParts = signatureToDisplayParts; + function getDeclaredName(typeChecker, symbol, location) { + // If this is an export or import specifier it could have been renamed using the 'as' syntax. + // If so we want to search for whatever is under the cursor. + if (isImportOrExportSpecifierName(location)) { + return location.getText(); + } + // Try to get the local symbol if we're dealing with an 'export default' + // since that symbol has the "true" name. + var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); + var name = typeChecker.symbolToString(localExportDefaultSymbol || symbol); + return name; + } + ts.getDeclaredName = getDeclaredName; + function isImportOrExportSpecifierName(location) { + return location.parent && + (location.parent.kind === 223 /* ImportSpecifier */ || location.parent.kind === 227 /* ExportSpecifier */) && + location.parent.propertyName === location; + } + ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; + /** + * Strip off existed single quotes or double quotes from a given string + * + * @return non-quoted string + */ + function stripQuotes(name) { + var length = name.length; + if (length >= 2 && + name.charCodeAt(0) === name.charCodeAt(length - 1) && + (name.charCodeAt(0) === 34 /* doubleQuote */ || name.charCodeAt(0) === 39 /* singleQuote */)) { + return name.substring(1, length - 1); + } + ; + return name; + } + ts.stripQuotes = stripQuotes; })(ts || (ts = {})); /// /// @@ -35356,11 +37790,11 @@ var ts; function shouldRescanGreaterThanToken(node) { if (node) { switch (node.kind) { - case 27 /* GreaterThanEqualsToken */: - case 60 /* GreaterThanGreaterThanEqualsToken */: - case 61 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 42 /* GreaterThanGreaterThanGreaterThanToken */: - case 41 /* GreaterThanGreaterThanToken */: + case 28 /* GreaterThanEqualsToken */: + case 61 /* GreaterThanGreaterThanEqualsToken */: + case 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 43 /* GreaterThanGreaterThanGreaterThanToken */: + case 42 /* GreaterThanGreaterThanToken */: return true; } } @@ -35374,7 +37808,7 @@ var ts; container.kind === 13 /* TemplateTail */; } function startsWithSlashToken(t) { - return t === 36 /* SlashToken */ || t === 57 /* SlashEqualsToken */; + return t === 37 /* SlashToken */ || t === 58 /* SlashEqualsToken */; } function readTokenInfo(n) { if (!isOnToken()) { @@ -35410,7 +37844,7 @@ var ts; scanner.scan(); } var currentToken = scanner.getToken(); - if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 25 /* GreaterThanToken */) { + if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 26 /* GreaterThanToken */) { currentToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === currentToken); lastScanAction = 1 /* RescanGreaterThanToken */; @@ -35742,17 +38176,17 @@ var ts; this.IgnoreAfterLineComment = new formatting.Rule(formatting.RuleDescriptor.create3(2 /* SingleLineCommentTrivia */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create1(1 /* Ignore */)); // Space after keyword but not before ; or : or ? this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 22 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 51 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 50 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(51 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); - this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(50 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); - this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(50 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 51 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); + this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(51 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); + this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(51 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Space after }. this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied - this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* CloseBraceToken */, 76 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* CloseBraceToken */, 100 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* CloseBraceToken */, 77 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* CloseBraceToken */, 101 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 19 /* CloseBracketToken */, 23 /* CommaToken */, 22 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // No space for indexer and dot this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); @@ -35765,10 +38199,10 @@ var ts; this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments; this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([65 /* Identifier */, 3 /* MultiLineCommentTrivia */]); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([66 /* Identifier */, 3 /* MultiLineCommentTrivia */]); this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a control flow construct - this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 75 /* DoKeyword */, 96 /* TryKeyword */, 81 /* FinallyKeyword */, 76 /* ElseKeyword */]); + this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 76 /* DoKeyword */, 97 /* TryKeyword */, 82 /* FinallyKeyword */, 77 /* ElseKeyword */]); this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(14 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); @@ -35782,71 +38216,71 @@ var ts; // Prefix operators generally shouldn't have a space between // them and their target unary expression. 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 /* Delete */)); - this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(38 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(39 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 38 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 39 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(39 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(40 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 39 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 40 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(38 /* PlusPlusToken */, 33 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(33 /* PlusToken */, 33 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(33 /* PlusToken */, 38 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(39 /* MinusMinusToken */, 34 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(34 /* MinusToken */, 34 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(34 /* MinusToken */, 39 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(39 /* PlusPlusToken */, 34 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(34 /* PlusToken */, 34 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(34 /* PlusToken */, 39 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(40 /* MinusMinusToken */, 35 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* MinusToken */, 35 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* MinusToken */, 40 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([98 /* VarKeyword */, 94 /* ThrowKeyword */, 88 /* NewKeyword */, 74 /* DeleteKeyword */, 90 /* ReturnKeyword */, 97 /* TypeOfKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([104 /* LetKeyword */, 70 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([99 /* VarKeyword */, 95 /* ThrowKeyword */, 89 /* NewKeyword */, 75 /* DeleteKeyword */, 91 /* ReturnKeyword */, 98 /* TypeOfKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([105 /* LetKeyword */, 71 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); - this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(83 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(84 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(99 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(90 /* ReturnKeyword */, 22 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(100 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(91 /* ReturnKeyword */, 22 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] - this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 75 /* DoKeyword */, 76 /* ElseKeyword */, 67 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2 /* Space */)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 76 /* DoKeyword */, 77 /* ElseKeyword */, 68 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2 /* Space */)); // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([96 /* TryKeyword */, 81 /* FinallyKeyword */]), 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([97 /* TryKeyword */, 82 /* FinallyKeyword */]), 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // get x() {} // set x(val) {} - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([116 /* GetKeyword */, 122 /* SetKeyword */]), 65 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([120 /* GetKeyword */, 126 /* SetKeyword */]), 66 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); // TypeScript-specific higher priority rules // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses - this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(114 /* ConstructorKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* ConstructorKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Use of module as a function call. e.g.: import m2 = module("m2"); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([118 /* ModuleKeyword */, 120 /* RequireKeyword */]), 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([122 /* ModuleKeyword */, 124 /* RequireKeyword */]), 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([69 /* ClassKeyword */, 115 /* DeclareKeyword */, 77 /* EnumKeyword */, 78 /* ExportKeyword */, 79 /* ExtendsKeyword */, 116 /* GetKeyword */, 102 /* ImplementsKeyword */, 85 /* ImportKeyword */, 103 /* InterfaceKeyword */, 118 /* ModuleKeyword */, 119 /* NamespaceKeyword */, 106 /* PrivateKeyword */, 108 /* PublicKeyword */, 122 /* SetKeyword */, 109 /* StaticKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([79 /* ExtendsKeyword */, 102 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112 /* AbstractKeyword */, 70 /* ClassKeyword */, 119 /* DeclareKeyword */, 74 /* DefaultKeyword */, 78 /* EnumKeyword */, 79 /* ExportKeyword */, 80 /* ExtendsKeyword */, 120 /* GetKeyword */, 103 /* ImplementsKeyword */, 86 /* ImportKeyword */, 104 /* InterfaceKeyword */, 122 /* ModuleKeyword */, 123 /* NamespaceKeyword */, 107 /* PrivateKeyword */, 109 /* PublicKeyword */, 108 /* ProtectedKeyword */, 126 /* SetKeyword */, 110 /* StaticKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([80 /* ExtendsKeyword */, 103 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(8 /* StringLiteral */, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); // Lambda expressions - this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(32 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(33 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Optional parameters and let args - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(21 /* DotDotDotToken */, 65 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(50 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 23 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(21 /* DotDotDotToken */, 66 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(51 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 23 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); // generics this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 24 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* CloseParenToken */, 24 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* LessThanToken */, formatting.Shared.TokenRange.TypeNames), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 25 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); - this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(25 /* GreaterThanToken */, formatting.Shared.TokenRange.FromTokens([16 /* OpenParenToken */, 18 /* OpenBracketToken */, 25 /* GreaterThanToken */, 23 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 26 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); + this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(26 /* GreaterThanToken */, formatting.Shared.TokenRange.FromTokens([16 /* OpenParenToken */, 18 /* OpenBracketToken */, 26 /* GreaterThanToken */, 23 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); // Remove spaces in empty interface literals. e.g.: x: {} this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(14 /* OpenBraceToken */, 15 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8 /* Delete */)); // decorators - this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([65 /* Identifier */, 78 /* ExportKeyword */, 73 /* DefaultKeyword */, 69 /* ClassKeyword */, 109 /* StaticKeyword */, 108 /* PublicKeyword */, 106 /* PrivateKeyword */, 107 /* ProtectedKeyword */, 116 /* GetKeyword */, 122 /* SetKeyword */, 18 /* OpenBracketToken */, 35 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); - this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(83 /* FunctionKeyword */, 35 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); - this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(35 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([65 /* Identifier */, 16 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); - this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(110 /* YieldKeyword */, 35 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); - this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([110 /* YieldKeyword */, 35 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([112 /* AbstractKeyword */, 66 /* Identifier */, 79 /* ExportKeyword */, 74 /* DefaultKeyword */, 70 /* ClassKeyword */, 110 /* StaticKeyword */, 109 /* PublicKeyword */, 107 /* PrivateKeyword */, 108 /* ProtectedKeyword */, 120 /* GetKeyword */, 126 /* SetKeyword */, 18 /* OpenBracketToken */, 36 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); + this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(84 /* FunctionKeyword */, 36 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); + this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(36 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([66 /* Identifier */, 16 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(111 /* YieldKeyword */, 36 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([111 /* YieldKeyword */, 36 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ @@ -35933,14 +38367,14 @@ var ts; this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Insert space after function keyword for anonymous functions - this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(83 /* FunctionKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); - this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(83 /* FunctionKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(84 /* FunctionKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(84 /* FunctionKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_26 in o) { - if (o[name_26] === rule) { - return name_26; + for (var name_30 in o) { + if (o[name_30] === rule) { + return name_30; } } throw new Error("Unknown rule"); @@ -35949,37 +38383,38 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 189 /* ForStatement */; + return context.contextNode.kind === 196 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 172 /* BinaryExpression */: - case 173 /* ConditionalExpression */: - case 143 /* TypePredicate */: + case 178 /* BinaryExpression */: + case 179 /* ConditionalExpression */: + case 186 /* AsExpression */: + case 147 /* TypePredicate */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 155 /* BindingElement */: + case 160 /* BindingElement */: // equals in type X = ... - case 206 /* TypeAliasDeclaration */: + case 213 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 211 /* ImportEqualsDeclaration */: + case 218 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 201 /* VariableDeclaration */: + case 208 /* VariableDeclaration */: // equal in p = 0; - case 131 /* Parameter */: - case 229 /* EnumMember */: - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: - return context.currentTokenSpan.kind === 53 /* EqualsToken */ || context.nextTokenSpan.kind === 53 /* EqualsToken */; + case 135 /* Parameter */: + case 244 /* EnumMember */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: + return context.currentTokenSpan.kind === 54 /* EqualsToken */ || context.nextTokenSpan.kind === 54 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 190 /* ForInStatement */: - return context.currentTokenSpan.kind === 86 /* InKeyword */ || context.nextTokenSpan.kind === 86 /* InKeyword */; + case 197 /* ForInStatement */: + return context.currentTokenSpan.kind === 87 /* InKeyword */ || context.nextTokenSpan.kind === 87 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 191 /* ForOfStatement */: - return context.currentTokenSpan.kind === 127 /* OfKeyword */ || context.nextTokenSpan.kind === 127 /* OfKeyword */; + case 198 /* ForOfStatement */: + return context.currentTokenSpan.kind === 131 /* OfKeyword */ || context.nextTokenSpan.kind === 131 /* OfKeyword */; } return false; }; @@ -35987,7 +38422,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 173 /* ConditionalExpression */; + return context.contextNode.kind === 179 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -36031,92 +38466,92 @@ var ts; return true; } switch (node.kind) { - case 182 /* Block */: - case 210 /* CaseBlock */: - case 157 /* ObjectLiteralExpression */: - case 209 /* ModuleBlock */: + case 189 /* Block */: + case 217 /* CaseBlock */: + case 162 /* ObjectLiteralExpression */: + case 216 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 203 /* FunctionDeclaration */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 210 /* FunctionDeclaration */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: //case SyntaxKind.MemberFunctionDeclaration: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: ///case SyntaxKind.MethodSignature: - case 140 /* CallSignature */: - case 165 /* FunctionExpression */: - case 137 /* Constructor */: - case 166 /* ArrowFunction */: + case 144 /* CallSignature */: + case 170 /* FunctionExpression */: + case 141 /* Constructor */: + case 171 /* ArrowFunction */: //case SyntaxKind.ConstructorDeclaration: //case SyntaxKind.SimpleArrowFunctionExpression: //case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 205 /* InterfaceDeclaration */: + case 212 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 203 /* FunctionDeclaration */ || context.contextNode.kind === 165 /* FunctionExpression */; + return context.contextNode.kind === 210 /* FunctionDeclaration */ || context.contextNode.kind === 170 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 204 /* ClassDeclaration */: - case 205 /* InterfaceDeclaration */: - case 207 /* EnumDeclaration */: - case 148 /* TypeLiteral */: - case 208 /* ModuleDeclaration */: + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: + case 214 /* EnumDeclaration */: + case 152 /* TypeLiteral */: + case 215 /* ModuleDeclaration */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 204 /* ClassDeclaration */: - case 208 /* ModuleDeclaration */: - case 207 /* EnumDeclaration */: - case 182 /* Block */: - case 226 /* CatchClause */: - case 209 /* ModuleBlock */: - case 196 /* SwitchStatement */: + case 211 /* ClassDeclaration */: + case 215 /* ModuleDeclaration */: + case 214 /* EnumDeclaration */: + case 189 /* Block */: + case 241 /* CatchClause */: + case 216 /* ModuleBlock */: + case 203 /* SwitchStatement */: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 186 /* IfStatement */: - case 196 /* SwitchStatement */: - case 189 /* ForStatement */: - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: - case 188 /* WhileStatement */: - case 199 /* TryStatement */: - case 187 /* DoStatement */: - case 195 /* WithStatement */: + case 193 /* IfStatement */: + case 203 /* SwitchStatement */: + case 196 /* ForStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: + case 195 /* WhileStatement */: + case 206 /* TryStatement */: + case 194 /* DoStatement */: + case 202 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 226 /* CatchClause */: + case 241 /* CatchClause */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 157 /* ObjectLiteralExpression */; + return context.contextNode.kind === 162 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 160 /* CallExpression */; + return context.contextNode.kind === 165 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 161 /* NewExpression */; + return context.contextNode.kind === 166 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -36140,38 +38575,38 @@ var ts; while (ts.isExpression(node)) { node = node.parent; } - return node.kind === 132 /* Decorator */; + return node.kind === 136 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 202 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 209 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 208 /* ModuleDeclaration */; + return context.contextNode.kind === 215 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 148 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 152 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; }; Rules.IsTypeArgumentOrParameter = function (token, parent) { - if (token.kind !== 24 /* LessThanToken */ && token.kind !== 25 /* GreaterThanToken */) { + if (token.kind !== 24 /* LessThanToken */ && token.kind !== 26 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 144 /* TypeReference */: - case 204 /* ClassDeclaration */: - case 205 /* InterfaceDeclaration */: - case 203 /* FunctionDeclaration */: - case 165 /* FunctionExpression */: - case 166 /* ArrowFunction */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 140 /* CallSignature */: - case 141 /* ConstructSignature */: - case 160 /* CallExpression */: - case 161 /* NewExpression */: + case 148 /* TypeReference */: + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: + case 210 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 144 /* CallSignature */: + case 145 /* ConstructSignature */: + case 165 /* CallExpression */: + case 166 /* NewExpression */: return true; default: return false; @@ -36182,10 +38617,10 @@ var ts; Rules.IsTypeArgumentOrParameter(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 99 /* VoidKeyword */ && context.currentTokenParent.kind === 169 /* VoidExpression */; + return context.currentTokenSpan.kind === 100 /* VoidKeyword */ && context.currentTokenParent.kind === 174 /* VoidExpression */; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 175 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 181 /* YieldExpression */ && context.contextNode.expression !== undefined; }; return Rules; })(); @@ -36209,7 +38644,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 127 /* LastToken */ + 1; + this.mapRowLength = 131 /* LastToken */ + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); //new Array(this.mapRowLength * this.mapRowLength); // This array is used only during construction of the rulesbucket in the map var rulesBucketConstructionStateList = new Array(this.map.length); //new Array(this.map.length); @@ -36404,7 +38839,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0 /* FirstToken */; token <= 127 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 131 /* LastToken */; token++) { result.push(token); } return result; @@ -36446,17 +38881,17 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(66 /* FirstKeyword */, 127 /* LastKeyword */); - TokenRange.BinaryOperators = TokenRange.FromRange(24 /* FirstBinaryOperator */, 64 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([86 /* InKeyword */, 87 /* InstanceOfKeyword */, 127 /* OfKeyword */, 117 /* IsKeyword */]); - TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([38 /* PlusPlusToken */, 39 /* MinusMinusToken */, 47 /* TildeToken */, 46 /* ExclamationToken */]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([7 /* NumericLiteral */, 65 /* Identifier */, 16 /* OpenParenToken */, 18 /* OpenBracketToken */, 14 /* OpenBraceToken */, 93 /* ThisKeyword */, 88 /* NewKeyword */]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([65 /* Identifier */, 16 /* OpenParenToken */, 93 /* ThisKeyword */, 88 /* NewKeyword */]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([65 /* Identifier */, 17 /* CloseParenToken */, 19 /* CloseBracketToken */, 88 /* NewKeyword */]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([65 /* Identifier */, 16 /* OpenParenToken */, 93 /* ThisKeyword */, 88 /* NewKeyword */]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([65 /* Identifier */, 17 /* CloseParenToken */, 19 /* CloseBracketToken */, 88 /* NewKeyword */]); + TokenRange.Keywords = TokenRange.FromRange(67 /* FirstKeyword */, 131 /* LastKeyword */); + TokenRange.BinaryOperators = TokenRange.FromRange(24 /* FirstBinaryOperator */, 65 /* LastBinaryOperator */); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([87 /* InKeyword */, 88 /* InstanceOfKeyword */, 131 /* OfKeyword */, 113 /* AsKeyword */, 121 /* IsKeyword */]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([39 /* PlusPlusToken */, 40 /* MinusMinusToken */, 48 /* TildeToken */, 47 /* ExclamationToken */]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([7 /* NumericLiteral */, 66 /* Identifier */, 16 /* OpenParenToken */, 18 /* OpenBracketToken */, 14 /* OpenBraceToken */, 94 /* ThisKeyword */, 89 /* NewKeyword */]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([66 /* Identifier */, 16 /* OpenParenToken */, 94 /* ThisKeyword */, 89 /* NewKeyword */]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([66 /* Identifier */, 17 /* CloseParenToken */, 19 /* CloseBracketToken */, 89 /* NewKeyword */]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([66 /* Identifier */, 16 /* OpenParenToken */, 94 /* ThisKeyword */, 89 /* NewKeyword */]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([66 /* Identifier */, 17 /* CloseParenToken */, 19 /* CloseBracketToken */, 89 /* NewKeyword */]); TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([65 /* Identifier */, 121 /* NumberKeyword */, 123 /* StringKeyword */, 113 /* BooleanKeyword */, 124 /* SymbolKeyword */, 99 /* VoidKeyword */, 112 /* AnyKeyword */]); + TokenRange.TypeNames = TokenRange.FromTokens([66 /* Identifier */, 125 /* NumberKeyword */, 127 /* StringKeyword */, 117 /* BooleanKeyword */, 128 /* SymbolKeyword */, 100 /* VoidKeyword */, 114 /* AnyKeyword */]); return TokenRange; })(); Shared.TokenRange = TokenRange; @@ -36660,17 +39095,17 @@ var ts; // i.e. parent is class declaration with the list of members and node is one of members. function isListElement(parent, node) { switch (parent.kind) { - case 204 /* ClassDeclaration */: - case 205 /* InterfaceDeclaration */: + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 182 /* Block */ && ts.rangeContainsRange(body.statements, node); - case 230 /* SourceFile */: - case 182 /* Block */: - case 209 /* ModuleBlock */: + return body && body.kind === 189 /* Block */ && ts.rangeContainsRange(body.statements, node); + case 245 /* SourceFile */: + case 189 /* Block */: + case 216 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 226 /* CatchClause */: + case 241 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -36843,9 +39278,9 @@ var ts; // - source file // - switch\default clauses if (isSomeBlock(parent.kind) || - parent.kind === 230 /* SourceFile */ || - parent.kind === 223 /* CaseClause */ || - parent.kind === 224 /* DefaultClause */) { + parent.kind === 245 /* SourceFile */ || + parent.kind === 238 /* CaseClause */ || + parent.kind === 239 /* DefaultClause */) { indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } else { @@ -36881,19 +39316,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 204 /* ClassDeclaration */: return 69 /* ClassKeyword */; - case 205 /* InterfaceDeclaration */: return 103 /* InterfaceKeyword */; - case 203 /* FunctionDeclaration */: return 83 /* FunctionKeyword */; - case 207 /* EnumDeclaration */: return 207 /* EnumDeclaration */; - case 138 /* GetAccessor */: return 116 /* GetKeyword */; - case 139 /* SetAccessor */: return 122 /* SetKeyword */; - case 136 /* MethodDeclaration */: + case 211 /* ClassDeclaration */: return 70 /* ClassKeyword */; + case 212 /* InterfaceDeclaration */: return 104 /* InterfaceKeyword */; + case 210 /* FunctionDeclaration */: return 84 /* FunctionKeyword */; + case 214 /* EnumDeclaration */: return 214 /* EnumDeclaration */; + case 142 /* GetAccessor */: return 120 /* GetKeyword */; + case 143 /* SetAccessor */: return 126 /* SetKeyword */; + case 140 /* MethodDeclaration */: if (node.asteriskToken) { - return 35 /* AsteriskToken */; + return 36 /* AsteriskToken */; } // fall-through - case 134 /* PropertyDeclaration */: - case 131 /* Parameter */: + case 138 /* PropertyDeclaration */: + case 135 /* Parameter */: return node.name.kind; } } @@ -36924,9 +39359,9 @@ var ts; case 15 /* CloseBraceToken */: case 18 /* OpenBracketToken */: case 19 /* CloseBracketToken */: - case 76 /* ElseKeyword */: - case 100 /* WhileKeyword */: - case 52 /* AtToken */: + case 77 /* ElseKeyword */: + case 101 /* WhileKeyword */: + case 53 /* AtToken */: return indentation; default: // if token line equals to the line of containing node (this is a first token in the node) - use node indentation @@ -37026,7 +39461,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 132 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 136 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; @@ -37349,20 +39784,20 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 182 /* Block */: - case 209 /* ModuleBlock */: + case 189 /* Block */: + case 216 /* ModuleBlock */: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 137 /* Constructor */: - case 203 /* FunctionDeclaration */: - case 165 /* FunctionExpression */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 166 /* ArrowFunction */: + case 141 /* Constructor */: + case 210 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 171 /* ArrowFunction */: if (node.typeParameters === list) { return 24 /* LessThanToken */; } @@ -37370,8 +39805,8 @@ var ts; return 16 /* OpenParenToken */; } break; - case 160 /* CallExpression */: - case 161 /* NewExpression */: + case 165 /* CallExpression */: + case 166 /* NewExpression */: if (node.typeArguments === list) { return 24 /* LessThanToken */; } @@ -37379,7 +39814,7 @@ var ts; return 16 /* OpenParenToken */; } break; - case 144 /* TypeReference */: + case 148 /* TypeReference */: if (node.typeArguments === list) { return 24 /* LessThanToken */; } @@ -37391,7 +39826,7 @@ var ts; case 16 /* OpenParenToken */: return 17 /* CloseParenToken */; case 24 /* LessThanToken */: - return 25 /* GreaterThanToken */; + return 26 /* GreaterThanToken */; } return 0 /* Unknown */; } @@ -37478,7 +39913,7 @@ var ts; return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (precedingToken.kind === 23 /* CommaToken */ && precedingToken.parent.kind !== 172 /* BinaryExpression */) { + if (precedingToken.kind === 23 /* CommaToken */ && precedingToken.parent.kind !== 178 /* BinaryExpression */) { // previous token is comma that separates items in list - find the previous item and try to derive indentation from it var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1 /* Unknown */) { @@ -37597,7 +40032,7 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && - (parent.kind === 230 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 245 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -37630,8 +40065,8 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 186 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 76 /* ElseKeyword */, sourceFile); + if (parent.kind === 193 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 77 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -37642,23 +40077,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 144 /* TypeReference */: + case 148 /* TypeReference */: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 157 /* ObjectLiteralExpression */: + case 162 /* ObjectLiteralExpression */: return node.parent.properties; - case 156 /* ArrayLiteralExpression */: + case 161 /* ArrayLiteralExpression */: return node.parent.elements; - case 203 /* FunctionDeclaration */: - case 165 /* FunctionExpression */: - case 166 /* ArrowFunction */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 140 /* CallSignature */: - case 141 /* ConstructSignature */: { + case 210 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 144 /* CallSignature */: + case 145 /* ConstructSignature */: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -37669,8 +40104,8 @@ var ts; } break; } - case 161 /* NewExpression */: - case 160 /* CallExpression */: { + case 166 /* NewExpression */: + case 165 /* CallExpression */: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -37700,8 +40135,8 @@ var ts; if (node.kind === 17 /* CloseParenToken */) { return -1 /* Unknown */; } - if (node.parent && (node.parent.kind === 160 /* CallExpression */ || - node.parent.kind === 161 /* NewExpression */) && + if (node.parent && (node.parent.kind === 165 /* CallExpression */ || + node.parent.kind === 166 /* NewExpression */) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -37719,10 +40154,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 160 /* CallExpression */: - case 161 /* NewExpression */: - case 158 /* PropertyAccessExpression */: - case 159 /* ElementAccessExpression */: + case 165 /* CallExpression */: + case 166 /* NewExpression */: + case 163 /* PropertyAccessExpression */: + case 164 /* ElementAccessExpression */: node = node.expression; break; default: @@ -37787,28 +40222,28 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 204 /* ClassDeclaration */: - case 205 /* InterfaceDeclaration */: - case 207 /* EnumDeclaration */: - case 156 /* ArrayLiteralExpression */: - case 182 /* Block */: - case 209 /* ModuleBlock */: - case 157 /* ObjectLiteralExpression */: - case 148 /* TypeLiteral */: - case 150 /* TupleType */: - case 210 /* CaseBlock */: - case 224 /* DefaultClause */: - case 223 /* CaseClause */: - case 164 /* ParenthesizedExpression */: - case 160 /* CallExpression */: - case 161 /* NewExpression */: - case 183 /* VariableStatement */: - case 201 /* VariableDeclaration */: - case 217 /* ExportAssignment */: - case 194 /* ReturnStatement */: - case 173 /* ConditionalExpression */: - case 154 /* ArrayBindingPattern */: - case 153 /* ObjectBindingPattern */: + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: + case 214 /* EnumDeclaration */: + case 161 /* ArrayLiteralExpression */: + case 189 /* Block */: + case 216 /* ModuleBlock */: + case 162 /* ObjectLiteralExpression */: + case 152 /* TypeLiteral */: + case 154 /* TupleType */: + case 217 /* CaseBlock */: + case 239 /* DefaultClause */: + case 238 /* CaseClause */: + case 169 /* ParenthesizedExpression */: + case 165 /* CallExpression */: + case 166 /* NewExpression */: + case 190 /* VariableStatement */: + case 208 /* VariableDeclaration */: + case 224 /* ExportAssignment */: + case 201 /* ReturnStatement */: + case 179 /* ConditionalExpression */: + case 159 /* ArrayBindingPattern */: + case 158 /* ObjectBindingPattern */: return true; } return false; @@ -37818,22 +40253,22 @@ var ts; return true; } switch (parent) { - case 187 /* DoStatement */: - case 188 /* WhileStatement */: - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: - case 189 /* ForStatement */: - case 186 /* IfStatement */: - case 203 /* FunctionDeclaration */: - case 165 /* FunctionExpression */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 140 /* CallSignature */: - case 166 /* ArrowFunction */: - case 137 /* Constructor */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - return child !== 182 /* Block */; + case 194 /* DoStatement */: + case 195 /* WhileStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: + case 196 /* ForStatement */: + case 193 /* IfStatement */: + case 210 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 144 /* CallSignature */: + case 171 /* ArrowFunction */: + case 141 /* Constructor */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + return child !== 189 /* Block */; default: return false; } @@ -37866,7 +40301,6 @@ var ts; var StringScriptSnapshot = (function () { function StringScriptSnapshot(text) { this.text = text; - this._lineStartPositions = undefined; } StringScriptSnapshot.prototype.getText = function (start, end) { return this.text.substring(start, end); @@ -37931,13 +40365,13 @@ var ts; while (pos < end) { var token = scanner.scan(); var textPos = scanner.getTextPos(); - nodes.push(createNode(token, pos, textPos, 1024 /* Synthetic */, this)); + nodes.push(createNode(token, pos, textPos, 4096 /* Synthetic */, this)); pos = textPos; } return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(253 /* SyntaxList */, nodes.pos, nodes.end, 1024 /* Synthetic */, this); + var list = createNode(268 /* SyntaxList */, nodes.pos, nodes.end, 4096 /* Synthetic */, this); list._children = []; var pos = nodes.pos; for (var _i = 0; _i < nodes.length; _i++) { @@ -37956,7 +40390,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 128 /* FirstNode */) { + if (this.kind >= 132 /* FirstNode */) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos = this.pos; @@ -38001,7 +40435,7 @@ var ts; var children = this.getChildren(); for (var _i = 0; _i < children.length; _i++) { var child = children[_i]; - if (child.kind < 128 /* FirstNode */) { + if (child.kind < 132 /* FirstNode */) { return child; } return child.getFirstToken(sourceFile); @@ -38011,7 +40445,7 @@ var ts; var children = this.getChildren(sourceFile); for (var i = children.length - 1; i >= 0; i--) { var child = children[i]; - if (child.kind < 128 /* FirstNode */) { + if (child.kind < 132 /* FirstNode */) { return child; } return child.getLastToken(sourceFile); @@ -38064,27 +40498,27 @@ var ts; if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); // If it is parameter - try and get the jsDoc comment with @param tag from function declaration's jsDoc comments - if (canUseParsedParamTagComments && declaration.kind === 131 /* Parameter */) { + if (canUseParsedParamTagComments && declaration.kind === 135 /* Parameter */) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { - jsDocCommentParts.push.apply(jsDocCommentParts, cleanedParamJsDocComment); + ts.addRange(jsDocCommentParts, cleanedParamJsDocComment); } }); } // If this is left side of dotted module declaration, there is no doc comments associated with this node - if (declaration.kind === 208 /* ModuleDeclaration */ && declaration.body.kind === 208 /* ModuleDeclaration */) { + if (declaration.kind === 215 /* ModuleDeclaration */ && declaration.body.kind === 215 /* ModuleDeclaration */) { return; } // If this is dotted module name, get the doc comments from the parent - while (declaration.kind === 208 /* ModuleDeclaration */ && declaration.parent.kind === 208 /* ModuleDeclaration */) { + while (declaration.kind === 215 /* ModuleDeclaration */ && declaration.parent.kind === 215 /* ModuleDeclaration */) { declaration = declaration.parent; } // Get the cleaned js doc comment text from the declaration - ts.forEach(getJsDocCommentTextRange(declaration.kind === 201 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 208 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { - jsDocCommentParts.push.apply(jsDocCommentParts, cleanedJsDocComment); + ts.addRange(jsDocCommentParts, cleanedJsDocComment); } }); } @@ -38420,9 +40854,9 @@ var ts; if (result_2 !== undefined) { return result_2; } - if (declaration.name.kind === 129 /* ComputedPropertyName */) { + if (declaration.name.kind === 133 /* ComputedPropertyName */) { var expr = declaration.name.expression; - if (expr.kind === 158 /* PropertyAccessExpression */) { + if (expr.kind === 163 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -38432,7 +40866,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 65 /* Identifier */ || + if (node.kind === 66 /* Identifier */ || node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) { return node.text; @@ -38442,9 +40876,9 @@ var ts; } function visit(node) { switch (node.kind) { - case 203 /* FunctionDeclaration */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 210 /* FunctionDeclaration */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -38464,60 +40898,60 @@ var ts; ts.forEachChild(node, visit); } break; - case 204 /* ClassDeclaration */: - case 205 /* InterfaceDeclaration */: - case 206 /* TypeAliasDeclaration */: - case 207 /* EnumDeclaration */: - case 208 /* ModuleDeclaration */: - case 211 /* ImportEqualsDeclaration */: - case 220 /* ExportSpecifier */: - case 216 /* ImportSpecifier */: - case 211 /* ImportEqualsDeclaration */: - case 213 /* ImportClause */: - case 214 /* NamespaceImport */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 148 /* TypeLiteral */: + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: + case 213 /* TypeAliasDeclaration */: + case 214 /* EnumDeclaration */: + case 215 /* ModuleDeclaration */: + case 218 /* ImportEqualsDeclaration */: + case 227 /* ExportSpecifier */: + case 223 /* ImportSpecifier */: + case 218 /* ImportEqualsDeclaration */: + case 220 /* ImportClause */: + case 221 /* NamespaceImport */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 152 /* TypeLiteral */: addDeclaration(node); // fall through - case 137 /* Constructor */: - case 183 /* VariableStatement */: - case 202 /* VariableDeclarationList */: - case 153 /* ObjectBindingPattern */: - case 154 /* ArrayBindingPattern */: - case 209 /* ModuleBlock */: + case 141 /* Constructor */: + case 190 /* VariableStatement */: + case 209 /* VariableDeclarationList */: + case 158 /* ObjectBindingPattern */: + case 159 /* ArrayBindingPattern */: + case 216 /* ModuleBlock */: ts.forEachChild(node, visit); break; - case 182 /* Block */: + case 189 /* Block */: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 131 /* Parameter */: + case 135 /* Parameter */: // Only consider properties defined as constructor parameters if (!(node.flags & 112 /* AccessibilityModifier */)) { break; } // fall through - case 201 /* VariableDeclaration */: - case 155 /* BindingElement */: + case 208 /* VariableDeclaration */: + case 160 /* BindingElement */: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 229 /* EnumMember */: - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: + case 244 /* EnumMember */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: addDeclaration(node); break; - case 218 /* ExportDeclaration */: + case 225 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 212 /* ImportDeclaration */: + case 219 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -38529,7 +40963,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 214 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 221 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -38622,6 +41056,8 @@ var ts; ScriptElementKind.moduleElement = "module"; // class X {} ScriptElementKind.classElement = "class"; + // var x = class X {} + ScriptElementKind.localClassElement = "local class"; // interface Y {} ScriptElementKind.interfaceElement = "interface"; // type T = ... @@ -38672,6 +41108,7 @@ var ts; ScriptElementKindModifier.exportedModifier = "export"; ScriptElementKindModifier.ambientModifier = "declare"; ScriptElementKindModifier.staticModifier = "static"; + ScriptElementKindModifier.abstractModifier = "abstract"; })(ScriptElementKindModifier = ts.ScriptElementKindModifier || (ts.ScriptElementKindModifier = {})); var ClassificationTypeNames = (function () { function ClassificationTypeNames() { @@ -38730,16 +41167,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 165 /* FunctionExpression */) { + if (declaration.kind === 170 /* FunctionExpression */) { return true; } - if (declaration.kind !== 201 /* VariableDeclaration */ && declaration.kind !== 203 /* FunctionDeclaration */) { + if (declaration.kind !== 208 /* VariableDeclaration */ && declaration.kind !== 210 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable for (var parent_9 = declaration.parent; !ts.isFunctionBlock(parent_9); parent_9 = parent_9.parent) { // Reached source file or module block - if (parent_9.kind === 230 /* SourceFile */ || parent_9.kind === 209 /* ModuleBlock */) { + if (parent_9.kind === 245 /* SourceFile */ || parent_9.kind === 216 /* ModuleBlock */) { return false; } } @@ -38751,32 +41188,11 @@ var ts; // Always default to "ScriptTarget.ES5" for the language service return { target: 1 /* ES5 */, - module: 0 /* None */ + module: 0 /* None */, + jsx: 1 /* Preserve */ }; } ts.getDefaultCompilerOptions = getDefaultCompilerOptions; - var OperationCanceledException = (function () { - function OperationCanceledException() { - } - return OperationCanceledException; - })(); - ts.OperationCanceledException = OperationCanceledException; - var CancellationTokenObject = (function () { - function CancellationTokenObject(cancellationToken) { - this.cancellationToken = cancellationToken; - } - CancellationTokenObject.prototype.isCancellationRequested = function () { - return this.cancellationToken && this.cancellationToken.isCancellationRequested(); - }; - CancellationTokenObject.prototype.throwIfCancellationRequested = function () { - if (this.isCancellationRequested()) { - throw new OperationCanceledException(); - } - }; - CancellationTokenObject.None = new CancellationTokenObject(null); - return CancellationTokenObject; - })(); - ts.CancellationTokenObject = CancellationTokenObject; // Cache host information about scrip Should be refreshed // at each language service public entry point, since we don't know when // set of scripts handled by the host changes. @@ -39120,7 +41536,7 @@ var ts; // export * from "mod" // export {a as b} from "mod" while (token !== 1 /* EndOfFileToken */) { - if (token === 85 /* ImportKeyword */) { + if (token === 86 /* ImportKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // import "mod"; @@ -39128,9 +41544,9 @@ var ts; continue; } else { - if (token === 65 /* Identifier */) { + if (token === 66 /* Identifier */) { token = scanner.scan(); - if (token === 126 /* FromKeyword */) { + if (token === 130 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // import d from "mod"; @@ -39138,9 +41554,9 @@ var ts; continue; } } - else if (token === 53 /* EqualsToken */) { + else if (token === 54 /* EqualsToken */) { token = scanner.scan(); - if (token === 120 /* RequireKeyword */) { + if (token === 124 /* RequireKeyword */) { token = scanner.scan(); if (token === 16 /* OpenParenToken */) { token = scanner.scan(); @@ -39169,7 +41585,7 @@ var ts; } if (token === 15 /* CloseBraceToken */) { token = scanner.scan(); - if (token === 126 /* FromKeyword */) { + if (token === 130 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // import {a as A} from "mod"; @@ -39179,13 +41595,13 @@ var ts; } } } - else if (token === 35 /* AsteriskToken */) { + else if (token === 36 /* AsteriskToken */) { token = scanner.scan(); - if (token === 111 /* AsKeyword */) { + if (token === 113 /* AsKeyword */) { token = scanner.scan(); - if (token === 65 /* Identifier */) { + if (token === 66 /* Identifier */) { token = scanner.scan(); - if (token === 126 /* FromKeyword */) { + if (token === 130 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // import * as NS from "mod" @@ -39198,7 +41614,7 @@ var ts; } } } - else if (token === 78 /* ExportKeyword */) { + else if (token === 79 /* ExportKeyword */) { token = scanner.scan(); if (token === 14 /* OpenBraceToken */) { token = scanner.scan(); @@ -39208,7 +41624,7 @@ var ts; } if (token === 15 /* CloseBraceToken */) { token = scanner.scan(); - if (token === 126 /* FromKeyword */) { + if (token === 130 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // export {a as A} from "mod"; @@ -39218,9 +41634,9 @@ var ts; } } } - else if (token === 35 /* AsteriskToken */) { + else if (token === 36 /* AsteriskToken */) { token = scanner.scan(); - if (token === 126 /* FromKeyword */) { + if (token === 130 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // export * from "mod" @@ -39243,7 +41659,7 @@ var ts; /// Helpers function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 197 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 204 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -39251,13 +41667,13 @@ var ts; return undefined; } function isJumpStatementTarget(node) { - return node.kind === 65 /* Identifier */ && - (node.parent.kind === 193 /* BreakStatement */ || node.parent.kind === 192 /* ContinueStatement */) && + return node.kind === 66 /* Identifier */ && + (node.parent.kind === 200 /* BreakStatement */ || node.parent.kind === 199 /* ContinueStatement */) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { - return node.kind === 65 /* Identifier */ && - node.parent.kind === 197 /* LabeledStatement */ && + return node.kind === 66 /* Identifier */ && + node.parent.kind === 204 /* LabeledStatement */ && node.parent.label === node; } /** @@ -39265,7 +41681,7 @@ var ts; * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 197 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 204 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -39276,49 +41692,49 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 128 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 132 /* QualifiedName */ && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 158 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 163 /* PropertyAccessExpression */ && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 160 /* CallExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 165 /* CallExpression */ && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 161 /* NewExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 166 /* NewExpression */ && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 208 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 215 /* ModuleDeclaration */ && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { - return node.kind === 65 /* Identifier */ && + return node.kind === 66 /* Identifier */ && ts.isFunctionLike(node.parent) && node.parent.name === node; } /** Returns true if node is a name of an object literal property, e.g. "a" in x = { "a": 1 } */ function isNameOfPropertyAssignment(node) { - return (node.kind === 65 /* Identifier */ || node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) && - (node.parent.kind === 227 /* PropertyAssignment */ || node.parent.kind === 228 /* ShorthandPropertyAssignment */) && node.parent.name === node; + return (node.kind === 66 /* Identifier */ || node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) && + (node.parent.kind === 242 /* PropertyAssignment */ || node.parent.kind === 243 /* ShorthandPropertyAssignment */) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) { switch (node.parent.kind) { - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: - case 227 /* PropertyAssignment */: - case 229 /* EnumMember */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 208 /* ModuleDeclaration */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: + case 242 /* PropertyAssignment */: + case 244 /* EnumMember */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 215 /* ModuleDeclaration */: return node.parent.name === node; - case 159 /* ElementAccessExpression */: + case 164 /* ElementAccessExpression */: return node.parent.argumentExpression === node; } } @@ -39377,7 +41793,7 @@ var ts; })(BreakContinueSearchType || (BreakContinueSearchType = {})); // A cache of completion entries for keywords, these do not change between sessions var keywordCompletions = []; - for (var i = 66 /* FirstKeyword */; i <= 127 /* LastKeyword */; i++) { + for (var i = 67 /* FirstKeyword */; i <= 131 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -39392,17 +41808,17 @@ var ts; return undefined; } switch (node.kind) { - case 230 /* SourceFile */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 203 /* FunctionDeclaration */: - case 165 /* FunctionExpression */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 204 /* ClassDeclaration */: - case 205 /* InterfaceDeclaration */: - case 207 /* EnumDeclaration */: - case 208 /* ModuleDeclaration */: + case 245 /* SourceFile */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 210 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: + case 214 /* EnumDeclaration */: + case 215 /* ModuleDeclaration */: return node; } } @@ -39410,43 +41826,57 @@ var ts; ts.getContainerNode = getContainerNode; /* @internal */ function getNodeKind(node) { switch (node.kind) { - case 208 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; - case 204 /* ClassDeclaration */: return ScriptElementKind.classElement; - case 205 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; - case 206 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; - case 207 /* EnumDeclaration */: return ScriptElementKind.enumElement; - case 201 /* VariableDeclaration */: + case 215 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; + case 211 /* ClassDeclaration */: return ScriptElementKind.classElement; + case 212 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; + case 213 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; + case 214 /* EnumDeclaration */: return ScriptElementKind.enumElement; + case 208 /* VariableDeclaration */: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 203 /* FunctionDeclaration */: return ScriptElementKind.functionElement; - case 138 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; - case 139 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 210 /* FunctionDeclaration */: return ScriptElementKind.functionElement; + case 142 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; + case 143 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: return ScriptElementKind.memberFunctionElement; - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: return ScriptElementKind.memberVariableElement; - case 142 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; - case 141 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; - case 140 /* CallSignature */: return ScriptElementKind.callSignatureElement; - case 137 /* Constructor */: return ScriptElementKind.constructorImplementationElement; - case 130 /* TypeParameter */: return ScriptElementKind.typeParameterElement; - case 229 /* EnumMember */: return ScriptElementKind.variableElement; - case 131 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 211 /* ImportEqualsDeclaration */: - case 216 /* ImportSpecifier */: - case 213 /* ImportClause */: - case 220 /* ExportSpecifier */: - case 214 /* NamespaceImport */: + case 146 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; + case 145 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; + case 144 /* CallSignature */: return ScriptElementKind.callSignatureElement; + case 141 /* Constructor */: return ScriptElementKind.constructorImplementationElement; + case 134 /* TypeParameter */: return ScriptElementKind.typeParameterElement; + case 244 /* EnumMember */: return ScriptElementKind.variableElement; + case 135 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 218 /* ImportEqualsDeclaration */: + case 223 /* ImportSpecifier */: + case 220 /* ImportClause */: + case 227 /* ExportSpecifier */: + case 221 /* NamespaceImport */: return ScriptElementKind.alias; } return ScriptElementKind.unknown; } ts.getNodeKind = getNodeKind; + var CancellationTokenObject = (function () { + function CancellationTokenObject(cancellationToken) { + this.cancellationToken = cancellationToken; + } + CancellationTokenObject.prototype.isCancellationRequested = function () { + return this.cancellationToken && this.cancellationToken.isCancellationRequested(); + }; + CancellationTokenObject.prototype.throwIfCancellationRequested = function () { + if (this.isCancellationRequested()) { + throw new ts.OperationCanceledException(); + } + }; + return CancellationTokenObject; + })(); function createLanguageService(host, documentRegistry) { if (documentRegistry === void 0) { documentRegistry = createDocumentRegistry(); } var syntaxTreeCache = new SyntaxTreeCache(host); @@ -39621,7 +42051,7 @@ var ts; /// Diagnostics function getSyntacticDiagnostics(fileName) { synchronizeHostData(); - return program.getSyntacticDiagnostics(getValidSourceFile(fileName)); + return program.getSyntacticDiagnostics(getValidSourceFile(fileName), cancellationToken); } /** * getSemanticDiagnostiscs return array of Diagnostics. If '-d' is not enabled, only report semantic errors @@ -39638,12 +42068,12 @@ var ts; } // Only perform the action per file regardless of '-out' flag as LanguageServiceHost is expected to call this function per file. // Therefore only get diagnostics for given file. - var semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile); + var semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile, cancellationToken); if (!program.getCompilerOptions().declaration) { return semanticDiagnostics; } // If '-d' is enabled, check for emitter error. One example of emitter error is export class implements non-export interface - var declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile); + var declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile, cancellationToken); return ts.concatenate(semanticDiagnostics, declarationDiagnostics); } function getJavaScriptSemanticDiagnostics(sourceFile) { @@ -39655,44 +42085,44 @@ var ts; return false; } switch (node.kind) { - case 211 /* ImportEqualsDeclaration */: + case 218 /* ImportEqualsDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 217 /* ExportAssignment */: + case 224 /* ExportAssignment */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; - case 204 /* ClassDeclaration */: + case 211 /* ClassDeclaration */: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 225 /* HeritageClause */: + case 240 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 102 /* ImplementsKeyword */) { + if (heritageClause.token === 103 /* ImplementsKeyword */) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 205 /* InterfaceDeclaration */: + case 212 /* InterfaceDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 206 /* TypeAliasDeclaration */: + case 213 /* TypeAliasDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 137 /* Constructor */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 165 /* FunctionExpression */: - case 203 /* FunctionDeclaration */: - case 166 /* ArrowFunction */: - case 203 /* FunctionDeclaration */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 141 /* Constructor */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 170 /* FunctionExpression */: + case 210 /* FunctionDeclaration */: + case 171 /* ArrowFunction */: + case 210 /* FunctionDeclaration */: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -39700,20 +42130,20 @@ var ts; return true; } break; - case 183 /* VariableStatement */: + case 190 /* VariableStatement */: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 201 /* VariableDeclaration */: + case 208 /* VariableDeclaration */: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 160 /* CallExpression */: - case 161 /* NewExpression */: + case 165 /* CallExpression */: + case 166 /* NewExpression */: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -39721,7 +42151,7 @@ var ts; return true; } break; - case 131 /* Parameter */: + case 135 /* Parameter */: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -39737,17 +42167,17 @@ var ts; return true; } break; - case 134 /* PropertyDeclaration */: + case 138 /* PropertyDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 207 /* EnumDeclaration */: + case 214 /* EnumDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 163 /* TypeAssertionExpression */: + case 168 /* TypeAssertionExpression */: var typeAssertionExpression = node; diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return true; - case 132 /* Decorator */: + case 136 /* Decorator */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); return true; } @@ -39773,17 +42203,18 @@ var ts; for (var _i = 0; _i < modifiers.length; _i++) { var modifier = modifiers[_i]; switch (modifier.kind) { - case 108 /* PublicKeyword */: - case 106 /* PrivateKeyword */: - case 107 /* ProtectedKeyword */: - case 115 /* DeclareKeyword */: + case 109 /* PublicKeyword */: + case 107 /* PrivateKeyword */: + case 108 /* ProtectedKeyword */: + case 119 /* DeclareKeyword */: diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; // These are all legal modifiers. - case 109 /* StaticKeyword */: - case 78 /* ExportKeyword */: - case 70 /* ConstKeyword */: - case 73 /* DefaultKeyword */: + case 110 /* StaticKeyword */: + case 79 /* ExportKeyword */: + case 71 /* ConstKeyword */: + case 74 /* DefaultKeyword */: + case 112 /* AbstractKeyword */: } } } @@ -39792,19 +42223,16 @@ var ts; } function getCompilerOptionsDiagnostics() { synchronizeHostData(); - return program.getOptionsDiagnostics().concat(program.getGlobalDiagnostics()); + return program.getOptionsDiagnostics(cancellationToken).concat(program.getGlobalDiagnostics(cancellationToken)); } - /// Completion - function getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks) { - var displayName = symbol.getName(); + /** + * Get the name to be display in completion from a given symbol. + * + * @return undefined if the name is of external module otherwise a name with striped of any quote + */ + function getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks, location) { + var displayName = ts.getDeclaredName(program.getTypeChecker(), symbol, location); if (displayName) { - // If this is the default export, get the name of the declaration if it exists - if (displayName === "default") { - var localSymbol = ts.getLocalSymbolForExportDefault(symbol); - if (localSymbol && localSymbol.name) { - displayName = symbol.valueDeclaration.localSymbol.name; - } - } var firstCharCode = displayName.charCodeAt(0); // First check of the displayName is not external module; if it is an external module, it is not valid entry if ((symbol.flags & 1536 /* Namespace */) && (firstCharCode === 39 /* singleQuote */ || firstCharCode === 34 /* doubleQuote */)) { @@ -39815,32 +42243,33 @@ var ts; } return getCompletionEntryDisplayName(displayName, target, performCharacterChecks); } - function getCompletionEntryDisplayName(displayName, target, performCharacterChecks) { - if (!displayName) { + /** + * Get a displayName from a given for completion list, performing any necessary quotes stripping + * and checking whether the name is valid identifier name. + */ + function getCompletionEntryDisplayName(name, target, performCharacterChecks) { + if (!name) { return undefined; } - var firstCharCode = displayName.charCodeAt(0); - if (displayName.length >= 2 && - firstCharCode === displayName.charCodeAt(displayName.length - 1) && - (firstCharCode === 39 /* singleQuote */ || firstCharCode === 34 /* doubleQuote */)) { - // If the user entered name for the symbol was quoted, removing the quotes is not enough, as the name could be an - // invalid identifier name. We need to check if whatever was inside the quotes is actually a valid identifier name. - displayName = displayName.substring(1, displayName.length - 1); - } - if (!displayName) { + name = ts.stripQuotes(name); + if (!name) { return undefined; } + // If the user entered name for the symbol was quoted, removing the quotes is not enough, as the name could be an + // invalid identifier name. We need to check if whatever was inside the quotes is actually a valid identifier name. + // e.g "b a" is valid quoted name but when we strip off the quotes, it is invalid. + // We, thus, need to check if whatever was inside the quotes is actually a valid identifier name. if (performCharacterChecks) { - if (!ts.isIdentifierStart(displayName.charCodeAt(0), target)) { + if (!ts.isIdentifierStart(name.charCodeAt(0), target)) { return undefined; } - for (var i = 1, n = displayName.length; i < n; i++) { - if (!ts.isIdentifierPart(displayName.charCodeAt(i), target)) { + for (var i = 1, n = name.length; i < n; i++) { + if (!ts.isIdentifierPart(name.charCodeAt(i), target)) { return undefined; } } } - return ts.unescapeIdentifier(displayName); + return name; } function getCompletionData(fileName, position) { var typeChecker = program.getTypeChecker(); @@ -39871,26 +42300,40 @@ var ts; contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile); log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start_2)); } - // Check if this is a valid completion location - if (contextToken && isCompletionListBlocker(contextToken)) { - log("Returning an empty list because completion was requested in an invalid position."); - return undefined; - } - // Find the node where completion is requested on, in the case of a completion after - // a dot, it is the member access expression other wise, it is a request for all - // visible symbols in the scope, and the node is the current location. + // Find the node where completion is requested on. + // Also determine whether we are trying to complete with members of that node + // or attributes of a JSX tag. var node = currentToken; var isRightOfDot = false; - if (contextToken && contextToken.kind === 20 /* DotToken */ && contextToken.parent.kind === 158 /* PropertyAccessExpression */) { - node = contextToken.parent.expression; - isRightOfDot = true; - } - else if (contextToken && contextToken.kind === 20 /* DotToken */ && contextToken.parent.kind === 128 /* QualifiedName */) { - node = contextToken.parent.left; - isRightOfDot = true; - } + var isRightOfOpenTag = false; var location = ts.getTouchingPropertyName(sourceFile, position); - var target = program.getCompilerOptions().target; + if (contextToken) { + // Bail out if this is a known invalid completion location + if (isCompletionListBlocker(contextToken)) { + log("Returning an empty list because completion was requested in an invalid position."); + return undefined; + } + var parent_10 = contextToken.parent, kind = contextToken.kind; + if (kind === 20 /* DotToken */) { + if (parent_10.kind === 163 /* PropertyAccessExpression */) { + node = contextToken.parent.expression; + isRightOfDot = true; + } + else if (parent_10.kind === 132 /* QualifiedName */) { + node = contextToken.parent.left; + isRightOfDot = true; + } + else { + // There is nothing that precedes the dot, so this likely just a stray character + // or leading into a '...' token. Just bail out instead. + return undefined; + } + } + else if (kind === 24 /* LessThanToken */ && sourceFile.languageVariant === 1 /* JSX */) { + isRightOfOpenTag = true; + location = contextToken; + } + } var semanticStart = new Date().getTime(); var isMemberCompletion; var isNewIdentifierLocation; @@ -39898,6 +42341,17 @@ var ts; if (isRightOfDot) { getTypeScriptMemberSymbols(); } + else if (isRightOfOpenTag) { + var tagSymbols = typeChecker.getJsxIntrinsicTagNames(); + if (tryGetGlobalSymbols()) { + symbols = tagSymbols.concat(symbols.filter(function (s) { return !!(s.flags & 107455 /* Value */); })); + } + else { + symbols = tagSymbols; + } + isMemberCompletion = true; + isNewIdentifierLocation = false; + } else { // For JavaScript or TypeScript, if we're not after a dot, then just try to get the // global symbols in scope. These results should be valid for either language as @@ -39907,12 +42361,12 @@ var ts; } } log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart)); - return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: isRightOfDot }; + return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag) }; function getTypeScriptMemberSymbols() { // Right of dot member completion list isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 65 /* Identifier */ || node.kind === 128 /* QualifiedName */ || node.kind === 158 /* PropertyAccessExpression */) { + if (node.kind === 66 /* Identifier */ || node.kind === 132 /* QualifiedName */ || node.kind === 163 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -39955,80 +42409,68 @@ var ts; } } function tryGetGlobalSymbols() { - var containingObjectLiteral = getContainingObjectLiteralApplicableForCompletion(contextToken); - if (containingObjectLiteral) { - // Object literal expression, look up possible property names from contextual type - isMemberCompletion = true; - isNewIdentifierLocation = true; - var contextualType = typeChecker.getContextualType(containingObjectLiteral); - if (!contextualType) { - return false; - } - var contextualTypeMembers = typeChecker.getPropertiesOfType(contextualType); - if (contextualTypeMembers && contextualTypeMembers.length > 0) { - // Add filtered items to the completion list - symbols = filterContextualMembersList(contextualTypeMembers, containingObjectLiteral.properties); - } + var objectLikeContainer; + var importClause; + var jsxContainer; + if (objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken)) { + return tryGetObjectLikeCompletionSymbols(objectLikeContainer); } - else if (ts.getAncestor(contextToken, 213 /* ImportClause */)) { - // cursor is in import clause + if (importClause = ts.getAncestor(contextToken, 220 /* ImportClause */)) { + // cursor is in an import clause // try to show exported member for imported module - isMemberCompletion = true; - isNewIdentifierLocation = true; - if (showCompletionsInImportsClause(contextToken)) { - var importDeclaration = ts.getAncestor(contextToken, 212 /* ImportDeclaration */); - ts.Debug.assert(importDeclaration !== undefined); - var exports; - if (importDeclaration.moduleSpecifier) { - var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importDeclaration.moduleSpecifier); - if (moduleSpecifierSymbol) { - exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); - } + return tryGetImportClauseCompletionSymbols(importClause); + } + if (jsxContainer = tryGetContainingJsxElement(contextToken)) { + var attrsType; + if ((jsxContainer.kind === 231 /* JsxSelfClosingElement */) || (jsxContainer.kind === 232 /* JsxOpeningElement */)) { + // Cursor is inside a JSX self-closing element or opening element + attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); + if (attrsType) { + symbols = filterJsxAttributes(jsxContainer.attributes, typeChecker.getPropertiesOfType(attrsType)); + isMemberCompletion = true; + isNewIdentifierLocation = false; + return true; } - //let exports = typeInfoResolver.getExportsOfImportDeclaration(importDeclaration); - symbols = exports ? filterModuleExports(exports, importDeclaration) : emptyArray; } } - else { - // Get all entities in the current scope. - isMemberCompletion = false; - isNewIdentifierLocation = isNewIdentifierDefinitionLocation(contextToken); - if (previousToken !== contextToken) { - ts.Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); - } - // We need to find the node that will give us an appropriate scope to begin - // aggregating completion candidates. This is achieved in 'getScopeNode' - // by finding the first node that encompasses a position, accounting for whether a node - // is "complete" to decide whether a position belongs to the node. - // - // However, at the end of an identifier, we are interested in the scope of the identifier - // itself, but fall outside of the identifier. For instance: - // - // xyz => x$ - // - // the cursor is outside of both the 'x' and the arrow function 'xyz => x', - // so 'xyz' is not returned in our results. - // - // We define 'adjustedPosition' so that we may appropriately account for - // being at the end of an identifier. The intention is that if requesting completion - // at the end of an identifier, it should be effectively equivalent to requesting completion - // anywhere inside/at the beginning of the identifier. So in the previous case, the - // 'adjustedPosition' will work as if requesting completion in the following: - // - // xyz => $x - // - // If previousToken !== contextToken, then - // - 'contextToken' was adjusted to the token prior to 'previousToken' - // because we were at the end of an identifier. - // - 'previousToken' is defined. - var adjustedPosition = previousToken !== contextToken ? - previousToken.getStart() : - position; - var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; - /// TODO filter meaning based on the current context - var symbolMeanings = 793056 /* Type */ | 107455 /* Value */ | 1536 /* Namespace */ | 8388608 /* Alias */; - symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); + // Get all entities in the current scope. + isMemberCompletion = false; + isNewIdentifierLocation = isNewIdentifierDefinitionLocation(contextToken); + if (previousToken !== contextToken) { + ts.Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); } + // We need to find the node that will give us an appropriate scope to begin + // aggregating completion candidates. This is achieved in 'getScopeNode' + // by finding the first node that encompasses a position, accounting for whether a node + // is "complete" to decide whether a position belongs to the node. + // + // However, at the end of an identifier, we are interested in the scope of the identifier + // itself, but fall outside of the identifier. For instance: + // + // xyz => x$ + // + // the cursor is outside of both the 'x' and the arrow function 'xyz => x', + // so 'xyz' is not returned in our results. + // + // We define 'adjustedPosition' so that we may appropriately account for + // being at the end of an identifier. The intention is that if requesting completion + // at the end of an identifier, it should be effectively equivalent to requesting completion + // anywhere inside/at the beginning of the identifier. So in the previous case, the + // 'adjustedPosition' will work as if requesting completion in the following: + // + // xyz => $x + // + // If previousToken !== contextToken, then + // - 'contextToken' was adjusted to the token prior to 'previousToken' + // because we were at the end of an identifier. + // - 'previousToken' is defined. + var adjustedPosition = previousToken !== contextToken ? + previousToken.getStart() : + position; + var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; + /// TODO filter meaning based on the current context + var symbolMeanings = 793056 /* Type */ | 107455 /* Value */ | 1536 /* Namespace */ | 8388608 /* Alias */; + symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); return true; } /** @@ -40042,20 +42484,20 @@ var ts; } return scope; } - function isCompletionListBlocker(previousToken) { + function isCompletionListBlocker(contextToken) { var start = new Date().getTime(); - var result = isInStringOrRegularExpressionOrTemplateLiteral(previousToken) || - isIdentifierDefinitionLocation(previousToken) || - isRightOfIllegalDot(previousToken); + var result = isInStringOrRegularExpressionOrTemplateLiteral(contextToken) || + isIdentifierDefinitionLocation(contextToken) || + isDotOfNumericLiteral(contextToken); log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - start)); return result; } - function showCompletionsInImportsClause(node) { + function shouldShowCompletionsInImportsClause(node) { if (node) { // import {| // import {a,| if (node.kind === 14 /* OpenBraceToken */ || node.kind === 23 /* CommaToken */) { - return node.parent.kind === 215 /* NamedImports */; + return node.parent.kind === 222 /* NamedImports */; } } return false; @@ -40065,38 +42507,40 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 23 /* CommaToken */: - return containingNodeKind === 160 /* CallExpression */ // func( a, | - || containingNodeKind === 137 /* Constructor */ // constructor( a, | public, protected, private keywords are allowed here, so show completion - || containingNodeKind === 161 /* NewExpression */ // new C(a, | - || containingNodeKind === 156 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 172 /* BinaryExpression */ // let x = (a, | - || containingNodeKind === 145 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 165 /* CallExpression */ // func( a, | + || containingNodeKind === 141 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 166 /* NewExpression */ // new C(a, | + || containingNodeKind === 161 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 178 /* BinaryExpression */ // let x = (a, | + || containingNodeKind === 149 /* FunctionType */; // var x: (s: string, list| case 16 /* OpenParenToken */: - return containingNodeKind === 160 /* CallExpression */ // func( | - || containingNodeKind === 137 /* Constructor */ // constructor( | - || containingNodeKind === 161 /* NewExpression */ // new C(a| - || containingNodeKind === 164 /* ParenthesizedExpression */ // let x = (a| - || containingNodeKind === 152 /* ParenthesizedType */; // function F(pred: (a| this can become an arrow function, where 'a' is the argument + return containingNodeKind === 165 /* CallExpression */ // func( | + || containingNodeKind === 141 /* Constructor */ // constructor( | + || containingNodeKind === 166 /* NewExpression */ // new C(a| + || containingNodeKind === 169 /* ParenthesizedExpression */ // let x = (a| + || containingNodeKind === 157 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 18 /* OpenBracketToken */: - return containingNodeKind === 156 /* ArrayLiteralExpression */; // [ | - case 118 /* ModuleKeyword */: // module | - case 119 /* NamespaceKeyword */: + return containingNodeKind === 161 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 146 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 133 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 122 /* ModuleKeyword */: // module | + case 123 /* NamespaceKeyword */: return true; case 20 /* DotToken */: - return containingNodeKind === 208 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 215 /* ModuleDeclaration */; // module A.| case 14 /* OpenBraceToken */: - return containingNodeKind === 204 /* ClassDeclaration */; // class A{ | - case 53 /* EqualsToken */: - return containingNodeKind === 201 /* VariableDeclaration */ // let x = a| - || containingNodeKind === 172 /* BinaryExpression */; // x = a| + return containingNodeKind === 211 /* ClassDeclaration */; // class A{ | + case 54 /* EqualsToken */: + return containingNodeKind === 208 /* VariableDeclaration */ // let x = a| + || containingNodeKind === 178 /* BinaryExpression */; // x = a| case 11 /* TemplateHead */: - return containingNodeKind === 174 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 180 /* TemplateExpression */; // `aa ${| case 12 /* TemplateMiddle */: - return containingNodeKind === 180 /* TemplateSpan */; // `aa ${10} dd ${| - case 108 /* PublicKeyword */: - case 106 /* PrivateKeyword */: - case 107 /* ProtectedKeyword */: - return containingNodeKind === 134 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 187 /* TemplateSpan */; // `aa ${10} dd ${| + case 109 /* PublicKeyword */: + case 107 /* PrivateKeyword */: + case 108 /* ProtectedKeyword */: + return containingNodeKind === 138 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (previousToken.getText()) { @@ -40108,12 +42552,12 @@ var ts; } return false; } - function isInStringOrRegularExpressionOrTemplateLiteral(previousToken) { - if (previousToken.kind === 8 /* StringLiteral */ - || previousToken.kind === 9 /* RegularExpressionLiteral */ - || ts.isTemplateLiteralKind(previousToken.kind)) { - var start_3 = previousToken.getStart(); - var end = previousToken.getEnd(); + function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { + if (contextToken.kind === 8 /* StringLiteral */ + || contextToken.kind === 9 /* RegularExpressionLiteral */ + || ts.isTemplateLiteralKind(contextToken.kind)) { + var start_3 = contextToken.getStart(); + var end = contextToken.getEnd(); // To be "in" one of these literals, the position has to be: // 1. entirely within the token text. // 2. at the end position of an unterminated token. @@ -40122,21 +42566,118 @@ var ts; return true; } if (position === end) { - return !!previousToken.isUnterminated || - previousToken.kind === 9 /* RegularExpressionLiteral */; + return !!contextToken.isUnterminated + || contextToken.kind === 9 /* RegularExpressionLiteral */; } } return false; } - function getContainingObjectLiteralApplicableForCompletion(previousToken) { - // The locations in an object literal expression that are applicable for completion are property name definition locations. - if (previousToken) { - var parent_10 = previousToken.parent; - switch (previousToken.kind) { + /** + * Aggregates relevant symbols for completion in object literals and object binding patterns. + * Relevant symbols are stored in the captured 'symbols' variable. + * + * @returns true if 'symbols' was successfully populated; false otherwise. + */ + function tryGetObjectLikeCompletionSymbols(objectLikeContainer) { + // We're looking up possible property names from contextual/inferred/declared type. + isMemberCompletion = true; + var typeForObject; + var existingMembers; + if (objectLikeContainer.kind === 162 /* ObjectLiteralExpression */) { + // We are completing on contextual types, but may also include properties + // other than those within the declared type. + isNewIdentifierLocation = true; + typeForObject = typeChecker.getContextualType(objectLikeContainer); + existingMembers = objectLikeContainer.properties; + } + else if (objectLikeContainer.kind === 158 /* ObjectBindingPattern */) { + // We are *only* completing on properties from the type being destructured. + isNewIdentifierLocation = false; + typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); + existingMembers = objectLikeContainer.elements; + } + else { + ts.Debug.fail("Expected object literal or binding pattern, got " + objectLikeContainer.kind); + } + if (!typeForObject) { + return false; + } + var typeMembers = typeChecker.getPropertiesOfType(typeForObject); + if (typeMembers && typeMembers.length > 0) { + // Add filtered items to the completion list + symbols = filterObjectMembersList(typeMembers, existingMembers); + } + return true; + } + /** + * Aggregates relevant symbols for completion in import clauses; for instance, + * + * import { $ } from "moduleName"; + * + * Relevant symbols are stored in the captured 'symbols' variable. + * + * @returns true if 'symbols' was successfully populated; false otherwise. + */ + function tryGetImportClauseCompletionSymbols(importClause) { + // cursor is in import clause + // try to show exported member for imported module + if (shouldShowCompletionsInImportsClause(contextToken)) { + isMemberCompletion = true; + isNewIdentifierLocation = false; + var importDeclaration = importClause.parent; + ts.Debug.assert(importDeclaration !== undefined && importDeclaration.kind === 219 /* ImportDeclaration */); + var exports; + var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importDeclaration.moduleSpecifier); + if (moduleSpecifierSymbol) { + exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); + } + //let exports = typeInfoResolver.getExportsOfImportDeclaration(importDeclaration); + symbols = exports ? filterModuleExports(exports, importDeclaration) : emptyArray; + } + else { + isMemberCompletion = false; + isNewIdentifierLocation = true; + } + return true; + } + /** + * Returns the immediate owning object literal or binding pattern of a context token, + * on the condition that one exists and that the context implies completion should be given. + */ + function tryGetObjectLikeCompletionContainer(contextToken) { + if (contextToken) { + switch (contextToken.kind) { case 14 /* OpenBraceToken */: // let x = { | case 23 /* CommaToken */: - if (parent_10 && parent_10.kind === 157 /* ObjectLiteralExpression */) { - return parent_10; + var parent_11 = contextToken.parent; + if (parent_11 && (parent_11.kind === 162 /* ObjectLiteralExpression */ || parent_11.kind === 158 /* ObjectBindingPattern */)) { + return parent_11; + } + break; + } + } + return undefined; + } + function tryGetContainingJsxElement(contextToken) { + if (contextToken) { + var parent_12 = contextToken.parent; + switch (contextToken.kind) { + case 25 /* LessThanSlashToken */: + case 37 /* SlashToken */: + case 66 /* Identifier */: + if (parent_12 && (parent_12.kind === 231 /* JsxSelfClosingElement */ || parent_12.kind === 232 /* JsxOpeningElement */)) { + return parent_12; + } + break; + case 15 /* CloseBraceToken */: + // The context token is the closing } of an attribute, which means + // its parent is a JsxExpression, whose parent is a JsxAttribute, + // whose parent is a JsxOpeningLikeElement + if (parent_12 && + parent_12.kind === 237 /* JsxExpression */ && + parent_12.parent && + parent_12.parent.kind === 235 /* JsxAttribute */) { + return parent_12.parent.parent; } break; } @@ -40145,103 +42686,98 @@ var ts; } function isFunction(kind) { switch (kind) { - case 165 /* FunctionExpression */: - case 166 /* ArrowFunction */: - case 203 /* FunctionDeclaration */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 140 /* CallSignature */: - case 141 /* ConstructSignature */: - case 142 /* IndexSignature */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: + case 210 /* FunctionDeclaration */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 144 /* CallSignature */: + case 145 /* ConstructSignature */: + case 146 /* IndexSignature */: return true; } return false; } - function isIdentifierDefinitionLocation(previousToken) { - if (previousToken) { - var containingNodeKind = previousToken.parent.kind; - switch (previousToken.kind) { - case 23 /* CommaToken */: - return containingNodeKind === 201 /* VariableDeclaration */ || - containingNodeKind === 202 /* VariableDeclarationList */ || - containingNodeKind === 183 /* VariableStatement */ || - containingNodeKind === 207 /* EnumDeclaration */ || - isFunction(containingNodeKind) || - containingNodeKind === 204 /* ClassDeclaration */ || - containingNodeKind === 203 /* FunctionDeclaration */ || - containingNodeKind === 205 /* InterfaceDeclaration */ || - containingNodeKind === 154 /* ArrayBindingPattern */ || - containingNodeKind === 153 /* ObjectBindingPattern */; // function func({ x, y| - case 20 /* DotToken */: - return containingNodeKind === 154 /* ArrayBindingPattern */; // var [.| - case 51 /* ColonToken */: - return containingNodeKind === 155 /* BindingElement */; // var {x :html| - case 18 /* OpenBracketToken */: - return containingNodeKind === 154 /* ArrayBindingPattern */; // var [x| - case 16 /* OpenParenToken */: - return containingNodeKind === 226 /* CatchClause */ || - isFunction(containingNodeKind); - case 14 /* OpenBraceToken */: - return containingNodeKind === 207 /* EnumDeclaration */ || - containingNodeKind === 205 /* InterfaceDeclaration */ || - containingNodeKind === 148 /* TypeLiteral */ || - containingNodeKind === 153 /* ObjectBindingPattern */; // function func({ x| - case 22 /* SemicolonToken */: - return containingNodeKind === 133 /* PropertySignature */ && - previousToken.parent && previousToken.parent.parent && - (previousToken.parent.parent.kind === 205 /* InterfaceDeclaration */ || - previousToken.parent.parent.kind === 148 /* TypeLiteral */); // let x : { a; | - case 24 /* LessThanToken */: - return containingNodeKind === 204 /* ClassDeclaration */ || - containingNodeKind === 203 /* FunctionDeclaration */ || - containingNodeKind === 205 /* InterfaceDeclaration */ || - isFunction(containingNodeKind); - case 109 /* StaticKeyword */: - return containingNodeKind === 134 /* PropertyDeclaration */; - case 21 /* DotDotDotToken */: - return containingNodeKind === 131 /* Parameter */ || - containingNodeKind === 137 /* Constructor */ || - (previousToken.parent && previousToken.parent.parent && - previousToken.parent.parent.kind === 154 /* ArrayBindingPattern */); // var [...z| - case 108 /* PublicKeyword */: - case 106 /* PrivateKeyword */: - case 107 /* ProtectedKeyword */: - return containingNodeKind === 131 /* Parameter */; - case 69 /* ClassKeyword */: - case 77 /* EnumKeyword */: - case 103 /* InterfaceKeyword */: - case 83 /* FunctionKeyword */: - case 98 /* VarKeyword */: - case 116 /* GetKeyword */: - case 122 /* SetKeyword */: - case 85 /* ImportKeyword */: - case 104 /* LetKeyword */: - case 70 /* ConstKeyword */: - case 110 /* YieldKeyword */: - case 125 /* TypeKeyword */: - return true; - } - // Previous token may have been a keyword that was converted to an identifier. - switch (previousToken.getText()) { - case "class": - case "interface": - case "enum": - case "function": - case "var": - case "static": - case "let": - case "const": - case "yield": - return true; - } + function isIdentifierDefinitionLocation(contextToken) { + var containingNodeKind = contextToken.parent.kind; + switch (contextToken.kind) { + case 23 /* CommaToken */: + return containingNodeKind === 208 /* VariableDeclaration */ || + containingNodeKind === 209 /* VariableDeclarationList */ || + containingNodeKind === 190 /* VariableStatement */ || + containingNodeKind === 214 /* EnumDeclaration */ || + isFunction(containingNodeKind) || + containingNodeKind === 211 /* ClassDeclaration */ || + containingNodeKind === 210 /* FunctionDeclaration */ || + containingNodeKind === 212 /* InterfaceDeclaration */ || + containingNodeKind === 159 /* ArrayBindingPattern */; // var [x, y| + case 20 /* DotToken */: + return containingNodeKind === 159 /* ArrayBindingPattern */; // var [.| + case 52 /* ColonToken */: + return containingNodeKind === 160 /* BindingElement */; // var {x :html| + case 18 /* OpenBracketToken */: + return containingNodeKind === 159 /* ArrayBindingPattern */; // var [x| + case 16 /* OpenParenToken */: + return containingNodeKind === 241 /* CatchClause */ || + isFunction(containingNodeKind); + case 14 /* OpenBraceToken */: + return containingNodeKind === 214 /* EnumDeclaration */ || + containingNodeKind === 212 /* InterfaceDeclaration */ || + containingNodeKind === 152 /* TypeLiteral */; // let x : { | + case 22 /* SemicolonToken */: + return containingNodeKind === 137 /* PropertySignature */ && + contextToken.parent && contextToken.parent.parent && + (contextToken.parent.parent.kind === 212 /* InterfaceDeclaration */ || + contextToken.parent.parent.kind === 152 /* TypeLiteral */); // let x : { a; | + case 24 /* LessThanToken */: + return containingNodeKind === 211 /* ClassDeclaration */ || + containingNodeKind === 210 /* FunctionDeclaration */ || + containingNodeKind === 212 /* InterfaceDeclaration */ || + isFunction(containingNodeKind); + case 110 /* StaticKeyword */: + return containingNodeKind === 138 /* PropertyDeclaration */; + case 21 /* DotDotDotToken */: + return containingNodeKind === 135 /* Parameter */ || + (contextToken.parent && contextToken.parent.parent && + contextToken.parent.parent.kind === 159 /* ArrayBindingPattern */); // var [...z| + case 109 /* PublicKeyword */: + case 107 /* PrivateKeyword */: + case 108 /* ProtectedKeyword */: + return containingNodeKind === 135 /* Parameter */; + case 70 /* ClassKeyword */: + case 78 /* EnumKeyword */: + case 104 /* InterfaceKeyword */: + case 84 /* FunctionKeyword */: + case 99 /* VarKeyword */: + case 120 /* GetKeyword */: + case 126 /* SetKeyword */: + case 86 /* ImportKeyword */: + case 105 /* LetKeyword */: + case 71 /* ConstKeyword */: + case 111 /* YieldKeyword */: + case 129 /* TypeKeyword */: + return true; + } + // Previous token may have been a keyword that was converted to an identifier. + switch (contextToken.getText()) { + case "class": + case "interface": + case "enum": + case "function": + case "var": + case "static": + case "let": + case "const": + case "yield": + return true; } return false; } - function isRightOfIllegalDot(previousToken) { - if (previousToken && previousToken.kind === 7 /* NumericLiteral */) { - var text = previousToken.getFullText(); + function isDotOfNumericLiteral(contextToken) { + if (contextToken.kind === 7 /* NumericLiteral */) { + var text = contextToken.getFullText(); return text.charAt(text.length - 1) === "."; } return false; @@ -40252,8 +42788,12 @@ var ts; return exports; } if (importDeclaration.importClause.namedBindings && - importDeclaration.importClause.namedBindings.kind === 215 /* NamedImports */) { + importDeclaration.importClause.namedBindings.kind === 222 /* NamedImports */) { ts.forEach(importDeclaration.importClause.namedBindings.elements, function (el) { + // If this is the current item we are editing right now, do not filter it out + if (el.getStart() <= position && position <= el.getEnd()) { + return; + } var name = el.propertyName || el.name; exisingImports[name.text] = true; }); @@ -40263,23 +42803,35 @@ var ts; } return ts.filter(exports, function (e) { return !ts.lookUp(exisingImports, e.name); }); } - function filterContextualMembersList(contextualMemberSymbols, existingMembers) { + function filterObjectMembersList(contextualMemberSymbols, existingMembers) { if (!existingMembers || existingMembers.length === 0) { return contextualMemberSymbols; } var existingMemberNames = {}; - ts.forEach(existingMembers, function (m) { - if (m.kind !== 227 /* PropertyAssignment */ && m.kind !== 228 /* ShorthandPropertyAssignment */) { - // Ignore omitted expressions for missing members in the object literal - return; + for (var _i = 0; _i < existingMembers.length; _i++) { + var m = existingMembers[_i]; + // Ignore omitted expressions for missing members + if (m.kind !== 242 /* PropertyAssignment */ && + m.kind !== 243 /* ShorthandPropertyAssignment */ && + m.kind !== 160 /* BindingElement */) { + continue; } + // If this is the current item we are editing right now, do not filter it out if (m.getStart() <= position && position <= m.getEnd()) { - // If this is the current item we are editing right now, do not filter it out - return; + continue; } - // TODO(jfreeman): Account for computed property name - existingMemberNames[m.name.text] = true; - }); + var existingName = void 0; + if (m.kind === 160 /* BindingElement */ && m.propertyName) { + existingName = m.propertyName.text; + } + else { + // TODO(jfreeman): Account for computed property name + // NOTE: if one only performs this step when m.name is an identifier, + // things like '__proto__' are not filtered out. + existingName = m.name.text; + } + existingMemberNames[existingName] = true; + } var filteredMembers = []; ts.forEach(contextualMemberSymbols, function (s) { if (!existingMemberNames[s.name]) { @@ -40288,6 +42840,27 @@ var ts; }); return filteredMembers; } + function filterJsxAttributes(attributes, symbols) { + var seenNames = {}; + for (var _i = 0; _i < attributes.length; _i++) { + var attr = attributes[_i]; + // If this is the current item we are editing right now, do not filter it out + if (attr.getStart() <= position && position <= attr.getEnd()) { + continue; + } + if (attr.kind === 235 /* JsxAttribute */) { + seenNames[attr.name.text] = true; + } + } + var result = []; + for (var _a = 0; _a < symbols.length; _a++) { + var sym = symbols[_a]; + if (!seenNames[sym.name]) { + result.push(sym); + } + } + return result; + } } function getCompletionsAtPosition(fileName, position) { synchronizeHostData(); @@ -40319,10 +42892,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_27 in nameTable) { - if (!allNames[name_27]) { - allNames[name_27] = name_27; - var displayName = getCompletionEntryDisplayName(name_27, target, true); + for (var name_31 in nameTable) { + if (!allNames[name_31]) { + allNames[name_31] = name_31; + var displayName = getCompletionEntryDisplayName(name_31, target, true); if (displayName) { var entry = { name: displayName, @@ -40341,7 +42914,7 @@ var ts; // Try to get a valid display name for this symbol, if we could not find one, then ignore it. // We would like to only show things that can be added after a dot, so for instance numeric properties can // not be accessed with a dot (a.1 <- invalid) - var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, true); + var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, true, location); if (!displayName) { return undefined; } @@ -40391,15 +42964,15 @@ var ts; // We don't need to perform character checks here because we're only comparing the // name against 'entryName' (which is known to be good), not building a new // completion entry. - var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target, false) === entryName ? s : undefined; }); + var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target, false, location_2) === entryName ? s : undefined; }); if (symbol) { - var displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location_2, location_2, 7 /* All */); + var _a = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location_2, location_2, 7 /* All */), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; return { name: entryName, - kind: displayPartsDocumentationsAndSymbolKind.symbolKind, kindModifiers: getSymbolModifiers(symbol), - displayParts: displayPartsDocumentationsAndSymbolKind.displayParts, - documentation: displayPartsDocumentationsAndSymbolKind.documentation + kind: symbolKind, + displayParts: displayParts, + documentation: documentation }; } } @@ -40420,7 +42993,8 @@ var ts; function getSymbolKind(symbol, location) { var flags = symbol.getFlags(); if (flags & 32 /* Class */) - return ScriptElementKind.classElement; + return ts.getDeclarationOfKind(symbol, 183 /* ClassExpression */) ? + ScriptElementKind.localClassElement : ScriptElementKind.classElement; if (flags & 384 /* Enum */) return ScriptElementKind.enumElement; if (flags & 524288 /* TypeAlias */) @@ -40473,7 +43047,7 @@ var ts; if (flags & 16384 /* Constructor */) return ScriptElementKind.constructorImplementationElement; if (flags & 4 /* Property */) { - if (flags & 268435456 /* UnionProperty */) { + if (flags & 268435456 /* SyntheticProperty */) { // If union property is result of union of non method (property/accessors/variables), it is labeled as property var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { var rootSymbolFlags = rootSymbol.getFlags(); @@ -40521,7 +43095,7 @@ var ts; var signature; type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 158 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 163 /* PropertyAccessExpression */) { var right = location.parent.name; // Either the location is on the right of a property access, or on the left and the right is missing if (right === location || (right && right.getFullWidth() === 0)) { @@ -40530,7 +43104,7 @@ var ts; } // try get the call/construct signature from the type if it matches var callExpression; - if (location.kind === 160 /* CallExpression */ || location.kind === 161 /* NewExpression */) { + if (location.kind === 165 /* CallExpression */ || location.kind === 166 /* NewExpression */) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -40543,7 +43117,7 @@ var ts; // Use the first candidate: signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 161 /* NewExpression */ || callExpression.expression.kind === 91 /* SuperKeyword */; + var useConstructSignatures = callExpression.kind === 166 /* NewExpression */ || callExpression.expression.kind === 92 /* SuperKeyword */; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target || signature)) { // Get the first signature if there @@ -40560,7 +43134,7 @@ var ts; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(88 /* NewKeyword */)); + displayParts.push(ts.keywordPart(89 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -40576,14 +43150,14 @@ var ts; case ScriptElementKind.parameterElement: case ScriptElementKind.localVariableElement: // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(51 /* ColonToken */)); + displayParts.push(ts.punctuationPart(52 /* ColonToken */)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(88 /* NewKeyword */)); + displayParts.push(ts.keywordPart(89 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - if (!(type.flags & 32768 /* Anonymous */)) { - displayParts.push.apply(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, undefined, 1 /* WriteTypeParametersOrArguments */)); + if (!(type.flags & 65536 /* Anonymous */)) { + ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, undefined, 1 /* WriteTypeParametersOrArguments */)); } addSignatureDisplayParts(signature, allSignatures, 8 /* WriteArrowStyleSignature */); break; @@ -40595,24 +43169,24 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 114 /* ConstructorKeyword */ && location.parent.kind === 137 /* Constructor */)) { + (location.kind === 118 /* ConstructorKeyword */ && location.parent.kind === 141 /* Constructor */)) { // get the signature from the declaration and write it var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 137 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 141 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 137 /* Constructor */) { + if (functionDeclaration.kind === 141 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 140 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 144 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -40621,43 +43195,52 @@ var ts; } } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo) { - displayParts.push(ts.keywordPart(69 /* ClassKeyword */)); + if (ts.getDeclarationOfKind(symbol, 183 /* ClassExpression */)) { + // Special case for class expressions because we would like to indicate that + // the class name is local to the class body (similar to function expression) + // (local class) class + pushTypePart(ScriptElementKind.localClassElement); + } + else { + // Class declaration has name which is not local. + displayParts.push(ts.keywordPart(70 /* ClassKeyword */)); + } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(103 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(104 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & 524288 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(125 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(129 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(53 /* EqualsToken */)); + displayParts.push(ts.operatorPart(54 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push.apply(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); + ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); } if (symbolFlags & 384 /* Enum */) { addNewLineIfDisplayPartsExist(); if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(70 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(71 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(77 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(78 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 208 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 65 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 119 /* NamespaceKeyword */ : 118 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 215 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 66 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 123 /* NamespaceKeyword */ : 122 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -40669,7 +43252,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(86 /* InKeyword */)); + displayParts.push(ts.keywordPart(87 /* InKeyword */)); displayParts.push(ts.spacePart()); if (symbol.parent) { // Class/Interface type parameter @@ -40678,26 +43261,26 @@ var ts; } else { // Method/function type parameter - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 130 /* TypeParameter */).parent; + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 134 /* TypeParameter */).parent; var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 141 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(88 /* NewKeyword */)); + if (signatureDeclaration.kind === 145 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(89 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (signatureDeclaration.kind !== 140 /* CallSignature */ && signatureDeclaration.name) { + else if (signatureDeclaration.kind !== 144 /* CallSignature */ && signatureDeclaration.name) { addFullSymbolName(signatureDeclaration.symbol); } - displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } } if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 229 /* EnumMember */) { + if (declaration.kind === 244 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(53 /* EqualsToken */)); + displayParts.push(ts.operatorPart(54 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(constantValue.toString(), SymbolDisplayPartKind.numericLiteral)); } @@ -40705,17 +43288,17 @@ var ts; } if (symbolFlags & 8388608 /* Alias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(85 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(86 /* ImportKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 211 /* ImportEqualsDeclaration */) { + if (declaration.kind === 218 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(53 /* EqualsToken */)); + displayParts.push(ts.operatorPart(54 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(120 /* RequireKeyword */)); + displayParts.push(ts.keywordPart(124 /* RequireKeyword */)); displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); @@ -40724,7 +43307,7 @@ var ts; var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(53 /* EqualsToken */)); + displayParts.push(ts.operatorPart(54 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -40741,17 +43324,17 @@ var ts; if (symbolKind === ScriptElementKind.memberVariableElement || symbolFlags & 3 /* Variable */ || symbolKind === ScriptElementKind.localVariableElement) { - displayParts.push(ts.punctuationPart(51 /* ColonToken */)); + displayParts.push(ts.punctuationPart(52 /* ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplay(type, writer, enclosingDeclaration); }); - displayParts.push.apply(displayParts, typeParameterParts); + ts.addRange(displayParts, typeParameterParts); } else { - displayParts.push.apply(displayParts, ts.typeToDisplayParts(typeChecker, type, enclosingDeclaration)); + ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, type, enclosingDeclaration)); } } else if (symbolFlags & 16 /* Function */ || @@ -40780,7 +43363,7 @@ var ts; } function addFullSymbolName(symbol, enclosingDeclaration) { var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */); - displayParts.push.apply(displayParts, fullSymbolDisplayParts); + ts.addRange(displayParts, fullSymbolDisplayParts); } function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { addNewLineIfDisplayPartsExist(); @@ -40807,11 +43390,11 @@ var ts; } } function addSignatureDisplayParts(signature, allSignatures, flags) { - displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); - displayParts.push(ts.operatorPart(33 /* PlusToken */)); + displayParts.push(ts.operatorPart(34 /* PlusToken */)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); @@ -40823,7 +43406,7 @@ var ts; var typeParameterParts = ts.mapToDisplayParts(function (writer) { typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration); }); - displayParts.push.apply(displayParts, typeParameterParts); + ts.addRange(displayParts, typeParameterParts); } } function getQuickInfoAtPosition(fileName, position) { @@ -40841,11 +43424,11 @@ var ts; if (!symbol) { // Try getting just type at this position and show switch (node.kind) { - case 65 /* Identifier */: - case 158 /* PropertyAccessExpression */: - case 128 /* QualifiedName */: - case 93 /* ThisKeyword */: - case 91 /* SuperKeyword */: + case 66 /* Identifier */: + case 163 /* PropertyAccessExpression */: + case 132 /* QualifiedName */: + case 94 /* ThisKeyword */: + case 92 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type = typeChecker.getTypeAtLocation(node); if (type) { @@ -40898,10 +43481,10 @@ var ts; function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class - if (isNewExpressionTarget(location) || location.kind === 114 /* ConstructorKeyword */) { + if (isNewExpressionTarget(location) || location.kind === 118 /* ConstructorKeyword */) { if (symbol.flags & 32 /* Class */) { var classDeclaration = symbol.getDeclarations()[0]; - ts.Debug.assert(classDeclaration && classDeclaration.kind === 204 /* ClassDeclaration */); + ts.Debug.assert(classDeclaration && classDeclaration.kind === 211 /* ClassDeclaration */); return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result); } } @@ -40917,8 +43500,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 137 /* Constructor */) || - (!selectConstructors && (d.kind === 203 /* FunctionDeclaration */ || d.kind === 136 /* MethodDeclaration */ || d.kind === 135 /* MethodSignature */))) { + if ((selectConstructors && d.kind === 141 /* Constructor */) || + (!selectConstructors && (d.kind === 210 /* FunctionDeclaration */ || d.kind === 140 /* MethodDeclaration */ || d.kind === 139 /* MethodSignature */))) { declarations.push(d); if (d.body) definition = d; @@ -40978,7 +43561,7 @@ var ts; // to jump to the implementation directly. if (symbol.flags & 8388608 /* Alias */) { var declaration = symbol.declarations[0]; - if (node.kind === 65 /* Identifier */ && node.parent === declaration) { + if (node.kind === 66 /* Identifier */ && node.parent === declaration) { symbol = typeChecker.getAliasedSymbol(symbol); } } @@ -40987,7 +43570,7 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 228 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 243 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -41061,12 +43644,12 @@ var ts; }; } function getSemanticDocumentHighlights(node) { - if (node.kind === 65 /* Identifier */ || - node.kind === 93 /* ThisKeyword */ || - node.kind === 91 /* SuperKeyword */ || + if (node.kind === 66 /* Identifier */ || + node.kind === 94 /* ThisKeyword */ || + node.kind === 92 /* SuperKeyword */ || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { - var referencedSymbols = getReferencedSymbolsForNodes(node, sourceFilesToSearch, false, false); + var referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, false, false); return convertReferencedSymbols(referencedSymbols); } return undefined; @@ -41114,76 +43697,76 @@ var ts; function getHighlightSpans(node) { if (node) { switch (node.kind) { - case 84 /* IfKeyword */: - case 76 /* ElseKeyword */: - if (hasKind(node.parent, 186 /* IfStatement */)) { + case 85 /* IfKeyword */: + case 77 /* ElseKeyword */: + if (hasKind(node.parent, 193 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; - case 90 /* ReturnKeyword */: - if (hasKind(node.parent, 194 /* ReturnStatement */)) { + case 91 /* ReturnKeyword */: + if (hasKind(node.parent, 201 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; - case 94 /* ThrowKeyword */: - if (hasKind(node.parent, 198 /* ThrowStatement */)) { + case 95 /* ThrowKeyword */: + if (hasKind(node.parent, 205 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; - case 68 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 199 /* TryStatement */)) { + case 69 /* CatchKeyword */: + if (hasKind(parent(parent(node)), 206 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; - case 96 /* TryKeyword */: - case 81 /* FinallyKeyword */: - if (hasKind(parent(node), 199 /* TryStatement */)) { + case 97 /* TryKeyword */: + case 82 /* FinallyKeyword */: + if (hasKind(parent(node), 206 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent); } break; - case 92 /* SwitchKeyword */: - if (hasKind(node.parent, 196 /* SwitchStatement */)) { + case 93 /* SwitchKeyword */: + if (hasKind(node.parent, 203 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; - case 67 /* CaseKeyword */: - case 73 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 196 /* SwitchStatement */)) { + case 68 /* CaseKeyword */: + case 74 /* DefaultKeyword */: + if (hasKind(parent(parent(parent(node))), 203 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; - case 66 /* BreakKeyword */: - case 71 /* ContinueKeyword */: - if (hasKind(node.parent, 193 /* BreakStatement */) || hasKind(node.parent, 192 /* ContinueStatement */)) { + case 67 /* BreakKeyword */: + case 72 /* ContinueKeyword */: + if (hasKind(node.parent, 200 /* BreakStatement */) || hasKind(node.parent, 199 /* ContinueStatement */)) { return getBreakOrContinueStatementOccurences(node.parent); } break; - case 82 /* ForKeyword */: - if (hasKind(node.parent, 189 /* ForStatement */) || - hasKind(node.parent, 190 /* ForInStatement */) || - hasKind(node.parent, 191 /* ForOfStatement */)) { + case 83 /* ForKeyword */: + if (hasKind(node.parent, 196 /* ForStatement */) || + hasKind(node.parent, 197 /* ForInStatement */) || + hasKind(node.parent, 198 /* ForOfStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 100 /* WhileKeyword */: - case 75 /* DoKeyword */: - if (hasKind(node.parent, 188 /* WhileStatement */) || hasKind(node.parent, 187 /* DoStatement */)) { + case 101 /* WhileKeyword */: + case 76 /* DoKeyword */: + if (hasKind(node.parent, 195 /* WhileStatement */) || hasKind(node.parent, 194 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 114 /* ConstructorKeyword */: - if (hasKind(node.parent, 137 /* Constructor */)) { + case 118 /* ConstructorKeyword */: + if (hasKind(node.parent, 141 /* Constructor */)) { return getConstructorOccurrences(node.parent); } break; - case 116 /* GetKeyword */: - case 122 /* SetKeyword */: - if (hasKind(node.parent, 138 /* GetAccessor */) || hasKind(node.parent, 139 /* SetAccessor */)) { + case 120 /* GetKeyword */: + case 126 /* SetKeyword */: + if (hasKind(node.parent, 142 /* GetAccessor */) || hasKind(node.parent, 143 /* SetAccessor */)) { return getGetAndSetOccurrences(node.parent); } default: if (ts.isModifier(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 183 /* VariableStatement */)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 190 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -41199,10 +43782,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 198 /* ThrowStatement */) { + if (node.kind === 205 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 199 /* TryStatement */) { + else if (node.kind === 206 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -41230,19 +43813,19 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_11 = child.parent; - if (ts.isFunctionBlock(parent_11) || parent_11.kind === 230 /* SourceFile */) { - return parent_11; + var parent_13 = child.parent; + if (ts.isFunctionBlock(parent_13) || parent_13.kind === 245 /* SourceFile */) { + return parent_13; } // A throw-statement is only owned by a try-statement if the try-statement has // a catch clause, and if the throw-statement occurs within the try block. - if (parent_11.kind === 199 /* TryStatement */) { - var tryStatement = parent_11; + if (parent_13.kind === 206 /* TryStatement */) { + var tryStatement = parent_13; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_11; + child = parent_13; } return undefined; } @@ -41251,7 +43834,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 193 /* BreakStatement */ || node.kind === 192 /* ContinueStatement */) { + if (node.kind === 200 /* BreakStatement */ || node.kind === 199 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -41267,16 +43850,16 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { switch (node_2.kind) { - case 196 /* SwitchStatement */: - if (statement.kind === 192 /* ContinueStatement */) { + case 203 /* SwitchStatement */: + if (statement.kind === 199 /* ContinueStatement */) { continue; } // Fall through. - case 189 /* ForStatement */: - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: - case 188 /* WhileStatement */: - case 187 /* DoStatement */: + case 196 /* ForStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: + case 195 /* WhileStatement */: + case 194 /* DoStatement */: if (!statement.label || isLabeledBy(node_2, statement.label.text)) { return node_2; } @@ -41295,18 +43878,18 @@ var ts; var container = declaration.parent; // Make sure we only highlight the keyword when it makes sense to do so. if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 204 /* ClassDeclaration */ || - (declaration.kind === 131 /* Parameter */ && hasKind(container, 137 /* Constructor */)))) { + if (!(container.kind === 211 /* ClassDeclaration */ || + (declaration.kind === 135 /* Parameter */ && hasKind(container, 141 /* Constructor */)))) { return undefined; } } - else if (modifier === 109 /* StaticKeyword */) { - if (container.kind !== 204 /* ClassDeclaration */) { + else if (modifier === 110 /* StaticKeyword */) { + if (container.kind !== 211 /* ClassDeclaration */) { return undefined; } } - else if (modifier === 78 /* ExportKeyword */ || modifier === 115 /* DeclareKeyword */) { - if (!(container.kind === 209 /* ModuleBlock */ || container.kind === 230 /* SourceFile */)) { + else if (modifier === 79 /* ExportKeyword */ || modifier === 119 /* DeclareKeyword */) { + if (!(container.kind === 216 /* ModuleBlock */ || container.kind === 245 /* SourceFile */)) { return undefined; } } @@ -41318,20 +43901,20 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 209 /* ModuleBlock */: - case 230 /* SourceFile */: + case 216 /* ModuleBlock */: + case 245 /* SourceFile */: nodes = container.statements; break; - case 137 /* Constructor */: + case 141 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; - case 204 /* ClassDeclaration */: + case 211 /* ClassDeclaration */: nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. if (modifierFlag & 112 /* AccessibilityModifier */) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 137 /* Constructor */ && member; + return member.kind === 141 /* Constructor */ && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -41349,17 +43932,17 @@ var ts; return ts.map(keywords, getHighlightSpanForNode); function getFlagFromModifier(modifier) { switch (modifier) { - case 108 /* PublicKeyword */: + case 109 /* PublicKeyword */: return 16 /* Public */; - case 106 /* PrivateKeyword */: + case 107 /* PrivateKeyword */: return 32 /* Private */; - case 107 /* ProtectedKeyword */: + case 108 /* ProtectedKeyword */: return 64 /* Protected */; - case 109 /* StaticKeyword */: + case 110 /* StaticKeyword */: return 128 /* Static */; - case 78 /* ExportKeyword */: + case 79 /* ExportKeyword */: return 1 /* Export */; - case 115 /* DeclareKeyword */: + case 119 /* DeclareKeyword */: return 2 /* Ambient */; default: ts.Debug.fail(); @@ -41379,13 +43962,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 138 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 139 /* SetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 142 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 143 /* SetAccessor */); return ts.map(keywords, getHighlightSpanForNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 116 /* GetKeyword */, 122 /* SetKeyword */); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 120 /* GetKeyword */, 126 /* SetKeyword */); }); } } } @@ -41394,19 +43977,19 @@ var ts; var keywords = []; ts.forEach(declarations, function (declaration) { ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 114 /* ConstructorKeyword */); + return pushKeywordIf(keywords, token, 118 /* ConstructorKeyword */); }); }); return ts.map(keywords, getHighlightSpanForNode); } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 82 /* ForKeyword */, 100 /* WhileKeyword */, 75 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 83 /* ForKeyword */, 101 /* WhileKeyword */, 76 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 187 /* DoStatement */) { + if (loopNode.kind === 194 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 100 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 101 /* WhileKeyword */)) { break; } } @@ -41415,7 +43998,7 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 66 /* BreakKeyword */, 71 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 67 /* BreakKeyword */, 72 /* ContinueKeyword */); } }); return ts.map(keywords, getHighlightSpanForNode); @@ -41424,13 +44007,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 189 /* ForStatement */: - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: - case 187 /* DoStatement */: - case 188 /* WhileStatement */: + case 196 /* ForStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: + case 194 /* DoStatement */: + case 195 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 196 /* SwitchStatement */: + case 203 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -41438,14 +44021,14 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 92 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 93 /* SwitchKeyword */); // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 67 /* CaseKeyword */, 73 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 68 /* CaseKeyword */, 74 /* DefaultKeyword */); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 66 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 67 /* BreakKeyword */); } }); }); @@ -41453,13 +44036,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 96 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 97 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 68 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 69 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 81 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 81 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 82 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 82 /* FinallyKeyword */); } return ts.map(keywords, getHighlightSpanForNode); } @@ -41470,13 +44053,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 94 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 95 /* ThrowKeyword */); }); // If the "owner" is a function, then we equate 'return' and 'throw' statements in their // ability to "jump out" of the function, and include occurrences for both. if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 90 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 91 /* ReturnKeyword */); }); } return ts.map(keywords, getHighlightSpanForNode); @@ -41484,36 +44067,36 @@ var ts; function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); // If we didn't find a containing function with a block body, bail out. - if (!(func && hasKind(func.body, 182 /* Block */))) { + if (!(func && hasKind(func.body, 189 /* Block */))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 90 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 91 /* ReturnKeyword */); }); // Include 'throw' statements that do not occur within a try block. ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 94 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 95 /* ThrowKeyword */); }); return ts.map(keywords, getHighlightSpanForNode); } function getIfElseOccurrences(ifStatement) { var keywords = []; // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 186 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 193 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. while (ifStatement) { var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 84 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 85 /* IfKeyword */); // Generally the 'else' keyword is second-to-last, so we traverse backwards. for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 76 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 77 /* ElseKeyword */)) { break; } } - if (!hasKind(ifStatement.elseStatement, 186 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 193 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -41522,7 +44105,7 @@ var ts; // We'd like to highlight else/ifs together if they are only separated by whitespace // (i.e. the keywords are separated by no comments, no newlines). for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 76 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 77 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombindElseAndIf = true; @@ -41604,7 +44187,7 @@ var ts; if (!node) { return undefined; } - if (node.kind !== 65 /* Identifier */ && + if (node.kind !== 66 /* Identifier */ && // TODO (drosen): This should be enabled in a later release - currently breaks rename. //node.kind !== SyntaxKind.ThisKeyword && //node.kind !== SyntaxKind.SuperKeyword && @@ -41612,10 +44195,10 @@ var ts; !isNameOfExternalModuleImportOrDeclaration(node)) { return undefined; } - ts.Debug.assert(node.kind === 65 /* Identifier */ || node.kind === 7 /* NumericLiteral */ || node.kind === 8 /* StringLiteral */); - return getReferencedSymbolsForNodes(node, program.getSourceFiles(), findInStrings, findInComments); + ts.Debug.assert(node.kind === 66 /* Identifier */ || node.kind === 7 /* NumericLiteral */ || node.kind === 8 /* StringLiteral */); + return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); } - function getReferencedSymbolsForNodes(node, sourceFiles, findInStrings, findInComments) { + function getReferencedSymbolsForNode(node, sourceFiles, findInStrings, findInComments) { var typeChecker = program.getTypeChecker(); // Labels if (isLabelName(node)) { @@ -41630,10 +44213,10 @@ var ts; return getLabelReferencesInNode(node.parent, node); } } - if (node.kind === 93 /* ThisKeyword */) { + if (node.kind === 94 /* ThisKeyword */) { return getReferencesForThisKeyword(node, sourceFiles); } - if (node.kind === 91 /* SuperKeyword */) { + if (node.kind === 92 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } var symbol = typeChecker.getSymbolAtLocation(node); @@ -41643,15 +44226,16 @@ var ts; return undefined; } var declarations = symbol.declarations; - // The symbol was an internal symbol and does not have a declaration e.g.undefined symbol + // The symbol was an internal symbol and does not have a declaration e.g. undefined symbol if (!declarations || !declarations.length) { return undefined; } var result; // Compute the meaning from the location and the symbol it references var searchMeaning = getIntersectingMeaningFromDeclarations(getMeaningFromLocation(node), declarations); - // Get the text to search for, we need to normalize it as external module names will have quote - var declaredName = getDeclaredName(symbol, node); + // Get the text to search for. + // Note: if this is an external module symbol, the name doesn't include quotes. + var declaredName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); // Try to get the smallest valid scope that we can limit our search to; // otherwise we'll need to search globally (i.e. include each file). var scope = getSymbolScope(symbol); @@ -41690,70 +44274,43 @@ var ts; textSpan: ts.createTextSpan(declarations[0].getStart(), 0) }; } - function isImportOrExportSpecifierName(location) { - return location.parent && - (location.parent.kind === 216 /* ImportSpecifier */ || location.parent.kind === 220 /* ExportSpecifier */) && - location.parent.propertyName === location; - } function isImportOrExportSpecifierImportSymbol(symbol) { return (symbol.flags & 8388608 /* Alias */) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 216 /* ImportSpecifier */ || declaration.kind === 220 /* ExportSpecifier */; + return declaration.kind === 223 /* ImportSpecifier */ || declaration.kind === 227 /* ExportSpecifier */; }); } - function getDeclaredName(symbol, location) { - // Special case for function expressions, whose names are solely local to their bodies. - var functionExpression = ts.forEach(symbol.declarations, function (d) { return d.kind === 165 /* FunctionExpression */ ? d : undefined; }); - // When a name gets interned into a SourceFile's 'identifiers' Map, - // its name is escaped and stored in the same way its symbol name/identifier - // name should be stored. Function expressions, however, are a special case, - // because despite sometimes having a name, the binder unconditionally binds them - // to a symbol with the name "__function". - var name; - if (functionExpression && functionExpression.name) { - name = functionExpression.name.text; - } - // If this is an export or import specifier it could have been renamed using the as syntax. - // if so we want to search for whatever under the cursor, the symbol is pointing to the alias (name) - // so check for the propertyName. - if (isImportOrExportSpecifierName(location)) { - return location.getText(); - } - name = typeChecker.symbolToString(symbol); - return stripQuotes(name); - } function getInternedName(symbol, location, declarations) { - // If this is an export or import specifier it could have been renamed using the as syntax. - // if so we want to search for whatever under the cursor, the symbol is pointing to the alias (name) - // so check for the propertyName. - if (isImportOrExportSpecifierName(location)) { + // If this is an export or import specifier it could have been renamed using the 'as' syntax. + // If so we want to search for whatever under the cursor. + if (ts.isImportOrExportSpecifierName(location)) { return location.getText(); } - // Special case for function expressions, whose names are solely local to their bodies. - var functionExpression = ts.forEach(declarations, function (d) { return d.kind === 165 /* FunctionExpression */ ? d : undefined; }); - // When a name gets interned into a SourceFile's 'identifiers' Map, - // its name is escaped and stored in the same way its symbol name/identifier - // name should be stored. Function expressions, however, are a special case, - // because despite sometimes having a name, the binder unconditionally binds them - // to a symbol with the name "__function". - var name = functionExpression && functionExpression.name - ? functionExpression.name.text - : symbol.name; - return stripQuotes(name); - } - function stripQuotes(name) { - var length = name.length; - if (length >= 2 && name.charCodeAt(0) === 34 /* doubleQuote */ && name.charCodeAt(length - 1) === 34 /* doubleQuote */) { - return name.substring(1, length - 1); - } - ; - return name; + // Try to get the local symbol if we're dealing with an 'export default' + // since that symbol has the "true" name. + var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); + symbol = localExportDefaultSymbol || symbol; + return ts.stripQuotes(symbol.name); } + /** + * Determines the smallest scope in which a symbol may have named references. + * Note that not every construct has been accounted for. This function can + * probably be improved. + * + * @returns undefined if the scope cannot be determined, implying that + * a reference to a symbol can occur anywhere. + */ function getSymbolScope(symbol) { + // If this is the symbol of a named function expression or named class expression, + // then named references are limited to its own scope. + var valueDeclaration = symbol.valueDeclaration; + if (valueDeclaration && (valueDeclaration.kind === 170 /* FunctionExpression */ || valueDeclaration.kind === 183 /* ClassExpression */)) { + return valueDeclaration; + } // If this is private property or method, the scope is the containing class if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32 /* Private */) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 204 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 211 /* ClassDeclaration */); } } // If the symbol is an import we would like to find it if we are looking for what it imports. @@ -41763,7 +44320,7 @@ var ts; } // if this symbol is visible from its parent container, e.g. exported, then bail out // if symbol correspond to the union property - bail out - if (symbol.parent || (symbol.flags & 268435456 /* UnionProperty */)) { + if (symbol.parent || (symbol.flags & 268435456 /* SyntheticProperty */)) { return undefined; } var scope = undefined; @@ -41779,7 +44336,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (container.kind === 230 /* SourceFile */ && !ts.isExternalModule(container)) { + if (container.kind === 245 /* SourceFile */ && !ts.isExternalModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -41850,7 +44407,7 @@ var ts; if (node) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 65 /* Identifier */: + case 66 /* Identifier */: return node.getWidth() === searchSymbolName.length; case 8 /* StringLiteral */: if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || @@ -41967,13 +44524,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 137 /* Constructor */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 141 /* Constructor */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -41986,7 +44543,7 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 91 /* SuperKeyword */) { + if (!node || node.kind !== 92 /* SuperKeyword */) { return; } var container = ts.getSuperContainer(node, false); @@ -42005,27 +44562,27 @@ var ts; // Whether 'this' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // fall through - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: - case 137 /* Constructor */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: + case 141 /* Constructor */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 230 /* SourceFile */: + case 245 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // Fall through - case 203 /* FunctionDeclaration */: - case 165 /* FunctionExpression */: + case 210 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: break; // Computed properties in classes are not handled here because references to this are illegal, // so there is no point finding references to them. @@ -42034,7 +44591,7 @@ var ts; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 230 /* SourceFile */) { + if (searchSpaceNode.kind === 245 /* SourceFile */) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -42060,32 +44617,32 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 93 /* ThisKeyword */) { + if (!node || node.kind !== 94 /* ThisKeyword */) { return; } var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { - case 165 /* FunctionExpression */: - case 203 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: + case 210 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 204 /* ClassDeclaration */: + case 211 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128 /* Static */) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 230 /* SourceFile */: - if (container.kind === 230 /* SourceFile */ && !ts.isExternalModule(container)) { + case 245 /* SourceFile */: + if (container.kind === 245 /* SourceFile */ && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -42105,7 +44662,7 @@ var ts; // type to the search set if (isNameOfPropertyAssignment(location)) { ts.forEach(getPropertySymbolsFromContextualType(location), function (contextualSymbol) { - result.push.apply(result, typeChecker.getRootSymbols(contextualSymbol)); + ts.addRange(result, typeChecker.getRootSymbols(contextualSymbol)); }); /* Because in short-hand property assignment, location has two meaning : property name and as value of the property * When we do findAllReference at the position of the short-hand property assignment, we would want to have references to position of @@ -42139,11 +44696,11 @@ var ts; function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { if (symbol && symbol.flags & (32 /* Class */ | 64 /* Interface */)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 204 /* ClassDeclaration */) { + if (declaration.kind === 211 /* ClassDeclaration */) { getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 205 /* InterfaceDeclaration */) { + else if (declaration.kind === 212 /* InterfaceDeclaration */) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -42204,19 +44761,19 @@ var ts; if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeChecker.getContextualType(objectLiteral); - var name_28 = node.text; + var name_32 = node.text; if (contextualType) { if (contextualType.flags & 16384 /* Union */) { // This is a union type, first see if the property we are looking for is a union property (i.e. exists in all types) // if not, search the constituent types for the property - var unionProperty = contextualType.getProperty(name_28); + var unionProperty = contextualType.getProperty(name_32); if (unionProperty) { return [unionProperty]; } else { var result_4 = []; ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name_28); + var symbol = t.getProperty(name_32); if (symbol) { result_4.push(symbol); } @@ -42225,7 +44782,7 @@ var ts; } } else { - var symbol_1 = contextualType.getProperty(name_28); + var symbol_1 = contextualType.getProperty(name_32); if (symbol_1) { return [symbol_1]; } @@ -42278,17 +44835,17 @@ var ts; } /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ function isWriteAccess(node) { - if (node.kind === 65 /* Identifier */ && ts.isDeclarationName(node)) { + if (node.kind === 66 /* Identifier */ && ts.isDeclarationName(node)) { return true; } var parent = node.parent; if (parent) { - if (parent.kind === 171 /* PostfixUnaryExpression */ || parent.kind === 170 /* PrefixUnaryExpression */) { + if (parent.kind === 177 /* PostfixUnaryExpression */ || parent.kind === 176 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 172 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 178 /* BinaryExpression */ && parent.left === node) { var operator = parent.operatorToken.kind; - return 53 /* FirstAssignment */ <= operator && operator <= 64 /* LastAssignment */; + return 54 /* FirstAssignment */ <= operator && operator <= 65 /* LastAssignment */; } } return false; @@ -42312,7 +44869,7 @@ var ts; text: data }); } - var emitOutput = program.emit(sourceFile, writeFile); + var emitOutput = program.emit(sourceFile, writeFile, cancellationToken); return { outputFiles: outputFiles, emitSkipped: emitOutput.emitSkipped @@ -42320,33 +44877,33 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 131 /* Parameter */: - case 201 /* VariableDeclaration */: - case 155 /* BindingElement */: - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: - case 227 /* PropertyAssignment */: - case 228 /* ShorthandPropertyAssignment */: - case 229 /* EnumMember */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 137 /* Constructor */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 203 /* FunctionDeclaration */: - case 165 /* FunctionExpression */: - case 166 /* ArrowFunction */: - case 226 /* CatchClause */: + case 135 /* Parameter */: + case 208 /* VariableDeclaration */: + case 160 /* BindingElement */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: + case 242 /* PropertyAssignment */: + case 243 /* ShorthandPropertyAssignment */: + case 244 /* EnumMember */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 141 /* Constructor */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 210 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: + case 241 /* CatchClause */: return 1 /* Value */; - case 130 /* TypeParameter */: - case 205 /* InterfaceDeclaration */: - case 206 /* TypeAliasDeclaration */: - case 148 /* TypeLiteral */: + case 134 /* TypeParameter */: + case 212 /* InterfaceDeclaration */: + case 213 /* TypeAliasDeclaration */: + case 152 /* TypeLiteral */: return 2 /* Type */; - case 204 /* ClassDeclaration */: - case 207 /* EnumDeclaration */: + case 211 /* ClassDeclaration */: + case 214 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: if (node.name.kind === 8 /* StringLiteral */) { return 4 /* Namespace */ | 1 /* Value */; } @@ -42356,15 +44913,15 @@ var ts; else { return 4 /* Namespace */; } - case 215 /* NamedImports */: - case 216 /* ImportSpecifier */: - case 211 /* ImportEqualsDeclaration */: - case 212 /* ImportDeclaration */: - case 217 /* ExportAssignment */: - case 218 /* ExportDeclaration */: + case 222 /* NamedImports */: + case 223 /* ImportSpecifier */: + case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportDeclaration */: + case 224 /* ExportAssignment */: + case 225 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 230 /* SourceFile */: + case 245 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; @@ -42374,8 +44931,8 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 144 /* TypeReference */ || - (node.parent.kind === 179 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); + return node.parent.kind === 148 /* TypeReference */ || + (node.parent.kind === 185 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); } function isNamespaceReference(node) { return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); @@ -42383,50 +44940,50 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 158 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 158 /* PropertyAccessExpression */) { + if (root.parent.kind === 163 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 163 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 179 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 225 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 185 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 240 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 204 /* ClassDeclaration */ && root.parent.parent.token === 102 /* ImplementsKeyword */) || - (decl.kind === 205 /* InterfaceDeclaration */ && root.parent.parent.token === 79 /* ExtendsKeyword */); + return (decl.kind === 211 /* ClassDeclaration */ && root.parent.parent.token === 103 /* ImplementsKeyword */) || + (decl.kind === 212 /* InterfaceDeclaration */ && root.parent.parent.token === 80 /* ExtendsKeyword */); } return false; } function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 128 /* QualifiedName */) { - while (root.parent && root.parent.kind === 128 /* QualifiedName */) { + if (root.parent.kind === 132 /* QualifiedName */) { + while (root.parent && root.parent.kind === 132 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 144 /* TypeReference */ && !isLastClause; + return root.parent.kind === 148 /* TypeReference */ && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 128 /* QualifiedName */) { + while (node.parent.kind === 132 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; } function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 65 /* Identifier */); + ts.Debug.assert(node.kind === 66 /* Identifier */); // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (node.parent.kind === 128 /* QualifiedName */ && + if (node.parent.kind === 132 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 211 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 218 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function getMeaningFromLocation(node) { - if (node.parent.kind === 217 /* ExportAssignment */) { + if (node.parent.kind === 224 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -42466,15 +45023,15 @@ var ts; return; } switch (node.kind) { - case 158 /* PropertyAccessExpression */: - case 128 /* QualifiedName */: + case 163 /* PropertyAccessExpression */: + case 132 /* QualifiedName */: case 8 /* StringLiteral */: - case 80 /* FalseKeyword */: - case 95 /* TrueKeyword */: - case 89 /* NullKeyword */: - case 91 /* SuperKeyword */: - case 93 /* ThisKeyword */: - case 65 /* Identifier */: + case 81 /* FalseKeyword */: + case 96 /* TrueKeyword */: + case 90 /* NullKeyword */: + case 92 /* SuperKeyword */: + case 94 /* ThisKeyword */: + case 66 /* Identifier */: break; // Cant create the text span default: @@ -42490,7 +45047,7 @@ var ts; // If this is name of a module declarations, check if this is right side of dotted module name // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of // Then this name is name from dotted module - if (nodeForStartPos.parent.parent.kind === 208 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 215 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -42519,6 +45076,25 @@ var ts; function getSemanticClassifications(fileName, span) { return convertClassifications(getEncodedSemanticClassifications(fileName, span)); } + function checkForClassificationCancellation(kind) { + // We don't want to actually call back into our host on every node to find out if we've + // been canceled. That would be an enormous amount of chattyness, along with the all + // the overhead of marshalling the data to/from the host. So instead we pick a few + // reasonable node kinds to bother checking on. These node kinds represent high level + // constructs that we would expect to see commonly, but just at a far less frequent + // interval. + // + // For example, in checker.ts (around 750k) we only have around 600 of these constructs. + // That means we're calling back into the host around every 1.2k of the file we process. + // Lib.d.ts has similar numbers. + switch (kind) { + case 215 /* ModuleDeclaration */: + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: + case 210 /* FunctionDeclaration */: + cancellationToken.throwIfCancellationRequested(); + } + } function getEncodedSemanticClassifications(fileName, span) { synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); @@ -42569,7 +45145,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 208 /* ModuleDeclaration */ && + return declaration.kind === 215 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } @@ -42577,7 +45153,9 @@ var ts; function processNode(node) { // Only walk into nodes that intersect the requested span. if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { - if (node.kind === 65 /* Identifier */ && !ts.nodeIsMissing(node)) { + var kind = node.kind; + checkForClassificationCancellation(kind); + if (kind === 66 /* Identifier */ && !ts.nodeIsMissing(node)) { var identifier = node; // Only bother calling into the typechecker if this is an identifier that // could possibly resolve to a type name. This makes classification run @@ -42638,8 +45216,8 @@ var ts; var spanStart = span.start; var spanLength = span.length; // Make a scanner we can get trivia from. - var triviaScanner = ts.createScanner(2 /* Latest */, false, sourceFile.text); - var mergeConflictScanner = ts.createScanner(2 /* Latest */, false, sourceFile.text); + var triviaScanner = ts.createScanner(2 /* Latest */, false, sourceFile.languageVariant, sourceFile.text); + var mergeConflictScanner = ts.createScanner(2 /* Latest */, false, sourceFile.languageVariant, sourceFile.text); var result = []; processElement(sourceFile); return { spans: result, endOfLineState: 0 /* None */ }; @@ -42722,16 +45300,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); pos = tag.tagName.end; switch (tag.kind) { - case 249 /* JSDocParameterTag */: + case 264 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 252 /* JSDocTemplateTag */: + case 267 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); break; - case 251 /* JSDocTypeTag */: + case 266 /* JSDocTypeTag */: processElement(tag.typeExpression); break; - case 250 /* JSDocReturnTag */: + case 265 /* JSDocReturnTag */: processElement(tag.typeExpression); break; } @@ -42811,7 +45389,7 @@ var ts; } // Special case < and > If they appear in a generic context they are punctuation, // not operators. - if (tokenKind === 24 /* LessThanToken */ || tokenKind === 25 /* GreaterThanToken */) { + if (tokenKind === 24 /* LessThanToken */ || tokenKind === 26 /* GreaterThanToken */) { // If the node owning the token has a type argument list or type parameter list, then // we can effectively assume that a '<' and '>' belong to those lists. if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { @@ -42820,18 +45398,18 @@ var ts; } if (ts.isPunctuation(tokenKind)) { if (token) { - if (tokenKind === 53 /* EqualsToken */) { + if (tokenKind === 54 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 201 /* VariableDeclaration */ || - token.parent.kind === 134 /* PropertyDeclaration */ || - token.parent.kind === 131 /* Parameter */) { + if (token.parent.kind === 208 /* VariableDeclaration */ || + token.parent.kind === 138 /* PropertyDeclaration */ || + token.parent.kind === 135 /* Parameter */) { return 5 /* operator */; } } - if (token.parent.kind === 172 /* BinaryExpression */ || - token.parent.kind === 170 /* PrefixUnaryExpression */ || - token.parent.kind === 171 /* PostfixUnaryExpression */ || - token.parent.kind === 173 /* ConditionalExpression */) { + if (token.parent.kind === 178 /* BinaryExpression */ || + token.parent.kind === 176 /* PrefixUnaryExpression */ || + token.parent.kind === 177 /* PostfixUnaryExpression */ || + token.parent.kind === 179 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -42851,35 +45429,35 @@ var ts; // TODO (drosen): we should *also* get another classification type for these literals. return 6 /* stringLiteral */; } - else if (tokenKind === 65 /* Identifier */) { + else if (tokenKind === 66 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 204 /* ClassDeclaration */: + case 211 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 130 /* TypeParameter */: + case 134 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 205 /* InterfaceDeclaration */: + case 212 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 207 /* EnumDeclaration */: + case 214 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 131 /* Parameter */: + case 135 /* Parameter */: if (token.parent.name === token) { return 17 /* parameterName */; } @@ -42895,6 +45473,7 @@ var ts; } // Ignore nodes that don't intersect the original span to classify. if (ts.decodedTextSpanIntersectsWith(spanStart, spanLength, element.pos, element.getFullWidth())) { + checkForClassificationCancellation(element.kind); var children = element.getChildren(sourceFile); for (var i = 0, n = children.length; i < n; i++) { var child = children[i]; @@ -42947,11 +45526,11 @@ var ts; case 14 /* OpenBraceToken */: return 15 /* CloseBraceToken */; case 16 /* OpenParenToken */: return 17 /* CloseParenToken */; case 18 /* OpenBracketToken */: return 19 /* CloseBracketToken */; - case 24 /* LessThanToken */: return 25 /* GreaterThanToken */; + case 24 /* LessThanToken */: return 26 /* GreaterThanToken */; case 15 /* CloseBraceToken */: return 14 /* OpenBraceToken */; case 17 /* CloseParenToken */: return 16 /* OpenParenToken */; case 19 /* CloseBracketToken */: return 18 /* OpenBracketToken */; - case 25 /* GreaterThanToken */: return 24 /* LessThanToken */; + case 26 /* GreaterThanToken */: return 24 /* LessThanToken */; } return undefined; } @@ -43116,7 +45695,7 @@ var ts; var typeChecker = program.getTypeChecker(); var node = ts.getTouchingWord(sourceFile, position); // Can only rename an identifier. - if (node && node.kind === 65 /* Identifier */) { + if (node && node.kind === 66 /* Identifier */) { var symbol = typeChecker.getSymbolAtLocation(node); // Only allow a symbol to be renamed if it actually has at least one declaration. if (symbol) { @@ -43128,17 +45707,19 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var current = declarations[_i]; var sourceFile_2 = current.getSourceFile(); + var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)); if (sourceFile_2 && getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)) === getCanonicalFileName(ts.normalizePath(defaultLibFileName))) { return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library.key)); } } } + var displayName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); var kind = getSymbolKind(symbol, node); if (kind) { return { canRename: true, localizedErrorMessage: undefined, - displayName: symbol.name, + displayName: displayName, fullDisplayName: typeChecker.getFullyQualifiedName(symbol), kind: kind, kindModifiers: getSymbolModifiers(symbol), @@ -43214,7 +45795,7 @@ var ts; sourceFile.nameTable = nameTable; function walk(node) { switch (node.kind) { - case 65 /* Identifier */: + case 66 /* Identifier */: nameTable[node.text] = node.text; break; case 8 /* StringLiteral */: @@ -43224,7 +45805,7 @@ var ts; // then we want 'something' to be in the name table. Similarly, if we have // "a['propname']" then we want to store "propname" in the name table. if (ts.isDeclarationName(node) || - node.parent.kind === 222 /* ExternalModuleReference */ || + node.parent.kind === 229 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node)) { nameTable[node.text] = node.text; } @@ -43237,7 +45818,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 159 /* ElementAccessExpression */ && + node.parent.kind === 164 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /// Classifier @@ -43248,18 +45829,18 @@ var ts; /// we have a series of divide operator. this list allows us to be more accurate by ruling out /// locations where a regexp cannot exist. var noRegexTable = []; - noRegexTable[65 /* Identifier */] = true; + noRegexTable[66 /* Identifier */] = true; noRegexTable[8 /* StringLiteral */] = true; noRegexTable[7 /* NumericLiteral */] = true; noRegexTable[9 /* RegularExpressionLiteral */] = true; - noRegexTable[93 /* ThisKeyword */] = true; - noRegexTable[38 /* PlusPlusToken */] = true; - noRegexTable[39 /* MinusMinusToken */] = true; + noRegexTable[94 /* ThisKeyword */] = true; + noRegexTable[39 /* PlusPlusToken */] = true; + noRegexTable[40 /* MinusMinusToken */] = true; noRegexTable[17 /* CloseParenToken */] = true; noRegexTable[19 /* CloseBracketToken */] = true; noRegexTable[15 /* CloseBraceToken */] = true; - noRegexTable[95 /* TrueKeyword */] = true; - noRegexTable[80 /* FalseKeyword */] = true; + noRegexTable[96 /* TrueKeyword */] = true; + noRegexTable[81 /* FalseKeyword */] = true; // Just a stack of TemplateHeads and OpenCurlyBraces, used to perform rudimentary (inexact) // classification on template strings. Because of the context free nature of templates, // the only precise way to classify a template portion would be by propagating the stack across @@ -43284,10 +45865,10 @@ var ts; /** Returns true if 'keyword2' can legally follow 'keyword1' in any language construct. */ function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { - if (keyword2 === 116 /* GetKeyword */ || - keyword2 === 122 /* SetKeyword */ || - keyword2 === 114 /* ConstructorKeyword */ || - keyword2 === 109 /* StaticKeyword */) { + if (keyword2 === 120 /* GetKeyword */ || + keyword2 === 126 /* SetKeyword */ || + keyword2 === 118 /* ConstructorKeyword */ || + keyword2 === 110 /* StaticKeyword */) { // Allow things like "public get", "public constructor" and "public static". // These are all legal. return true; @@ -43417,42 +45998,42 @@ var ts; do { token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 36 /* SlashToken */ || token === 57 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { + if ((token === 37 /* SlashToken */ || token === 58 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { if (scanner.reScanSlashToken() === 9 /* RegularExpressionLiteral */) { token = 9 /* RegularExpressionLiteral */; } } else if (lastNonTriviaToken === 20 /* DotToken */ && isKeyword(token)) { - token = 65 /* Identifier */; + token = 66 /* Identifier */; } else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { // We have two keywords in a row. Only treat the second as a keyword if // it's a sequence that could legally occur in the language. Otherwise // treat it as an identifier. This way, if someone writes "private var" // we recognize that 'var' is actually an identifier here. - token = 65 /* Identifier */; + token = 66 /* Identifier */; } - else if (lastNonTriviaToken === 65 /* Identifier */ && + else if (lastNonTriviaToken === 66 /* Identifier */ && token === 24 /* LessThanToken */) { // Could be the start of something generic. Keep track of that by bumping // up the current count of generic contexts we may be in. angleBracketStack++; } - else if (token === 25 /* GreaterThanToken */ && angleBracketStack > 0) { + else if (token === 26 /* GreaterThanToken */ && angleBracketStack > 0) { // If we think we're currently in something generic, then mark that that // generic entity is complete. angleBracketStack--; } - else if (token === 112 /* AnyKeyword */ || - token === 123 /* StringKeyword */ || - token === 121 /* NumberKeyword */ || - token === 113 /* BooleanKeyword */ || - token === 124 /* SymbolKeyword */) { + else if (token === 114 /* AnyKeyword */ || + token === 127 /* StringKeyword */ || + token === 125 /* NumberKeyword */ || + token === 117 /* BooleanKeyword */ || + token === 128 /* SymbolKeyword */) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, // causing a noisy experience for the user. - token = 65 /* Identifier */; + token = 66 /* Identifier */; } } else if (token === 11 /* TemplateHead */) { @@ -43563,41 +46144,41 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 35 /* AsteriskToken */: - case 36 /* SlashToken */: - case 37 /* PercentToken */: - case 33 /* PlusToken */: - case 34 /* MinusToken */: - case 40 /* LessThanLessThanToken */: - case 41 /* GreaterThanGreaterThanToken */: - case 42 /* GreaterThanGreaterThanGreaterThanToken */: + case 36 /* AsteriskToken */: + case 37 /* SlashToken */: + case 38 /* PercentToken */: + case 34 /* PlusToken */: + case 35 /* MinusToken */: + case 41 /* LessThanLessThanToken */: + case 42 /* GreaterThanGreaterThanToken */: + case 43 /* GreaterThanGreaterThanGreaterThanToken */: case 24 /* LessThanToken */: - case 25 /* GreaterThanToken */: - case 26 /* LessThanEqualsToken */: - case 27 /* GreaterThanEqualsToken */: - case 87 /* InstanceOfKeyword */: - case 86 /* InKeyword */: - case 28 /* EqualsEqualsToken */: - case 29 /* ExclamationEqualsToken */: - case 30 /* EqualsEqualsEqualsToken */: - case 31 /* ExclamationEqualsEqualsToken */: - case 43 /* AmpersandToken */: - case 45 /* CaretToken */: - case 44 /* BarToken */: - case 48 /* AmpersandAmpersandToken */: - case 49 /* BarBarToken */: - case 63 /* BarEqualsToken */: - case 62 /* AmpersandEqualsToken */: - case 64 /* CaretEqualsToken */: - case 59 /* LessThanLessThanEqualsToken */: - case 60 /* GreaterThanGreaterThanEqualsToken */: - case 61 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 54 /* PlusEqualsToken */: - case 55 /* MinusEqualsToken */: - case 56 /* AsteriskEqualsToken */: - case 57 /* SlashEqualsToken */: - case 58 /* PercentEqualsToken */: - case 53 /* EqualsToken */: + case 26 /* GreaterThanToken */: + case 27 /* LessThanEqualsToken */: + case 28 /* GreaterThanEqualsToken */: + case 88 /* InstanceOfKeyword */: + case 87 /* InKeyword */: + case 29 /* EqualsEqualsToken */: + case 30 /* ExclamationEqualsToken */: + case 31 /* EqualsEqualsEqualsToken */: + case 32 /* ExclamationEqualsEqualsToken */: + case 44 /* AmpersandToken */: + case 46 /* CaretToken */: + case 45 /* BarToken */: + case 49 /* AmpersandAmpersandToken */: + case 50 /* BarBarToken */: + case 64 /* BarEqualsToken */: + case 63 /* AmpersandEqualsToken */: + case 65 /* CaretEqualsToken */: + case 60 /* LessThanLessThanEqualsToken */: + case 61 /* GreaterThanGreaterThanEqualsToken */: + case 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 55 /* PlusEqualsToken */: + case 56 /* MinusEqualsToken */: + case 57 /* AsteriskEqualsToken */: + case 58 /* SlashEqualsToken */: + case 59 /* PercentEqualsToken */: + case 54 /* EqualsToken */: case 23 /* CommaToken */: return true; default: @@ -43606,19 +46187,19 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 33 /* PlusToken */: - case 34 /* MinusToken */: - case 47 /* TildeToken */: - case 46 /* ExclamationToken */: - case 38 /* PlusPlusToken */: - case 39 /* MinusMinusToken */: + case 34 /* PlusToken */: + case 35 /* MinusToken */: + case 48 /* TildeToken */: + case 47 /* ExclamationToken */: + case 39 /* PlusPlusToken */: + case 40 /* MinusMinusToken */: return true; default: return false; } } function isKeyword(token) { - return token >= 66 /* FirstKeyword */ && token <= 127 /* LastKeyword */; + return token >= 67 /* FirstKeyword */ && token <= 131 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { @@ -43627,7 +46208,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 14 /* FirstPunctuation */ && token <= 64 /* LastPunctuation */) { + else if (token >= 14 /* FirstPunctuation */ && token <= 65 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { @@ -43644,7 +46225,7 @@ var ts; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 65 /* Identifier */: + case 66 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -43659,7 +46240,7 @@ var ts; } ts.createClassifier = createClassifier; /** - * Get the path of the default library file (lib.d.ts) as distributed with the typescript + * Get the path of the default library files (lib.d.ts) as distributed with the typescript * node package. * The functionality is not supported if the ts module is consumed outside of a node module. */ @@ -43676,10 +46257,10 @@ var ts; getNodeConstructor: function (kind) { function Node() { } - var proto = kind === 230 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); + var proto = kind === 245 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); proto.kind = kind; - proto.pos = 0; - proto.end = 0; + proto.pos = -1; + proto.end = -1; proto.flags = 0; proto.parent = undefined; Node.prototype = proto; @@ -43705,7 +46286,7 @@ var ts; */ function spanInSourceFileAtLocation(sourceFile, position) { // Cannot set breakpoint in dts file - if (sourceFile.flags & 2048 /* DeclarationFile */) { + if (sourceFile.flags & 8192 /* DeclarationFile */) { return undefined; } var tokenAtLocation = ts.getTokenAtPosition(sourceFile, position); @@ -43746,125 +46327,125 @@ var ts; function spanInNode(node) { if (node) { if (ts.isExpression(node)) { - if (node.parent.kind === 187 /* DoStatement */) { + if (node.parent.kind === 194 /* DoStatement */) { // Set span as if on while keyword return spanInPreviousNode(node); } - if (node.parent.kind === 189 /* ForStatement */) { + if (node.parent.kind === 196 /* ForStatement */) { // For now lets set the span on this expression, fix it later return textSpan(node); } - if (node.parent.kind === 172 /* BinaryExpression */ && node.parent.operatorToken.kind === 23 /* CommaToken */) { + if (node.parent.kind === 178 /* BinaryExpression */ && node.parent.operatorToken.kind === 23 /* CommaToken */) { // if this is comma expression, the breakpoint is possible in this expression return textSpan(node); } - if (node.parent.kind === 166 /* ArrowFunction */ && node.parent.body === node) { + if (node.parent.kind === 171 /* ArrowFunction */ && node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); } } switch (node.kind) { - case 183 /* VariableStatement */: + case 190 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 201 /* VariableDeclaration */: - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: + case 208 /* VariableDeclaration */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: return spanInVariableDeclaration(node); - case 131 /* Parameter */: + case 135 /* Parameter */: return spanInParameterDeclaration(node); - case 203 /* FunctionDeclaration */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 137 /* Constructor */: - case 165 /* FunctionExpression */: - case 166 /* ArrowFunction */: + case 210 /* FunctionDeclaration */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 141 /* Constructor */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 182 /* Block */: + case 189 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 209 /* ModuleBlock */: + case 216 /* ModuleBlock */: return spanInBlock(node); - case 226 /* CatchClause */: + case 241 /* CatchClause */: return spanInBlock(node.block); - case 185 /* ExpressionStatement */: + case 192 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 194 /* ReturnStatement */: + case 201 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 188 /* WhileStatement */: + case 195 /* WhileStatement */: // Span on while(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 187 /* DoStatement */: + case 194 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 200 /* DebuggerStatement */: + case 207 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 186 /* IfStatement */: + case 193 /* IfStatement */: // set on if(..) span return textSpan(node, ts.findNextToken(node.expression, node)); - case 197 /* LabeledStatement */: + case 204 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 193 /* BreakStatement */: - case 192 /* ContinueStatement */: + case 200 /* BreakStatement */: + case 199 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 189 /* ForStatement */: + case 196 /* ForStatement */: return spanInForStatement(node); - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: // span on for (a in ...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 196 /* SwitchStatement */: + case 203 /* SwitchStatement */: // span on switch(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 223 /* CaseClause */: - case 224 /* DefaultClause */: + case 238 /* CaseClause */: + case 239 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 199 /* TryStatement */: + case 206 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 198 /* ThrowStatement */: + case 205 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 217 /* ExportAssignment */: + case 224 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 211 /* ImportEqualsDeclaration */: + case 218 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 212 /* ImportDeclaration */: + case 219 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 218 /* ExportDeclaration */: + case 225 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 204 /* ClassDeclaration */: - case 207 /* EnumDeclaration */: - case 229 /* EnumMember */: - case 160 /* CallExpression */: - case 161 /* NewExpression */: + case 211 /* ClassDeclaration */: + case 214 /* EnumDeclaration */: + case 244 /* EnumMember */: + case 165 /* CallExpression */: + case 166 /* NewExpression */: // span on complete node return textSpan(node); - case 195 /* WithStatement */: + case 202 /* WithStatement */: // span in statement return spanInNode(node.statement); // No breakpoint in interface, type alias - case 205 /* InterfaceDeclaration */: - case 206 /* TypeAliasDeclaration */: + case 212 /* InterfaceDeclaration */: + case 213 /* TypeAliasDeclaration */: return undefined; // Tokens: case 22 /* SemicolonToken */: @@ -43880,25 +46461,25 @@ var ts; return spanInOpenParenToken(node); case 17 /* CloseParenToken */: return spanInCloseParenToken(node); - case 51 /* ColonToken */: + case 52 /* ColonToken */: return spanInColonToken(node); - case 25 /* GreaterThanToken */: + case 26 /* GreaterThanToken */: case 24 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 100 /* WhileKeyword */: + case 101 /* WhileKeyword */: return spanInWhileKeyword(node); - case 76 /* ElseKeyword */: - case 68 /* CatchKeyword */: - case 81 /* FinallyKeyword */: + case 77 /* ElseKeyword */: + case 69 /* CatchKeyword */: + case 82 /* FinallyKeyword */: return spanInNextNode(node); default: // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 227 /* PropertyAssignment */ && node.parent.name === node) { + if (node.parent.kind === 242 /* PropertyAssignment */ && node.parent.name === node) { return spanInNode(node.parent.initializer); } // Breakpoint in type assertion goes to its operand - if (node.parent.kind === 163 /* TypeAssertionExpression */ && node.parent.type === node) { + if (node.parent.kind === 168 /* TypeAssertionExpression */ && node.parent.type === node) { return spanInNode(node.parent.expression); } // return type of function go to previous token @@ -43911,12 +46492,12 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 190 /* ForInStatement */ || - variableDeclaration.parent.parent.kind === 191 /* ForOfStatement */) { + if (variableDeclaration.parent.parent.kind === 197 /* ForInStatement */ || + variableDeclaration.parent.parent.kind === 198 /* ForOfStatement */) { return spanInNode(variableDeclaration.parent.parent); } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 183 /* VariableStatement */; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 189 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); + var isParentVariableStatement = variableDeclaration.parent.parent.kind === 190 /* VariableStatement */; + var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 196 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); var declarations = isParentVariableStatement ? variableDeclaration.parent.parent.declarationList.declarations : isDeclarationOfForStatement @@ -43970,7 +46551,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return !!(functionDeclaration.flags & 1 /* Export */) || - (functionDeclaration.parent.kind === 204 /* ClassDeclaration */ && functionDeclaration.kind !== 137 /* Constructor */); + (functionDeclaration.parent.kind === 211 /* ClassDeclaration */ && functionDeclaration.kind !== 141 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -43993,18 +46574,18 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 188 /* WhileStatement */: - case 186 /* IfStatement */: - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: + case 195 /* WhileStatement */: + case 193 /* IfStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 189 /* ForStatement */: + case 196 /* ForStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement @@ -44012,7 +46593,7 @@ var ts; } function spanInForStatement(forStatement) { if (forStatement.initializer) { - if (forStatement.initializer.kind === 202 /* VariableDeclarationList */) { + if (forStatement.initializer.kind === 209 /* VariableDeclarationList */) { var variableDeclarationList = forStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -44032,13 +46613,13 @@ var ts; // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 207 /* EnumDeclaration */: + case 214 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 204 /* ClassDeclaration */: + case 211 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 210 /* CaseBlock */: + case 217 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -44046,25 +46627,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 209 /* ModuleBlock */: + case 216 /* ModuleBlock */: // If this is not instantiated module block no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 207 /* EnumDeclaration */: - case 204 /* ClassDeclaration */: + case 214 /* EnumDeclaration */: + case 211 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 182 /* Block */: + case 189 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // fall through. - case 226 /* CatchClause */: + case 241 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); ; - case 210 /* CaseBlock */: + case 217 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -44078,7 +46659,7 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 187 /* DoStatement */) { + if (node.parent.kind === 194 /* DoStatement */) { // Go to while keyword and do action instead return spanInPreviousNode(node); } @@ -44088,17 +46669,17 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 165 /* FunctionExpression */: - case 203 /* FunctionDeclaration */: - case 166 /* ArrowFunction */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 137 /* Constructor */: - case 188 /* WhileStatement */: - case 187 /* DoStatement */: - case 189 /* ForStatement */: + case 170 /* FunctionExpression */: + case 210 /* FunctionDeclaration */: + case 171 /* ArrowFunction */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 141 /* Constructor */: + case 195 /* WhileStatement */: + case 194 /* DoStatement */: + case 196 /* ForStatement */: return spanInPreviousNode(node); // Default to parent node default: @@ -44109,19 +46690,19 @@ var ts; } function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration - if (ts.isFunctionLike(node.parent) || node.parent.kind === 227 /* PropertyAssignment */) { + if (ts.isFunctionLike(node.parent) || node.parent.kind === 242 /* PropertyAssignment */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 163 /* TypeAssertionExpression */) { + if (node.parent.kind === 168 /* TypeAssertionExpression */) { return spanInNode(node.parent.expression); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 187 /* DoStatement */) { + if (node.parent.kind === 194 /* DoStatement */) { // Set span on while expression return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); } @@ -44249,7 +46830,8 @@ var ts; } }; LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { - return this.shimHost.getCancellationToken(); + var hostCancellationToken = this.shimHost.getCancellationToken(); + return new ThrottledCancellationToken(hostCancellationToken); }; LanguageServiceShimHostAdapter.prototype.getCurrentDirectory = function () { return this.shimHost.getCurrentDirectory(); @@ -44267,6 +46849,27 @@ var ts; return LanguageServiceShimHostAdapter; })(); ts.LanguageServiceShimHostAdapter = LanguageServiceShimHostAdapter; + /** A cancellation that throttles calls to the host */ + var ThrottledCancellationToken = (function () { + function ThrottledCancellationToken(hostCancellationToken) { + this.hostCancellationToken = hostCancellationToken; + // Store when we last tried to cancel. Checking cancellation can be expensive (as we have + // to marshall over to the host layer). So we only bother actually checking once enough + // time has passed. + this.lastCancellationCheckTime = 0; + } + ThrottledCancellationToken.prototype.isCancellationRequested = function () { + var time = Date.now(); + var duration = Math.abs(time - this.lastCancellationCheckTime); + if (duration > 10) { + // Check no more than once every 10 ms. + this.lastCancellationCheckTime = time; + return this.hostCancellationToken.isCancellationRequested(); + } + return false; + }; + return ThrottledCancellationToken; + })(); var CoreServicesShimHostAdapter = (function () { function CoreServicesShimHostAdapter(shimHost) { this.shimHost = shimHost; diff --git a/bin/typescriptServices.d.ts b/bin/typescriptServices.d.ts index 70e4f42e1ef..cea8225468b 100644 --- a/bin/typescriptServices.d.ts +++ b/bin/typescriptServices.d.ts @@ -54,250 +54,265 @@ declare namespace ts { SemicolonToken = 22, CommaToken = 23, LessThanToken = 24, - GreaterThanToken = 25, - LessThanEqualsToken = 26, - GreaterThanEqualsToken = 27, - EqualsEqualsToken = 28, - ExclamationEqualsToken = 29, - EqualsEqualsEqualsToken = 30, - ExclamationEqualsEqualsToken = 31, - EqualsGreaterThanToken = 32, - PlusToken = 33, - MinusToken = 34, - AsteriskToken = 35, - SlashToken = 36, - PercentToken = 37, - PlusPlusToken = 38, - MinusMinusToken = 39, - LessThanLessThanToken = 40, - GreaterThanGreaterThanToken = 41, - GreaterThanGreaterThanGreaterThanToken = 42, - AmpersandToken = 43, - BarToken = 44, - CaretToken = 45, - ExclamationToken = 46, - TildeToken = 47, - AmpersandAmpersandToken = 48, - BarBarToken = 49, - QuestionToken = 50, - ColonToken = 51, - AtToken = 52, - EqualsToken = 53, - PlusEqualsToken = 54, - MinusEqualsToken = 55, - AsteriskEqualsToken = 56, - SlashEqualsToken = 57, - PercentEqualsToken = 58, - LessThanLessThanEqualsToken = 59, - GreaterThanGreaterThanEqualsToken = 60, - GreaterThanGreaterThanGreaterThanEqualsToken = 61, - AmpersandEqualsToken = 62, - BarEqualsToken = 63, - CaretEqualsToken = 64, - Identifier = 65, - BreakKeyword = 66, - CaseKeyword = 67, - CatchKeyword = 68, - ClassKeyword = 69, - ConstKeyword = 70, - ContinueKeyword = 71, - DebuggerKeyword = 72, - DefaultKeyword = 73, - DeleteKeyword = 74, - DoKeyword = 75, - ElseKeyword = 76, - EnumKeyword = 77, - ExportKeyword = 78, - ExtendsKeyword = 79, - FalseKeyword = 80, - FinallyKeyword = 81, - ForKeyword = 82, - FunctionKeyword = 83, - IfKeyword = 84, - ImportKeyword = 85, - InKeyword = 86, - InstanceOfKeyword = 87, - NewKeyword = 88, - NullKeyword = 89, - ReturnKeyword = 90, - SuperKeyword = 91, - SwitchKeyword = 92, - ThisKeyword = 93, - ThrowKeyword = 94, - TrueKeyword = 95, - TryKeyword = 96, - TypeOfKeyword = 97, - VarKeyword = 98, - VoidKeyword = 99, - WhileKeyword = 100, - WithKeyword = 101, - ImplementsKeyword = 102, - InterfaceKeyword = 103, - LetKeyword = 104, - PackageKeyword = 105, - PrivateKeyword = 106, - ProtectedKeyword = 107, - PublicKeyword = 108, - StaticKeyword = 109, - YieldKeyword = 110, - AsKeyword = 111, - AnyKeyword = 112, - BooleanKeyword = 113, - ConstructorKeyword = 114, - DeclareKeyword = 115, - GetKeyword = 116, - IsKeyword = 117, - ModuleKeyword = 118, - NamespaceKeyword = 119, - RequireKeyword = 120, - NumberKeyword = 121, - SetKeyword = 122, - StringKeyword = 123, - SymbolKeyword = 124, - TypeKeyword = 125, - FromKeyword = 126, - OfKeyword = 127, - QualifiedName = 128, - ComputedPropertyName = 129, - TypeParameter = 130, - Parameter = 131, - Decorator = 132, - PropertySignature = 133, - PropertyDeclaration = 134, - MethodSignature = 135, - MethodDeclaration = 136, - Constructor = 137, - GetAccessor = 138, - SetAccessor = 139, - CallSignature = 140, - ConstructSignature = 141, - IndexSignature = 142, - TypePredicate = 143, - TypeReference = 144, - FunctionType = 145, - ConstructorType = 146, - TypeQuery = 147, - TypeLiteral = 148, - ArrayType = 149, - TupleType = 150, - UnionType = 151, - ParenthesizedType = 152, - ObjectBindingPattern = 153, - ArrayBindingPattern = 154, - BindingElement = 155, - ArrayLiteralExpression = 156, - ObjectLiteralExpression = 157, - PropertyAccessExpression = 158, - ElementAccessExpression = 159, - CallExpression = 160, - NewExpression = 161, - TaggedTemplateExpression = 162, - TypeAssertionExpression = 163, - ParenthesizedExpression = 164, - FunctionExpression = 165, - ArrowFunction = 166, - DeleteExpression = 167, - TypeOfExpression = 168, - VoidExpression = 169, - PrefixUnaryExpression = 170, - PostfixUnaryExpression = 171, - BinaryExpression = 172, - ConditionalExpression = 173, - TemplateExpression = 174, - YieldExpression = 175, - SpreadElementExpression = 176, - ClassExpression = 177, - OmittedExpression = 178, - ExpressionWithTypeArguments = 179, - TemplateSpan = 180, - SemicolonClassElement = 181, - Block = 182, - VariableStatement = 183, - EmptyStatement = 184, - ExpressionStatement = 185, - IfStatement = 186, - DoStatement = 187, - WhileStatement = 188, - ForStatement = 189, - ForInStatement = 190, - ForOfStatement = 191, - ContinueStatement = 192, - BreakStatement = 193, - ReturnStatement = 194, - WithStatement = 195, - SwitchStatement = 196, - LabeledStatement = 197, - ThrowStatement = 198, - TryStatement = 199, - DebuggerStatement = 200, - VariableDeclaration = 201, - VariableDeclarationList = 202, - FunctionDeclaration = 203, - ClassDeclaration = 204, - InterfaceDeclaration = 205, - TypeAliasDeclaration = 206, - EnumDeclaration = 207, - ModuleDeclaration = 208, - ModuleBlock = 209, - CaseBlock = 210, - ImportEqualsDeclaration = 211, - ImportDeclaration = 212, - ImportClause = 213, - NamespaceImport = 214, - NamedImports = 215, - ImportSpecifier = 216, - ExportAssignment = 217, - ExportDeclaration = 218, - NamedExports = 219, - ExportSpecifier = 220, - MissingDeclaration = 221, - ExternalModuleReference = 222, - CaseClause = 223, - DefaultClause = 224, - HeritageClause = 225, - CatchClause = 226, - PropertyAssignment = 227, - ShorthandPropertyAssignment = 228, - EnumMember = 229, - SourceFile = 230, - JSDocTypeExpression = 231, - JSDocAllType = 232, - JSDocUnknownType = 233, - JSDocArrayType = 234, - JSDocUnionType = 235, - JSDocTupleType = 236, - JSDocNullableType = 237, - JSDocNonNullableType = 238, - JSDocRecordType = 239, - JSDocRecordMember = 240, - JSDocTypeReference = 241, - JSDocOptionalType = 242, - JSDocFunctionType = 243, - JSDocVariadicType = 244, - JSDocConstructorType = 245, - JSDocThisType = 246, - JSDocComment = 247, - JSDocTag = 248, - JSDocParameterTag = 249, - JSDocReturnTag = 250, - JSDocTypeTag = 251, - JSDocTemplateTag = 252, - SyntaxList = 253, - Count = 254, - FirstAssignment = 53, - LastAssignment = 64, - FirstReservedWord = 66, - LastReservedWord = 101, - FirstKeyword = 66, - LastKeyword = 127, - FirstFutureReservedWord = 102, - LastFutureReservedWord = 110, - FirstTypeNode = 144, - LastTypeNode = 152, + LessThanSlashToken = 25, + GreaterThanToken = 26, + LessThanEqualsToken = 27, + GreaterThanEqualsToken = 28, + EqualsEqualsToken = 29, + ExclamationEqualsToken = 30, + EqualsEqualsEqualsToken = 31, + ExclamationEqualsEqualsToken = 32, + EqualsGreaterThanToken = 33, + PlusToken = 34, + MinusToken = 35, + AsteriskToken = 36, + SlashToken = 37, + PercentToken = 38, + PlusPlusToken = 39, + MinusMinusToken = 40, + LessThanLessThanToken = 41, + GreaterThanGreaterThanToken = 42, + GreaterThanGreaterThanGreaterThanToken = 43, + AmpersandToken = 44, + BarToken = 45, + CaretToken = 46, + ExclamationToken = 47, + TildeToken = 48, + AmpersandAmpersandToken = 49, + BarBarToken = 50, + QuestionToken = 51, + ColonToken = 52, + AtToken = 53, + EqualsToken = 54, + PlusEqualsToken = 55, + MinusEqualsToken = 56, + AsteriskEqualsToken = 57, + SlashEqualsToken = 58, + PercentEqualsToken = 59, + LessThanLessThanEqualsToken = 60, + GreaterThanGreaterThanEqualsToken = 61, + GreaterThanGreaterThanGreaterThanEqualsToken = 62, + AmpersandEqualsToken = 63, + BarEqualsToken = 64, + CaretEqualsToken = 65, + Identifier = 66, + BreakKeyword = 67, + CaseKeyword = 68, + CatchKeyword = 69, + ClassKeyword = 70, + ConstKeyword = 71, + ContinueKeyword = 72, + DebuggerKeyword = 73, + DefaultKeyword = 74, + DeleteKeyword = 75, + DoKeyword = 76, + ElseKeyword = 77, + EnumKeyword = 78, + ExportKeyword = 79, + ExtendsKeyword = 80, + FalseKeyword = 81, + FinallyKeyword = 82, + ForKeyword = 83, + FunctionKeyword = 84, + IfKeyword = 85, + ImportKeyword = 86, + InKeyword = 87, + InstanceOfKeyword = 88, + NewKeyword = 89, + NullKeyword = 90, + ReturnKeyword = 91, + SuperKeyword = 92, + SwitchKeyword = 93, + ThisKeyword = 94, + ThrowKeyword = 95, + TrueKeyword = 96, + TryKeyword = 97, + TypeOfKeyword = 98, + VarKeyword = 99, + VoidKeyword = 100, + WhileKeyword = 101, + WithKeyword = 102, + ImplementsKeyword = 103, + InterfaceKeyword = 104, + LetKeyword = 105, + PackageKeyword = 106, + PrivateKeyword = 107, + ProtectedKeyword = 108, + PublicKeyword = 109, + StaticKeyword = 110, + YieldKeyword = 111, + AbstractKeyword = 112, + AsKeyword = 113, + AnyKeyword = 114, + AsyncKeyword = 115, + AwaitKeyword = 116, + BooleanKeyword = 117, + ConstructorKeyword = 118, + DeclareKeyword = 119, + GetKeyword = 120, + IsKeyword = 121, + ModuleKeyword = 122, + NamespaceKeyword = 123, + RequireKeyword = 124, + NumberKeyword = 125, + SetKeyword = 126, + StringKeyword = 127, + SymbolKeyword = 128, + TypeKeyword = 129, + FromKeyword = 130, + OfKeyword = 131, + QualifiedName = 132, + ComputedPropertyName = 133, + TypeParameter = 134, + Parameter = 135, + Decorator = 136, + PropertySignature = 137, + PropertyDeclaration = 138, + MethodSignature = 139, + MethodDeclaration = 140, + Constructor = 141, + GetAccessor = 142, + SetAccessor = 143, + CallSignature = 144, + ConstructSignature = 145, + IndexSignature = 146, + TypePredicate = 147, + TypeReference = 148, + FunctionType = 149, + ConstructorType = 150, + TypeQuery = 151, + TypeLiteral = 152, + ArrayType = 153, + TupleType = 154, + UnionType = 155, + IntersectionType = 156, + ParenthesizedType = 157, + ObjectBindingPattern = 158, + ArrayBindingPattern = 159, + BindingElement = 160, + ArrayLiteralExpression = 161, + ObjectLiteralExpression = 162, + PropertyAccessExpression = 163, + ElementAccessExpression = 164, + CallExpression = 165, + NewExpression = 166, + TaggedTemplateExpression = 167, + TypeAssertionExpression = 168, + ParenthesizedExpression = 169, + FunctionExpression = 170, + ArrowFunction = 171, + DeleteExpression = 172, + TypeOfExpression = 173, + VoidExpression = 174, + AwaitExpression = 175, + PrefixUnaryExpression = 176, + PostfixUnaryExpression = 177, + BinaryExpression = 178, + ConditionalExpression = 179, + TemplateExpression = 180, + YieldExpression = 181, + SpreadElementExpression = 182, + ClassExpression = 183, + OmittedExpression = 184, + ExpressionWithTypeArguments = 185, + AsExpression = 186, + TemplateSpan = 187, + SemicolonClassElement = 188, + Block = 189, + VariableStatement = 190, + EmptyStatement = 191, + ExpressionStatement = 192, + IfStatement = 193, + DoStatement = 194, + WhileStatement = 195, + ForStatement = 196, + ForInStatement = 197, + ForOfStatement = 198, + ContinueStatement = 199, + BreakStatement = 200, + ReturnStatement = 201, + WithStatement = 202, + SwitchStatement = 203, + LabeledStatement = 204, + ThrowStatement = 205, + TryStatement = 206, + DebuggerStatement = 207, + VariableDeclaration = 208, + VariableDeclarationList = 209, + FunctionDeclaration = 210, + ClassDeclaration = 211, + InterfaceDeclaration = 212, + TypeAliasDeclaration = 213, + EnumDeclaration = 214, + ModuleDeclaration = 215, + ModuleBlock = 216, + CaseBlock = 217, + ImportEqualsDeclaration = 218, + ImportDeclaration = 219, + ImportClause = 220, + NamespaceImport = 221, + NamedImports = 222, + ImportSpecifier = 223, + ExportAssignment = 224, + ExportDeclaration = 225, + NamedExports = 226, + ExportSpecifier = 227, + MissingDeclaration = 228, + ExternalModuleReference = 229, + JsxElement = 230, + JsxSelfClosingElement = 231, + JsxOpeningElement = 232, + JsxText = 233, + JsxClosingElement = 234, + JsxAttribute = 235, + JsxSpreadAttribute = 236, + JsxExpression = 237, + CaseClause = 238, + DefaultClause = 239, + HeritageClause = 240, + CatchClause = 241, + PropertyAssignment = 242, + ShorthandPropertyAssignment = 243, + EnumMember = 244, + SourceFile = 245, + JSDocTypeExpression = 246, + JSDocAllType = 247, + JSDocUnknownType = 248, + JSDocArrayType = 249, + JSDocUnionType = 250, + JSDocTupleType = 251, + JSDocNullableType = 252, + JSDocNonNullableType = 253, + JSDocRecordType = 254, + JSDocRecordMember = 255, + JSDocTypeReference = 256, + JSDocOptionalType = 257, + JSDocFunctionType = 258, + JSDocVariadicType = 259, + JSDocConstructorType = 260, + JSDocThisType = 261, + JSDocComment = 262, + JSDocTag = 263, + JSDocParameterTag = 264, + JSDocReturnTag = 265, + JSDocTypeTag = 266, + JSDocTemplateTag = 267, + SyntaxList = 268, + Count = 269, + FirstAssignment = 54, + LastAssignment = 65, + FirstReservedWord = 67, + LastReservedWord = 102, + FirstKeyword = 67, + LastKeyword = 131, + FirstFutureReservedWord = 103, + LastFutureReservedWord = 111, + FirstTypeNode = 148, + LastTypeNode = 157, FirstPunctuation = 14, - LastPunctuation = 64, + LastPunctuation = 65, FirstToken = 0, - LastToken = 127, + LastToken = 131, FirstTriviaToken = 2, LastTriviaToken = 6, FirstLiteralToken = 7, @@ -305,8 +320,8 @@ declare namespace ts { FirstTemplateToken = 10, LastTemplateToken = 13, FirstBinaryOperator = 24, - LastBinaryOperator = 64, - FirstNode = 128, + LastBinaryOperator = 65, + FirstNode = 132, } const enum NodeFlags { Export = 1, @@ -315,18 +330,28 @@ declare namespace ts { Private = 32, Protected = 64, Static = 128, - Default = 256, - MultiLine = 512, - Synthetic = 1024, - DeclarationFile = 2048, - Let = 4096, - Const = 8192, - OctalLiteral = 16384, - Namespace = 32768, - ExportContext = 65536, - Modifier = 499, + Abstract = 256, + Async = 512, + Default = 1024, + MultiLine = 2048, + Synthetic = 4096, + DeclarationFile = 8192, + Let = 16384, + Const = 32768, + OctalLiteral = 65536, + Namespace = 131072, + ExportContext = 262144, + Modifier = 2035, AccessibilityModifier = 112, - BlockScoped = 12288, + BlockScoped = 49152, + } + const enum JsxFlags { + None = 0, + IntrinsicNamedElement = 1, + IntrinsicIndexedElement = 2, + ClassElement = 4, + UnknownElement = 8, + IntrinsicElement = 3, } interface Node extends TextRange { kind: SyntaxKind; @@ -483,9 +508,13 @@ declare namespace ts { interface TupleTypeNode extends TypeNode { elementTypes: NodeArray; } - interface UnionTypeNode extends TypeNode { + interface UnionOrIntersectionTypeNode extends TypeNode { types: NodeArray; } + interface UnionTypeNode extends UnionOrIntersectionTypeNode { + } + interface IntersectionTypeNode extends UnionOrIntersectionTypeNode { + } interface ParenthesizedTypeNode extends TypeNode { type: TypeNode; } @@ -528,6 +557,9 @@ declare namespace ts { interface VoidExpression extends UnaryExpression { expression: UnaryExpression; } + interface AwaitExpression extends UnaryExpression { + expression: UnaryExpression; + } interface YieldExpression extends Expression { asteriskToken?: Node; expression?: Expression; @@ -601,10 +633,46 @@ declare namespace ts { template: LiteralExpression | TemplateExpression; } type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression | Decorator; + interface AsExpression extends Expression { + expression: Expression; + type: TypeNode; + } interface TypeAssertion extends UnaryExpression { type: TypeNode; expression: UnaryExpression; } + type AssertionExpression = TypeAssertion | AsExpression; + interface JsxElement extends PrimaryExpression { + openingElement: JsxOpeningElement; + children: NodeArray; + closingElement: JsxClosingElement; + } + interface JsxOpeningElement extends Expression { + _openingElementBrand?: any; + tagName: EntityName; + attributes: NodeArray; + } + interface JsxSelfClosingElement extends PrimaryExpression, JsxOpeningElement { + _selfClosingElementBrand?: any; + } + type JsxOpeningLikeElement = JsxSelfClosingElement | JsxOpeningElement; + interface JsxAttribute extends Node { + name: Identifier; + initializer?: Expression; + } + interface JsxSpreadAttribute extends Node { + expression: Expression; + } + interface JsxClosingElement extends Node { + tagName: EntityName; + } + interface JsxExpression extends Expression { + expression?: Expression; + } + interface JsxText extends Node { + _jsxTextExpressionBrand: any; + } + type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement; interface Statement extends Node { _statementBrand: any; } @@ -859,6 +927,7 @@ declare namespace ts { }[]; moduleName: string; referencedFiles: FileReference[]; + languageVariant: LanguageVariant; /** * lib.d.ts should have a reference comment like * @@ -881,6 +950,13 @@ declare namespace ts { interface WriteFileCallback { (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void): void; } + class OperationCanceledException { + } + interface CancellationToken { + isCancellationRequested(): boolean; + /** @throws OperationCanceledException if isCancellationRequested is true */ + throwIfCancellationRequested(): void; + } interface Program extends ScriptReferenceHost { /** * Get a list of files in the program @@ -896,12 +972,12 @@ declare namespace ts { * used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter * will be invoked when writing the JavaScript and declaration files. */ - emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback): EmitResult; - getOptionsDiagnostics(): Diagnostic[]; - getGlobalDiagnostics(): Diagnostic[]; - getSyntacticDiagnostics(sourceFile?: SourceFile): Diagnostic[]; - getSemanticDiagnostics(sourceFile?: SourceFile): Diagnostic[]; - getDeclarationDiagnostics(sourceFile?: SourceFile): Diagnostic[]; + emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken): EmitResult; + getOptionsDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; + getGlobalDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; /** * Gets a type checker that can be used to semantically analyze source fils in the program. */ @@ -976,6 +1052,8 @@ declare namespace ts { isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean; getAliasedSymbol(symbol: Symbol): Symbol; getExportsOfModule(moduleSymbol: Symbol): Symbol[]; + getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type; + getJsxIntrinsicTagNames(): Symbol[]; } interface SymbolDisplayBuilder { buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; @@ -1053,7 +1131,7 @@ declare namespace ts { Merged = 33554432, Transient = 67108864, Prototype = 134217728, - UnionProperty = 268435456, + SyntheticProperty = 268435456, Optional = 536870912, ExportStar = 1073741824, Enum = 384, @@ -1069,8 +1147,8 @@ declare namespace ts { PropertyExcludes = 107455, EnumMemberExcludes = 107455, FunctionExcludes = 106927, - ClassExcludes = 899583, - InterfaceExcludes = 792992, + ClassExcludes = 899519, + InterfaceExcludes = 792960, RegularEnumExcludes = 899327, ConstEnumExcludes = 899967, ValueModuleExcludes = 106639, @@ -1116,13 +1194,16 @@ declare namespace ts { Reference = 4096, Tuple = 8192, Union = 16384, - Anonymous = 32768, - Instantiated = 65536, - ObjectLiteral = 262144, - ESSymbol = 2097152, + Intersection = 32768, + Anonymous = 65536, + Instantiated = 131072, + ObjectLiteral = 524288, + ESSymbol = 4194304, StringLike = 258, NumberLike = 132, - ObjectType = 48128, + ObjectType = 80896, + UnionOrIntersection = 49152, + StructuredType = 130048, } interface Type { flags: TypeFlags; @@ -1157,9 +1238,13 @@ declare namespace ts { elementTypes: Type[]; baseArrayType: TypeReference; } - interface UnionType extends Type { + interface UnionOrIntersectionType extends Type { types: Type[]; } + interface UnionType extends UnionOrIntersectionType { + } + interface IntersectionType extends UnionOrIntersectionType { + } interface TypeParameter extends Type { constraint: Type; } @@ -1216,6 +1301,7 @@ declare namespace ts { help?: boolean; inlineSourceMap?: boolean; inlineSources?: boolean; + jsx?: JsxEmit; listFiles?: boolean; locale?: string; mapRoot?: string; @@ -1242,6 +1328,7 @@ declare namespace ts { watch?: boolean; isolatedModules?: boolean; experimentalDecorators?: boolean; + experimentalAsyncFunctions?: boolean; emitDecoratorMetadata?: boolean; [option: string]: string | number | boolean; } @@ -1252,6 +1339,11 @@ declare namespace ts { UMD = 3, System = 4, } + const enum JsxEmit { + None = 0, + Preserve = 1, + React = 2, + } const enum NewLineKind { CarriageReturnLineFeed = 0, LineFeed = 1, @@ -1266,18 +1358,18 @@ declare namespace ts { ES6 = 2, Latest = 2, } + const enum LanguageVariant { + Standard = 0, + JSX = 1, + } interface ParsedCommandLine { options: CompilerOptions; fileNames: string[]; errors: Diagnostic[]; } - interface CancellationToken { - isCancellationRequested(): boolean; - } interface CompilerHost { getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; getDefaultLibFileName(options: CompilerOptions): string; - getCancellationToken?(): CancellationToken; writeFile: WriteFileCallback; getCurrentDirectory(): string; getCanonicalFileName(fileName: string): string; @@ -1336,10 +1428,14 @@ declare namespace ts { reScanGreaterToken(): SyntaxKind; reScanSlashToken(): SyntaxKind; reScanTemplateToken(): SyntaxKind; + scanJsxIdentifier(): SyntaxKind; + reScanJsxToken(): SyntaxKind; + scanJsxToken(): SyntaxKind; scan(): SyntaxKind; setText(text: string, start?: number, length?: number): void; setOnError(onError: ErrorCallback): void; setScriptTarget(scriptTarget: ScriptTarget): void; + setLanguageVariant(variant: LanguageVariant): void; setTextPos(textPos: number): void; lookAhead(callback: () => T): T; tryScan(callback: () => T): T; @@ -1397,7 +1493,7 @@ declare namespace ts { const version: string; function findConfigFile(searchPath: string): string; function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; - function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile): Diagnostic[]; + function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost): Program; } @@ -1504,6 +1600,9 @@ declare namespace ts { importedFiles: FileReference[]; isLibFile: boolean; } + interface HostCancellationToken { + isCancellationRequested(): boolean; + } interface LanguageServiceHost { getCompilationSettings(): CompilerOptions; getNewLine?(): string; @@ -1512,7 +1611,7 @@ declare namespace ts { getScriptVersion(fileName: string): string; getScriptSnapshot(fileName: string): IScriptSnapshot; getLocalizedDiagnosticMessages?(): any; - getCancellationToken?(): CancellationToken; + getCancellationToken?(): HostCancellationToken; getCurrentDirectory(): string; getDefaultLibFileName(options: CompilerOptions): string; log?(s: string): void; @@ -1892,6 +1991,7 @@ declare namespace ts { const scriptElement: string; const moduleElement: string; const classElement: string; + const localClassElement: string; const interfaceElement: string; const typeElement: string; const enumElement: string; @@ -1923,6 +2023,7 @@ declare namespace ts { const exportedModifier: string; const ambientModifier: string; const staticModifier: string; + const abstractModifier: string; } class ClassificationTypeNames { static comment: string; @@ -1968,15 +2069,6 @@ declare namespace ts { } function displayPartsToString(displayParts: SymbolDisplayPart[]): string; function getDefaultCompilerOptions(): CompilerOptions; - class OperationCanceledException { - } - class CancellationTokenObject { - private cancellationToken; - static None: CancellationTokenObject; - constructor(cancellationToken: CancellationToken); - isCancellationRequested(): boolean; - throwIfCancellationRequested(): void; - } function transpile(input: string, compilerOptions?: CompilerOptions, fileName?: string, diagnostics?: Diagnostic[], moduleName?: string): string; function createLanguageServiceSourceFile(fileName: string, scriptSnapshot: IScriptSnapshot, scriptTarget: ScriptTarget, version: string, setNodeParents: boolean): SourceFile; let disableIncrementalParsing: boolean; @@ -1986,7 +2078,7 @@ declare namespace ts { function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; function createClassifier(): Classifier; /** - * Get the path of the default library file (lib.d.ts) as distributed with the typescript + * Get the path of the default library files (lib.d.ts) as distributed with the typescript * node package. * The functionality is not supported if the ts module is consumed outside of a node module. */ diff --git a/bin/typescriptServices.js b/bin/typescriptServices.js index 6373e3f9c58..219a0b3924f 100644 --- a/bin/typescriptServices.js +++ b/bin/typescriptServices.js @@ -47,275 +47,291 @@ var ts; SyntaxKind[SyntaxKind["SemicolonToken"] = 22] = "SemicolonToken"; SyntaxKind[SyntaxKind["CommaToken"] = 23] = "CommaToken"; SyntaxKind[SyntaxKind["LessThanToken"] = 24] = "LessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 25] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 26] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 27] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 28] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 29] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 30] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 31] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 32] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 33] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 34] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 35] = "AsteriskToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 36] = "SlashToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 37] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 38] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 39] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 40] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 41] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 42] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 43] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 44] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 45] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 46] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 47] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 48] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 49] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 50] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 51] = "ColonToken"; - SyntaxKind[SyntaxKind["AtToken"] = 52] = "AtToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 25] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 26] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 27] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 28] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 29] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 30] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 31] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 32] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 33] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 34] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 35] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 36] = "AsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 37] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 38] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 39] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 40] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 41] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 42] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 43] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 44] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 45] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 46] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 47] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 48] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 49] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 50] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 51] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 52] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 53] = "AtToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 53] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 54] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 55] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 56] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 57] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 58] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 59] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 60] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 61] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 62] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 63] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 64] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 54] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 55] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 56] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 57] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 58] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 59] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 60] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 61] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 62] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 63] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 64] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 65] = "CaretEqualsToken"; // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 65] = "Identifier"; + SyntaxKind[SyntaxKind["Identifier"] = 66] = "Identifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 66] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 67] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 68] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 69] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 70] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 71] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 72] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 73] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 74] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 75] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 76] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 77] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 78] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 79] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 80] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 81] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 82] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 83] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 84] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 85] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 86] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 87] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 88] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 89] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 90] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 91] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 92] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 93] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 94] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 95] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 96] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 97] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 98] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 99] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 100] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 101] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 67] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 68] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 69] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 70] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 71] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 72] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 73] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 74] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 75] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 76] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 77] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 78] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 79] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 80] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 81] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 82] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 83] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 84] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 85] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 86] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 87] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 88] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 89] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 90] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 91] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 92] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 93] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 94] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 95] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 96] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 97] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 98] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 99] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 100] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 101] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 102] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 102] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 103] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 104] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 105] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 106] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 107] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 108] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 109] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 110] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 103] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 104] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 105] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 106] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 107] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 108] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 109] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 110] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 111] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AsKeyword"] = 111] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 112] = "AnyKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 113] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 114] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 115] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 116] = "GetKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 117] = "IsKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 118] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 119] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 120] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 121] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 122] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 123] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 124] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 125] = "TypeKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 126] = "FromKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 127] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 112] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 113] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 114] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 115] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 116] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 117] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 118] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 119] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 120] = "GetKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 121] = "IsKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 122] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 123] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 124] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 125] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 126] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 127] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 128] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 129] = "TypeKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 130] = "FromKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 131] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 128] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 129] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 132] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 133] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 130] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 131] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 132] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 134] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 135] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 136] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 133] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 134] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 135] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 136] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 137] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 138] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 139] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 140] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 141] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 142] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 137] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 138] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 139] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 140] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 141] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 142] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 143] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 144] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 145] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 146] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 143] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 144] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 145] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 146] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 147] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 148] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 149] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 150] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 151] = "UnionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 152] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 147] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 148] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 149] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 150] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 151] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 152] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 153] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 154] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 155] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 156] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 157] = "ParenthesizedType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 153] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 154] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 155] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 158] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 159] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 160] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 156] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 157] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 158] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 159] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 160] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 161] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 162] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 163] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 164] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 165] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 166] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 167] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 168] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 169] = "VoidExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 170] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 171] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 172] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 173] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 174] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 175] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElementExpression"] = 176] = "SpreadElementExpression"; - SyntaxKind[SyntaxKind["ClassExpression"] = 177] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 178] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 179] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 161] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 162] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 163] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 164] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 165] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 166] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 167] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 168] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 169] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 170] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 171] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 172] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 173] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 174] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 175] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 176] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 177] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 178] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 179] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 180] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 181] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElementExpression"] = 182] = "SpreadElementExpression"; + SyntaxKind[SyntaxKind["ClassExpression"] = 183] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 184] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 185] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 186] = "AsExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 180] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 181] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 187] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 188] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 182] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 183] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 184] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 185] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 186] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 187] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 188] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 189] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 190] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 191] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 192] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 193] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 194] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 195] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 196] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 197] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 198] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 199] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 200] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 201] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 202] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 203] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 204] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 205] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 206] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 207] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 208] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 209] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 210] = "CaseBlock"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 211] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 212] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 213] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 214] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 215] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 216] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 217] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 218] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 219] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 220] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 221] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 189] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 190] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 191] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 192] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 193] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 194] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 195] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 196] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 197] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 198] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 199] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 200] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 201] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 202] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 203] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 204] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 205] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 206] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 207] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 208] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 209] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 210] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 211] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 212] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 213] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 214] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 215] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 216] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 217] = "CaseBlock"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 218] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 219] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 220] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 221] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 222] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 223] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 224] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 225] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 226] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 227] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 228] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 222] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 229] = "ExternalModuleReference"; + // JSX + SyntaxKind[SyntaxKind["JsxElement"] = 230] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 231] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 232] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxText"] = 233] = "JsxText"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 234] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 235] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 236] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 237] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 223] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 224] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 225] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 226] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 238] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 239] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 240] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 241] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 227] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 228] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 242] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 243] = "ShorthandPropertyAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 229] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 244] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 230] = "SourceFile"; + SyntaxKind[SyntaxKind["SourceFile"] = 245] = "SourceFile"; // JSDoc nodes. - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 231] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 246] = "JSDocTypeExpression"; // The * type. - SyntaxKind[SyntaxKind["JSDocAllType"] = 232] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 247] = "JSDocAllType"; // The ? type. - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 233] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 234] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 235] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 236] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 237] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 238] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 239] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 240] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 241] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 242] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 243] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 244] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 245] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 246] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 247] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 248] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 249] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 250] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 251] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 252] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 248] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 249] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 250] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 251] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 252] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 253] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 254] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 255] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 256] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 257] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 258] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 259] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 260] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 261] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 262] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 263] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 264] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 265] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 266] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 267] = "JSDocTemplateTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 253] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 268] = "SyntaxList"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 254] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 269] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 53] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 64] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 66] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 101] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 66] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 127] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 102] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 110] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 144] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 152] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 54] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 65] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 67] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 102] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 67] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 131] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 103] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 111] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 148] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 157] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 14] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 64] = "LastPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 65] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 127] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 131] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 6] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 7] = "FirstLiteralToken"; @@ -323,8 +339,8 @@ var ts; SyntaxKind[SyntaxKind["FirstTemplateToken"] = 10] = "FirstTemplateToken"; SyntaxKind[SyntaxKind["LastTemplateToken"] = 13] = "LastTemplateToken"; SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 24] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 64] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 128] = "FirstNode"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 65] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 132] = "FirstNode"; })(ts.SyntaxKind || (ts.SyntaxKind = {})); var SyntaxKind = ts.SyntaxKind; (function (NodeFlags) { @@ -334,48 +350,61 @@ var ts; NodeFlags[NodeFlags["Private"] = 32] = "Private"; NodeFlags[NodeFlags["Protected"] = 64] = "Protected"; NodeFlags[NodeFlags["Static"] = 128] = "Static"; - NodeFlags[NodeFlags["Default"] = 256] = "Default"; - NodeFlags[NodeFlags["MultiLine"] = 512] = "MultiLine"; - NodeFlags[NodeFlags["Synthetic"] = 1024] = "Synthetic"; - NodeFlags[NodeFlags["DeclarationFile"] = 2048] = "DeclarationFile"; - NodeFlags[NodeFlags["Let"] = 4096] = "Let"; - NodeFlags[NodeFlags["Const"] = 8192] = "Const"; - NodeFlags[NodeFlags["OctalLiteral"] = 16384] = "OctalLiteral"; - NodeFlags[NodeFlags["Namespace"] = 32768] = "Namespace"; - NodeFlags[NodeFlags["ExportContext"] = 65536] = "ExportContext"; - NodeFlags[NodeFlags["Modifier"] = 499] = "Modifier"; + NodeFlags[NodeFlags["Abstract"] = 256] = "Abstract"; + NodeFlags[NodeFlags["Async"] = 512] = "Async"; + NodeFlags[NodeFlags["Default"] = 1024] = "Default"; + NodeFlags[NodeFlags["MultiLine"] = 2048] = "MultiLine"; + NodeFlags[NodeFlags["Synthetic"] = 4096] = "Synthetic"; + NodeFlags[NodeFlags["DeclarationFile"] = 8192] = "DeclarationFile"; + NodeFlags[NodeFlags["Let"] = 16384] = "Let"; + NodeFlags[NodeFlags["Const"] = 32768] = "Const"; + NodeFlags[NodeFlags["OctalLiteral"] = 65536] = "OctalLiteral"; + NodeFlags[NodeFlags["Namespace"] = 131072] = "Namespace"; + NodeFlags[NodeFlags["ExportContext"] = 262144] = "ExportContext"; + NodeFlags[NodeFlags["Modifier"] = 2035] = "Modifier"; NodeFlags[NodeFlags["AccessibilityModifier"] = 112] = "AccessibilityModifier"; - NodeFlags[NodeFlags["BlockScoped"] = 12288] = "BlockScoped"; + NodeFlags[NodeFlags["BlockScoped"] = 49152] = "BlockScoped"; })(ts.NodeFlags || (ts.NodeFlags = {})); var NodeFlags = ts.NodeFlags; /* @internal */ (function (ParserContextFlags) { ParserContextFlags[ParserContextFlags["None"] = 0] = "None"; // If this node was parsed in a context where 'in-expressions' are not allowed. - ParserContextFlags[ParserContextFlags["DisallowIn"] = 2] = "DisallowIn"; + ParserContextFlags[ParserContextFlags["DisallowIn"] = 1] = "DisallowIn"; // If this node was parsed in the 'yield' context created when parsing a generator. - ParserContextFlags[ParserContextFlags["Yield"] = 4] = "Yield"; - // If this node was parsed in the parameters of a generator. - ParserContextFlags[ParserContextFlags["GeneratorParameter"] = 8] = "GeneratorParameter"; + ParserContextFlags[ParserContextFlags["Yield"] = 2] = "Yield"; // If this node was parsed as part of a decorator - ParserContextFlags[ParserContextFlags["Decorator"] = 16] = "Decorator"; + ParserContextFlags[ParserContextFlags["Decorator"] = 4] = "Decorator"; + // If this node was parsed in the 'await' context created when parsing an async function. + ParserContextFlags[ParserContextFlags["Await"] = 8] = "Await"; // If the parser encountered an error when parsing the code that created this node. Note // the parser only sets this directly on the node it creates right after encountering the // error. - ParserContextFlags[ParserContextFlags["ThisNodeHasError"] = 32] = "ThisNodeHasError"; + ParserContextFlags[ParserContextFlags["ThisNodeHasError"] = 16] = "ThisNodeHasError"; // This node was parsed in a JavaScript file and can be processed differently. For example // its type can be specified usign a JSDoc comment. - ParserContextFlags[ParserContextFlags["JavaScriptFile"] = 64] = "JavaScriptFile"; + ParserContextFlags[ParserContextFlags["JavaScriptFile"] = 32] = "JavaScriptFile"; // Context flags set directly by the parser. - ParserContextFlags[ParserContextFlags["ParserGeneratedFlags"] = 62] = "ParserGeneratedFlags"; + ParserContextFlags[ParserContextFlags["ParserGeneratedFlags"] = 31] = "ParserGeneratedFlags"; + // Exclude these flags when parsing a Type + ParserContextFlags[ParserContextFlags["TypeExcludesFlags"] = 10] = "TypeExcludesFlags"; // Context flags computed by aggregating child flags upwards. // Used during incremental parsing to determine if this node or any of its children had an // error. Computed only once and then cached. - ParserContextFlags[ParserContextFlags["ThisNodeOrAnySubNodesHasError"] = 128] = "ThisNodeOrAnySubNodesHasError"; + ParserContextFlags[ParserContextFlags["ThisNodeOrAnySubNodesHasError"] = 64] = "ThisNodeOrAnySubNodesHasError"; // Used to know if we've computed data from children and cached it in this node. - ParserContextFlags[ParserContextFlags["HasAggregatedChildData"] = 256] = "HasAggregatedChildData"; + ParserContextFlags[ParserContextFlags["HasAggregatedChildData"] = 128] = "HasAggregatedChildData"; })(ts.ParserContextFlags || (ts.ParserContextFlags = {})); var ParserContextFlags = ts.ParserContextFlags; + (function (JsxFlags) { + JsxFlags[JsxFlags["None"] = 0] = "None"; + JsxFlags[JsxFlags["IntrinsicNamedElement"] = 1] = "IntrinsicNamedElement"; + JsxFlags[JsxFlags["IntrinsicIndexedElement"] = 2] = "IntrinsicIndexedElement"; + JsxFlags[JsxFlags["ClassElement"] = 4] = "ClassElement"; + JsxFlags[JsxFlags["UnknownElement"] = 8] = "UnknownElement"; + JsxFlags[JsxFlags["IntrinsicElement"] = 3] = "IntrinsicElement"; + })(ts.JsxFlags || (ts.JsxFlags = {})); + var JsxFlags = ts.JsxFlags; /* @internal */ (function (RelationComparisonResult) { RelationComparisonResult[RelationComparisonResult["Succeeded"] = 1] = "Succeeded"; @@ -383,6 +412,12 @@ var ts; RelationComparisonResult[RelationComparisonResult["FailedAndReported"] = 3] = "FailedAndReported"; })(ts.RelationComparisonResult || (ts.RelationComparisonResult = {})); var RelationComparisonResult = ts.RelationComparisonResult; + var OperationCanceledException = (function () { + function OperationCanceledException() { + } + return OperationCanceledException; + })(); + ts.OperationCanceledException = OperationCanceledException; /** Return code used by getEmitOutput function to indicate status of the function */ (function (ExitStatus) { // Compiler ran successfully. Either this was a simple do-nothing compilation (for example, @@ -427,6 +462,27 @@ var ts; SymbolAccessibility[SymbolAccessibility["CannotBeNamed"] = 2] = "CannotBeNamed"; })(ts.SymbolAccessibility || (ts.SymbolAccessibility = {})); var SymbolAccessibility = ts.SymbolAccessibility; + /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator + * metadata */ + /* @internal */ + (function (TypeReferenceSerializationKind) { + TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; + // should be emitted using a safe fallback. + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + // function that can be reached at runtime (e.g. a `class` + // declaration or a `var` declaration for the static side + // of a type, such as the global `Promise` type in lib.d.ts). + TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidType"] = 2] = "VoidType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 4] = "StringLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 5] = "BooleanType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 6] = "ArrayLikeType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 7] = "ESSymbolType"; + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 8] = "TypeWithCallSignature"; + // with call signatures. + TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 9] = "ObjectType"; + })(ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); + var TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind; (function (SymbolFlags) { SymbolFlags[SymbolFlags["None"] = 0] = "None"; SymbolFlags[SymbolFlags["FunctionScopedVariable"] = 1] = "FunctionScopedVariable"; @@ -457,7 +513,7 @@ var ts; SymbolFlags[SymbolFlags["Merged"] = 33554432] = "Merged"; SymbolFlags[SymbolFlags["Transient"] = 67108864] = "Transient"; SymbolFlags[SymbolFlags["Prototype"] = 134217728] = "Prototype"; - SymbolFlags[SymbolFlags["UnionProperty"] = 268435456] = "UnionProperty"; + SymbolFlags[SymbolFlags["SyntheticProperty"] = 268435456] = "SyntheticProperty"; SymbolFlags[SymbolFlags["Optional"] = 536870912] = "Optional"; SymbolFlags[SymbolFlags["ExportStar"] = 1073741824] = "ExportStar"; SymbolFlags[SymbolFlags["Enum"] = 384] = "Enum"; @@ -477,8 +533,8 @@ var ts; SymbolFlags[SymbolFlags["PropertyExcludes"] = 107455] = "PropertyExcludes"; SymbolFlags[SymbolFlags["EnumMemberExcludes"] = 107455] = "EnumMemberExcludes"; SymbolFlags[SymbolFlags["FunctionExcludes"] = 106927] = "FunctionExcludes"; - SymbolFlags[SymbolFlags["ClassExcludes"] = 899583] = "ClassExcludes"; - SymbolFlags[SymbolFlags["InterfaceExcludes"] = 792992] = "InterfaceExcludes"; + SymbolFlags[SymbolFlags["ClassExcludes"] = 899519] = "ClassExcludes"; + SymbolFlags[SymbolFlags["InterfaceExcludes"] = 792960] = "InterfaceExcludes"; SymbolFlags[SymbolFlags["RegularEnumExcludes"] = 899327] = "RegularEnumExcludes"; SymbolFlags[SymbolFlags["ConstEnumExcludes"] = 899967] = "ConstEnumExcludes"; SymbolFlags[SymbolFlags["ValueModuleExcludes"] = 106639] = "ValueModuleExcludes"; @@ -497,7 +553,7 @@ var ts; SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; SymbolFlags[SymbolFlags["Export"] = 7340032] = "Export"; /* @internal */ - // The set of things we consider semantically classifiable. Used to speed up the LS during + // The set of things we consider semantically classifiable. Used to speed up the LS during // classification. SymbolFlags[SymbolFlags["Classifiable"] = 788448] = "Classifiable"; })(ts.SymbolFlags || (ts.SymbolFlags = {})); @@ -508,15 +564,19 @@ var ts; NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 2] = "LexicalThis"; NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 4] = "CaptureThis"; NodeCheckFlags[NodeCheckFlags["EmitExtends"] = 8] = "EmitExtends"; - NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 16] = "SuperInstance"; - NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 32] = "SuperStatic"; - NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 64] = "ContextChecked"; + NodeCheckFlags[NodeCheckFlags["EmitDecorate"] = 16] = "EmitDecorate"; + NodeCheckFlags[NodeCheckFlags["EmitParam"] = 32] = "EmitParam"; + NodeCheckFlags[NodeCheckFlags["EmitAwaiter"] = 64] = "EmitAwaiter"; + NodeCheckFlags[NodeCheckFlags["EmitGenerator"] = 128] = "EmitGenerator"; + NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance"; + NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic"; + NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked"; + NodeCheckFlags[NodeCheckFlags["LexicalArguments"] = 2048] = "LexicalArguments"; + NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 4096] = "CaptureArguments"; // Values for enum members have been computed, and any errors have been reported for them. - NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 128] = "EnumValuesComputed"; - NodeCheckFlags[NodeCheckFlags["BlockScopedBindingInLoop"] = 256] = "BlockScopedBindingInLoop"; - NodeCheckFlags[NodeCheckFlags["EmitDecorate"] = 512] = "EmitDecorate"; - NodeCheckFlags[NodeCheckFlags["EmitParam"] = 1024] = "EmitParam"; - NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 2048] = "LexicalModuleMergesWithClass"; + NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 8192] = "EnumValuesComputed"; + NodeCheckFlags[NodeCheckFlags["BlockScopedBindingInLoop"] = 16384] = "BlockScopedBindingInLoop"; + NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass"; })(ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); var NodeCheckFlags = ts.NodeCheckFlags; (function (TypeFlags) { @@ -535,25 +595,28 @@ var ts; TypeFlags[TypeFlags["Reference"] = 4096] = "Reference"; TypeFlags[TypeFlags["Tuple"] = 8192] = "Tuple"; TypeFlags[TypeFlags["Union"] = 16384] = "Union"; - TypeFlags[TypeFlags["Anonymous"] = 32768] = "Anonymous"; - TypeFlags[TypeFlags["Instantiated"] = 65536] = "Instantiated"; + TypeFlags[TypeFlags["Intersection"] = 32768] = "Intersection"; + TypeFlags[TypeFlags["Anonymous"] = 65536] = "Anonymous"; + TypeFlags[TypeFlags["Instantiated"] = 131072] = "Instantiated"; /* @internal */ - TypeFlags[TypeFlags["FromSignature"] = 131072] = "FromSignature"; - TypeFlags[TypeFlags["ObjectLiteral"] = 262144] = "ObjectLiteral"; + TypeFlags[TypeFlags["FromSignature"] = 262144] = "FromSignature"; + TypeFlags[TypeFlags["ObjectLiteral"] = 524288] = "ObjectLiteral"; /* @internal */ - TypeFlags[TypeFlags["ContainsUndefinedOrNull"] = 524288] = "ContainsUndefinedOrNull"; + TypeFlags[TypeFlags["ContainsUndefinedOrNull"] = 1048576] = "ContainsUndefinedOrNull"; /* @internal */ - TypeFlags[TypeFlags["ContainsObjectLiteral"] = 1048576] = "ContainsObjectLiteral"; - TypeFlags[TypeFlags["ESSymbol"] = 2097152] = "ESSymbol"; + TypeFlags[TypeFlags["ContainsObjectLiteral"] = 2097152] = "ContainsObjectLiteral"; + TypeFlags[TypeFlags["ESSymbol"] = 4194304] = "ESSymbol"; /* @internal */ - TypeFlags[TypeFlags["Intrinsic"] = 2097279] = "Intrinsic"; + TypeFlags[TypeFlags["Intrinsic"] = 4194431] = "Intrinsic"; /* @internal */ - TypeFlags[TypeFlags["Primitive"] = 2097662] = "Primitive"; + TypeFlags[TypeFlags["Primitive"] = 4194814] = "Primitive"; TypeFlags[TypeFlags["StringLike"] = 258] = "StringLike"; TypeFlags[TypeFlags["NumberLike"] = 132] = "NumberLike"; - TypeFlags[TypeFlags["ObjectType"] = 48128] = "ObjectType"; + TypeFlags[TypeFlags["ObjectType"] = 80896] = "ObjectType"; + TypeFlags[TypeFlags["UnionOrIntersection"] = 49152] = "UnionOrIntersection"; + TypeFlags[TypeFlags["StructuredType"] = 130048] = "StructuredType"; /* @internal */ - TypeFlags[TypeFlags["RequiresWidening"] = 1572864] = "RequiresWidening"; + TypeFlags[TypeFlags["RequiresWidening"] = 3145728] = "RequiresWidening"; })(ts.TypeFlags || (ts.TypeFlags = {})); var TypeFlags = ts.TypeFlags; (function (SignatureKind) { @@ -580,6 +643,12 @@ var ts; ModuleKind[ModuleKind["System"] = 4] = "System"; })(ts.ModuleKind || (ts.ModuleKind = {})); var ModuleKind = ts.ModuleKind; + (function (JsxEmit) { + JsxEmit[JsxEmit["None"] = 0] = "None"; + JsxEmit[JsxEmit["Preserve"] = 1] = "Preserve"; + JsxEmit[JsxEmit["React"] = 2] = "React"; + })(ts.JsxEmit || (ts.JsxEmit = {})); + var JsxEmit = ts.JsxEmit; (function (NewLineKind) { NewLineKind[NewLineKind["CarriageReturnLineFeed"] = 0] = "CarriageReturnLineFeed"; NewLineKind[NewLineKind["LineFeed"] = 1] = "LineFeed"; @@ -592,6 +661,11 @@ var ts; ScriptTarget[ScriptTarget["Latest"] = 2] = "Latest"; })(ts.ScriptTarget || (ts.ScriptTarget = {})); var ScriptTarget = ts.ScriptTarget; + (function (LanguageVariant) { + LanguageVariant[LanguageVariant["Standard"] = 0] = "Standard"; + LanguageVariant[LanguageVariant["JSX"] = 1] = "JSX"; + })(ts.LanguageVariant || (ts.LanguageVariant = {})); + var LanguageVariant = ts.LanguageVariant; /* @internal */ (function (CharacterCodes) { CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; @@ -726,13 +800,15 @@ var ts; /* @internal */ var ts; (function (ts) { - // Ternary values are defined such that - // x & y is False if either x or y is False. - // x & y is Maybe if either x or y is Maybe, but neither x or y is False. - // x & y is True if both x and y are True. - // x | y is False if both x and y are False. - // x | y is Maybe if either x or y is Maybe, but neither x or y is True. - // x | y is True if either x or y is True. + /** + * Ternary values are defined such that + * x & y is False if either x or y is False. + * x & y is Maybe if either x or y is Maybe, but neither x or y is False. + * x & y is True if both x and y are True. + * x | y is False if both x and y are False. + * x | y is Maybe if either x or y is Maybe, but neither x or y is True. + * x | y is True if either x or y is True. + */ (function (Ternary) { Ternary[Ternary["False"] = 0] = "False"; Ternary[Ternary["Maybe"] = 1] = "Maybe"; @@ -775,6 +851,11 @@ var ts; Comparison[Comparison["GreaterThan"] = 1] = "GreaterThan"; })(ts.Comparison || (ts.Comparison = {})); var Comparison = ts.Comparison; + /** + * Iterates through 'array' by index and performs the callback on each element of array until the callback + * returns a truthy value, then returns that value. + * If no such value is found, the callback is applied to each element of array and undefined is returned. + */ function forEach(array, callback) { if (array) { for (var i = 0, len = array.length; i < len; i++) { @@ -1286,19 +1367,19 @@ 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/ + // 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; // Initial root length is http:// part var rootLength = url.indexOf("://") + "://".length; while (rootLength < urlLength) { - // Consume all immediate slashes in the protocol + // Consume all immediate slashes in the protocol // eg.initial rootlength is just file:// but it needs to consume another "/" in file:/// if (url.charCodeAt(rootLength) === 47 /* slash */) { rootLength++; } else { - // non slash character means we continue proceeding to next component of root search + // non slash character means we continue proceeding to next component of root search break; } } @@ -1309,15 +1390,15 @@ var ts; // Find the index of "/" after website.com so the root can be http://www.website.com/ (from existing http://) var indexOfNextSlash = url.indexOf(ts.directorySeparator, rootLength); if (indexOfNextSlash !== -1) { - // Found the "/" after the website.com so the root is length of http://www.website.com/ + // Found the "/" after the website.com so the root is length of http://www.website.com/ // and get components afetr the root normally like any other folder components rootLength = indexOfNextSlash + 1; return normalizedPathComponents(url, rootLength); } else { - // Can't find the host assume the rest of the string as component + // Can't find the host assume the rest of the string as component // but make sure we append "/" to it as root is not joined using "/" - // eg. if url passed in was http://website.com we want to use root as [http://website.com/] + // eg. if url passed in was http://website.com we want to use root as [http://website.com/] // so that other path manipulations will be correct and it can be merged with relative paths correctly return [url + ts.directorySeparator]; } @@ -1389,8 +1470,8 @@ var ts; /** * List of supported extensions in order of file resolution precedence. */ - ts.supportedExtensions = [".ts", ".d.ts"]; - var extensionsToRemove = [".d.ts", ".ts", ".js"]; + ts.supportedExtensions = [".tsx", ".ts", ".d.ts"]; + var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { for (var _i = 0; _i < extensionsToRemove.length; _i++) { var ext = extensionsToRemove[_i]; @@ -1433,8 +1514,8 @@ var ts; } Node.prototype = { kind: kind, - pos: 0, - end: 0, + pos: -1, + end: -1, flags: 0, parent: undefined }; @@ -1670,16 +1751,16 @@ var ts; var directories = []; for (var _i = 0; _i < files.length; _i++) { var current = files[_i]; - var name = ts.combinePaths(path, current); - if (!ts.contains(exclude, getCanonicalPath(name))) { - var stat = _fs.statSync(name); + var name_3 = ts.combinePaths(path, current); + if (!ts.contains(exclude, getCanonicalPath(name_3))) { + var stat = _fs.statSync(name_3); if (stat.isFile()) { - if (!extension || ts.fileExtensionIs(name, extension)) { - result.push(name); + if (!extension || ts.fileExtensionIs(name_3, extension)) { + result.push(name_3); } } else if (stat.isDirectory()) { - directories.push(name); + directories.push(name_3); } } } @@ -1779,22 +1860,21 @@ var ts; An_index_signature_must_have_a_type_annotation: { code: 1021, category: ts.DiagnosticCategory.Error, key: "An index signature must have a type annotation." }, An_index_signature_parameter_must_have_a_type_annotation: { code: 1022, category: ts.DiagnosticCategory.Error, key: "An index signature parameter must have a type annotation." }, An_index_signature_parameter_type_must_be_string_or_number: { code: 1023, category: ts.DiagnosticCategory.Error, key: "An index signature parameter type must be 'string' or 'number'." }, - A_class_or_interface_declaration_can_only_have_one_extends_clause: { code: 1024, category: ts.DiagnosticCategory.Error, key: "A class or interface declaration can only have one 'extends' clause." }, - An_extends_clause_must_precede_an_implements_clause: { code: 1025, category: ts.DiagnosticCategory.Error, key: "An 'extends' clause must precede an 'implements' clause." }, - A_class_can_only_extend_a_single_class: { code: 1026, category: ts.DiagnosticCategory.Error, key: "A class can only extend a single class." }, - A_class_declaration_can_only_have_one_implements_clause: { code: 1027, category: ts.DiagnosticCategory.Error, key: "A class declaration can only have one 'implements' clause." }, Accessibility_modifier_already_seen: { code: 1028, category: ts.DiagnosticCategory.Error, key: "Accessibility modifier already seen." }, _0_modifier_must_precede_1_modifier: { code: 1029, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier must precede '{1}' modifier." }, _0_modifier_already_seen: { code: 1030, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier already seen." }, _0_modifier_cannot_appear_on_a_class_element: { code: 1031, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a class element." }, - An_interface_declaration_cannot_have_an_implements_clause: { code: 1032, category: ts.DiagnosticCategory.Error, key: "An interface declaration cannot have an 'implements' clause." }, super_must_be_followed_by_an_argument_list_or_member_access: { code: 1034, category: ts.DiagnosticCategory.Error, key: "'super' must be followed by an argument list or member access." }, Only_ambient_modules_can_use_quoted_names: { code: 1035, category: ts.DiagnosticCategory.Error, key: "Only ambient modules can use quoted names." }, Statements_are_not_allowed_in_ambient_contexts: { code: 1036, category: ts.DiagnosticCategory.Error, key: "Statements are not allowed in ambient contexts." }, A_declare_modifier_cannot_be_used_in_an_already_ambient_context: { code: 1038, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used in an already ambient context." }, Initializers_are_not_allowed_in_ambient_contexts: { code: 1039, category: ts.DiagnosticCategory.Error, key: "Initializers are not allowed in ambient contexts." }, + _0_modifier_cannot_be_used_in_an_ambient_context: { code: 1040, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used in an ambient context." }, + _0_modifier_cannot_be_used_with_a_class_declaration: { code: 1041, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with a class declaration." }, + _0_modifier_cannot_be_used_here: { code: 1042, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot be used here." }, + _0_modifier_cannot_appear_on_a_data_property: { code: 1043, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a data property." }, _0_modifier_cannot_appear_on_a_module_element: { code: 1044, category: ts.DiagnosticCategory.Error, key: "'{0}' modifier cannot appear on a module element." }, - A_declare_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an interface declaration." }, + A_0_modifier_cannot_be_used_with_an_interface_declaration: { code: 1045, category: ts.DiagnosticCategory.Error, key: "A '{0}' modifier cannot be used with an interface declaration." }, A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file: { code: 1046, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier is required for a top level declaration in a .d.ts file." }, A_rest_parameter_cannot_be_optional: { code: 1047, category: ts.DiagnosticCategory.Error, key: "A rest parameter cannot be optional." }, A_rest_parameter_cannot_have_an_initializer: { code: 1048, category: ts.DiagnosticCategory.Error, key: "A rest parameter cannot have an initializer." }, @@ -1803,12 +1883,18 @@ var ts; A_set_accessor_parameter_cannot_have_an_initializer: { code: 1052, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor parameter cannot have an initializer." }, A_set_accessor_cannot_have_rest_parameter: { code: 1053, category: ts.DiagnosticCategory.Error, key: "A 'set' accessor cannot have rest parameter." }, A_get_accessor_cannot_have_parameters: { code: 1054, category: ts.DiagnosticCategory.Error, key: "A 'get' accessor cannot have parameters." }, + Type_0_is_not_a_valid_async_function_return_type: { code: 1055, category: ts.DiagnosticCategory.Error, key: "Type '{0}' is not a valid async function return type." }, Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: ts.DiagnosticCategory.Error, key: "Accessors are only available when targeting ECMAScript 5 and higher." }, + An_async_function_or_method_must_have_a_valid_awaitable_return_type: { code: 1057, category: ts.DiagnosticCategory.Error, key: "An async function or method must have a valid awaitable return type." }, + Operand_for_await_does_not_have_a_valid_callable_then_member: { code: 1058, category: ts.DiagnosticCategory.Error, key: "Operand for 'await' does not have a valid callable 'then' member." }, + Return_expression_in_async_function_does_not_have_a_valid_callable_then_member: { code: 1059, category: ts.DiagnosticCategory.Error, key: "Return expression in async function does not have a valid callable 'then' member." }, + Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member: { code: 1060, category: ts.DiagnosticCategory.Error, key: "Expression body for async arrow function does not have a valid callable 'then' member." }, 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." }, 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_declare_modifier_cannot_be_used_with_an_import_declaration: { code: 1079, category: ts.DiagnosticCategory.Error, key: "A 'declare' modifier cannot be used with an import declaration." }, + 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." }, Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher: { code: 1085, category: ts.DiagnosticCategory.Error, key: "Octal literals are not available when targeting ECMAScript 5 and higher." }, An_accessor_cannot_be_declared_in_an_ambient_context: { code: 1086, category: ts.DiagnosticCategory.Error, key: "An accessor cannot be declared in an ambient context." }, @@ -1853,7 +1939,6 @@ var ts; case_or_default_expected: { code: 1130, category: ts.DiagnosticCategory.Error, key: "'case' or 'default' expected." }, Property_or_signature_expected: { code: 1131, category: ts.DiagnosticCategory.Error, key: "Property or signature expected." }, Enum_member_expected: { code: 1132, category: ts.DiagnosticCategory.Error, key: "Enum member expected." }, - Type_reference_expected: { code: 1133, category: ts.DiagnosticCategory.Error, key: "Type reference expected." }, Variable_declaration_expected: { code: 1134, category: ts.DiagnosticCategory.Error, key: "Variable declaration expected." }, Argument_expression_expected: { code: 1135, category: ts.DiagnosticCategory.Error, key: "Argument expression expected." }, Property_assignment_expected: { code: 1136, category: ts.DiagnosticCategory.Error, key: "Property assignment expected." }, @@ -1870,9 +1955,6 @@ var ts; Cannot_compile_modules_unless_the_module_flag_is_provided: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot compile modules unless the '--module' flag is provided." }, File_name_0_differs_from_already_included_file_name_1_only_in_casing: { code: 1149, category: ts.DiagnosticCategory.Error, key: "File name '{0}' differs from already included file name '{1}' only in casing" }, new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: ts.DiagnosticCategory.Error, key: "'new T[]' cannot be used to create an array. Use 'new Array()' instead." }, - var_let_or_const_expected: { code: 1152, category: ts.DiagnosticCategory.Error, key: "'var', 'let' or 'const' expected." }, - let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1153, category: ts.DiagnosticCategory.Error, key: "'let' declarations are only available when targeting ECMAScript 6 and higher." }, - const_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1154, category: ts.DiagnosticCategory.Error, key: "'const' declarations are only available when targeting ECMAScript 6 and higher." }, const_declarations_must_be_initialized: { code: 1155, category: ts.DiagnosticCategory.Error, key: "'const' declarations must be initialized" }, const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: ts.DiagnosticCategory.Error, key: "'const' declarations can only be declared inside a block." }, let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: ts.DiagnosticCategory.Error, key: "'let' declarations can only be declared inside a block." }, @@ -1883,7 +1965,6 @@ var ts; Computed_property_names_are_not_allowed_in_enums: { code: 1164, category: ts.DiagnosticCategory.Error, key: "Computed property names are not allowed in enums." }, A_computed_property_name_in_an_ambient_context_must_directly_refer_to_a_built_in_symbol: { code: 1165, category: ts.DiagnosticCategory.Error, key: "A computed property name in an ambient context must directly refer to a built-in symbol." }, A_computed_property_name_in_a_class_property_declaration_must_directly_refer_to_a_built_in_symbol: { code: 1166, category: ts.DiagnosticCategory.Error, key: "A computed property name in a class property declaration must directly refer to a built-in symbol." }, - Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1167, category: ts.DiagnosticCategory.Error, key: "Computed property names are only available when targeting ECMAScript 6 and higher." }, A_computed_property_name_in_a_method_overload_must_directly_refer_to_a_built_in_symbol: { code: 1168, category: ts.DiagnosticCategory.Error, key: "A computed property name in a method overload must directly refer to a built-in symbol." }, A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol: { code: 1169, category: ts.DiagnosticCategory.Error, key: "A computed property name in an interface must directly refer to a built-in symbol." }, A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol: { code: 1170, category: ts.DiagnosticCategory.Error, key: "A computed property name in a type literal must directly refer to a built-in symbol." }, @@ -1899,7 +1980,6 @@ 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." }, - Destructuring_declarations_are_not_allowed_in_ambient_contexts: { code: 1183, category: ts.DiagnosticCategory.Error, key: "Destructuring declarations are not allowed in ambient contexts." }, An_implementation_cannot_be_declared_in_ambient_contexts: { code: 1184, 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." }, @@ -1950,12 +2030,20 @@ 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." }, Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { code: 1239, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of parameter decorator when called as an expression." }, Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { code: 1240, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of property decorator when called as an expression." }, Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { code: 1241, category: ts.DiagnosticCategory.Error, key: "Unable to resolve signature of method decorator when called as an expression." }, + abstract_modifier_can_only_appear_on_a_class_or_method_declaration: { code: 1242, category: ts.DiagnosticCategory.Error, key: "'abstract' modifier can only appear on a class or method declaration." }, + _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." }, 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." }, @@ -1964,7 +2052,6 @@ var ts; Module_0_has_no_exported_member_1: { code: 2305, category: ts.DiagnosticCategory.Error, key: "Module '{0}' has no exported member '{1}'." }, File_0_is_not_a_module: { code: 2306, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not a module." }, Cannot_find_module_0: { code: 2307, category: ts.DiagnosticCategory.Error, key: "Cannot find module '{0}'." }, - A_module_cannot_have_more_than_one_export_assignment: { code: 2308, category: ts.DiagnosticCategory.Error, key: "A module cannot have more than one export assignment." }, An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: { code: 2309, category: ts.DiagnosticCategory.Error, key: "An export assignment cannot be used in a module with other exported elements." }, Type_0_recursively_references_itself_as_a_base_type: { code: 2310, category: ts.DiagnosticCategory.Error, key: "Type '{0}' recursively references itself as a base type." }, A_class_may_only_extend_another_class: { code: 2311, category: ts.DiagnosticCategory.Error, key: "A class may only extend another class." }, @@ -1992,10 +2079,10 @@ var ts; this_cannot_be_referenced_in_a_static_property_initializer: { code: 2334, category: ts.DiagnosticCategory.Error, key: "'this' cannot be referenced in a static property initializer." }, super_can_only_be_referenced_in_a_derived_class: { code: 2335, category: ts.DiagnosticCategory.Error, key: "'super' can only be referenced in a derived class." }, super_cannot_be_referenced_in_constructor_arguments: { code: 2336, category: ts.DiagnosticCategory.Error, key: "'super' cannot be referenced in constructor arguments." }, - Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: ts.DiagnosticCategory.Error, key: "Super calls are not permitted outside constructors or in nested functions inside constructors" }, - super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: ts.DiagnosticCategory.Error, key: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class" }, + Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: ts.DiagnosticCategory.Error, key: "Super calls are not permitted outside constructors or in nested functions inside constructors." }, + super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: ts.DiagnosticCategory.Error, key: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class." }, 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" }, + 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'." }, Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: ts.DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." }, @@ -2154,6 +2241,29 @@ var ts; No_base_constructor_has_the_specified_number_of_type_arguments: { code: 2508, category: ts.DiagnosticCategory.Error, key: "No base constructor has the specified number of type arguments." }, Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: ts.DiagnosticCategory.Error, key: "Base constructor return type '{0}' is not a class or interface type." }, Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: ts.DiagnosticCategory.Error, key: "Base constructors must all have the same return type." }, + Cannot_create_an_instance_of_the_abstract_class_0: { code: 2511, category: ts.DiagnosticCategory.Error, key: "Cannot create an instance of the abstract class '{0}'." }, + Overload_signatures_must_all_be_abstract_or_not_abstract: { code: 2512, category: ts.DiagnosticCategory.Error, key: "Overload signatures must all be abstract or not abstract." }, + Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: { code: 2513, category: ts.DiagnosticCategory.Error, key: "Abstract method '{0}' in class '{1}' cannot be accessed via super expression." }, + Classes_containing_abstract_methods_must_be_marked_abstract: { code: 2514, category: ts.DiagnosticCategory.Error, key: "Classes containing abstract methods must be marked abstract." }, + 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." }, + Constructor_objects_of_abstract_type_cannot_be_assigned_to_constructor_objects_of_non_abstract_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Constructor objects of abstract type cannot be assigned to constructor objects of non-abstract 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." }, + 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." }, + Property_0_in_type_1_is_not_assignable_to_type_2: { code: 2603, category: ts.DiagnosticCategory.Error, key: "Property '{0}' in type '{1}' is not assignable to type '{2}'" }, + JSX_element_type_0_does_not_have_any_construct_or_call_signatures: { code: 2604, category: ts.DiagnosticCategory.Error, key: "JSX element type '{0}' does not have any construct or call signatures." }, + JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements: { code: 2605, category: ts.DiagnosticCategory.Error, key: "JSX element type '{0}' is not a constructor function for JSX elements." }, + Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: ts.DiagnosticCategory.Error, key: "Property '{0}' of JSX spread attribute is not assignable to target property." }, + JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" }, + The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" }, + Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" }, 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}'." }, @@ -2290,15 +2400,18 @@ var ts; File_0_has_unsupported_extension_The_only_supported_extensions_are_1: { code: 6054, category: ts.DiagnosticCategory.Error, key: "File '{0}' has unsupported extension. The only supported extensions are {1}." }, Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: ts.DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." }, Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: ts.DiagnosticCategory.Message, key: "Do not emit declarations for code that has an '@internal' annotation." }, - Preserve_new_lines_when_emitting_code: { code: 6057, category: ts.DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." }, Specifies_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir: { code: 6058, category: ts.DiagnosticCategory.Message, key: "Specifies the root directory of input files. Use to control the output directory structure with --outDir." }, File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files: { code: 6059, category: ts.DiagnosticCategory.Error, key: "File '{0}' is not under 'rootDir' '{1}'. 'rootDir' is expected to contain all source files." }, Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: ts.DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, NEWLINE: { code: 6061, category: ts.DiagnosticCategory.Message, key: "NEWLINE" }, Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: ts.DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, + Specify_JSX_code_generation_Colon_preserve_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify JSX code generation: 'preserve' or 'react'" }, + Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: ts.DiagnosticCategory.Message, key: "Argument for '--jsx' must be 'preserve' or 'react'." }, Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: ts.DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." }, 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." }, Variable_0_implicitly_has_an_1_type: { code: 7005, category: ts.DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." }, Parameter_0_implicitly_has_an_1_type: { code: 7006, category: ts.DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." }, Member_0_implicitly_has_an_1_type: { code: 7008, category: ts.DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." }, @@ -2315,6 +2428,7 @@ var ts; _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: { code: 7023, category: ts.DiagnosticCategory.Error, key: "'{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." }, Function_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: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function 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." }, Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: ts.DiagnosticCategory.Error, key: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." }, + JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: ts.DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists" }, You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: ts.DiagnosticCategory.Error, key: "'import ... =' can only be used in a .ts file." }, @@ -2331,7 +2445,14 @@ var ts; property_declarations_can_only_be_used_in_a_ts_file: { code: 8014, category: ts.DiagnosticCategory.Error, key: "'property declarations' can only be used in a .ts file." }, enum_declarations_can_only_be_used_in_a_ts_file: { code: 8015, category: ts.DiagnosticCategory.Error, key: "'enum declarations' can only be used in a .ts file." }, type_assertion_expressions_can_only_be_used_in_a_ts_file: { code: 8016, category: ts.DiagnosticCategory.Error, key: "'type assertion expressions' can only be used in a .ts file." }, - decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: ts.DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." } + decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: ts.DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." }, + Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: ts.DiagnosticCategory.Error, key: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." }, + class_expressions_are_not_currently_supported: { code: 9003, category: ts.DiagnosticCategory.Error, key: "'class' expressions are not currently supported." }, + JSX_attributes_must_only_be_assigned_a_non_empty_expression: { code: 17000, category: ts.DiagnosticCategory.Error, key: "JSX attributes must only be assigned a non-empty 'expression'." }, + JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { code: 17001, category: ts.DiagnosticCategory.Error, key: "JSX elements cannot have multiple attributes with the same name." }, + 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." } }; })(ts || (ts = {})); /// @@ -2339,68 +2460,71 @@ var ts; var ts; (function (ts) { var textToToken = { - "any": 112 /* AnyKeyword */, - "as": 111 /* AsKeyword */, - "boolean": 113 /* BooleanKeyword */, - "break": 66 /* BreakKeyword */, - "case": 67 /* CaseKeyword */, - "catch": 68 /* CatchKeyword */, - "class": 69 /* ClassKeyword */, - "continue": 71 /* ContinueKeyword */, - "const": 70 /* ConstKeyword */, - "constructor": 114 /* ConstructorKeyword */, - "debugger": 72 /* DebuggerKeyword */, - "declare": 115 /* DeclareKeyword */, - "default": 73 /* DefaultKeyword */, - "delete": 74 /* DeleteKeyword */, - "do": 75 /* DoKeyword */, - "else": 76 /* ElseKeyword */, - "enum": 77 /* EnumKeyword */, - "export": 78 /* ExportKeyword */, - "extends": 79 /* ExtendsKeyword */, - "false": 80 /* FalseKeyword */, - "finally": 81 /* FinallyKeyword */, - "for": 82 /* ForKeyword */, - "from": 126 /* FromKeyword */, - "function": 83 /* FunctionKeyword */, - "get": 116 /* GetKeyword */, - "if": 84 /* IfKeyword */, - "implements": 102 /* ImplementsKeyword */, - "import": 85 /* ImportKeyword */, - "in": 86 /* InKeyword */, - "instanceof": 87 /* InstanceOfKeyword */, - "interface": 103 /* InterfaceKeyword */, - "is": 117 /* IsKeyword */, - "let": 104 /* LetKeyword */, - "module": 118 /* ModuleKeyword */, - "namespace": 119 /* NamespaceKeyword */, - "new": 88 /* NewKeyword */, - "null": 89 /* NullKeyword */, - "number": 121 /* NumberKeyword */, - "package": 105 /* PackageKeyword */, - "private": 106 /* PrivateKeyword */, - "protected": 107 /* ProtectedKeyword */, - "public": 108 /* PublicKeyword */, - "require": 120 /* RequireKeyword */, - "return": 90 /* ReturnKeyword */, - "set": 122 /* SetKeyword */, - "static": 109 /* StaticKeyword */, - "string": 123 /* StringKeyword */, - "super": 91 /* SuperKeyword */, - "switch": 92 /* SwitchKeyword */, - "symbol": 124 /* SymbolKeyword */, - "this": 93 /* ThisKeyword */, - "throw": 94 /* ThrowKeyword */, - "true": 95 /* TrueKeyword */, - "try": 96 /* TryKeyword */, - "type": 125 /* TypeKeyword */, - "typeof": 97 /* TypeOfKeyword */, - "var": 98 /* VarKeyword */, - "void": 99 /* VoidKeyword */, - "while": 100 /* WhileKeyword */, - "with": 101 /* WithKeyword */, - "yield": 110 /* YieldKeyword */, - "of": 127 /* OfKeyword */, + "abstract": 112 /* AbstractKeyword */, + "any": 114 /* AnyKeyword */, + "as": 113 /* AsKeyword */, + "boolean": 117 /* BooleanKeyword */, + "break": 67 /* BreakKeyword */, + "case": 68 /* CaseKeyword */, + "catch": 69 /* CatchKeyword */, + "class": 70 /* ClassKeyword */, + "continue": 72 /* ContinueKeyword */, + "const": 71 /* ConstKeyword */, + "constructor": 118 /* ConstructorKeyword */, + "debugger": 73 /* DebuggerKeyword */, + "declare": 119 /* DeclareKeyword */, + "default": 74 /* DefaultKeyword */, + "delete": 75 /* DeleteKeyword */, + "do": 76 /* DoKeyword */, + "else": 77 /* ElseKeyword */, + "enum": 78 /* EnumKeyword */, + "export": 79 /* ExportKeyword */, + "extends": 80 /* ExtendsKeyword */, + "false": 81 /* FalseKeyword */, + "finally": 82 /* FinallyKeyword */, + "for": 83 /* ForKeyword */, + "from": 130 /* FromKeyword */, + "function": 84 /* FunctionKeyword */, + "get": 120 /* GetKeyword */, + "if": 85 /* IfKeyword */, + "implements": 103 /* ImplementsKeyword */, + "import": 86 /* ImportKeyword */, + "in": 87 /* InKeyword */, + "instanceof": 88 /* InstanceOfKeyword */, + "interface": 104 /* InterfaceKeyword */, + "is": 121 /* IsKeyword */, + "let": 105 /* LetKeyword */, + "module": 122 /* ModuleKeyword */, + "namespace": 123 /* NamespaceKeyword */, + "new": 89 /* NewKeyword */, + "null": 90 /* NullKeyword */, + "number": 125 /* NumberKeyword */, + "package": 106 /* PackageKeyword */, + "private": 107 /* PrivateKeyword */, + "protected": 108 /* ProtectedKeyword */, + "public": 109 /* PublicKeyword */, + "require": 124 /* RequireKeyword */, + "return": 91 /* ReturnKeyword */, + "set": 126 /* SetKeyword */, + "static": 110 /* StaticKeyword */, + "string": 127 /* StringKeyword */, + "super": 92 /* SuperKeyword */, + "switch": 93 /* SwitchKeyword */, + "symbol": 128 /* SymbolKeyword */, + "this": 94 /* ThisKeyword */, + "throw": 95 /* ThrowKeyword */, + "true": 96 /* TrueKeyword */, + "try": 97 /* TryKeyword */, + "type": 129 /* TypeKeyword */, + "typeof": 98 /* TypeOfKeyword */, + "var": 99 /* VarKeyword */, + "void": 100 /* VoidKeyword */, + "while": 101 /* WhileKeyword */, + "with": 102 /* WithKeyword */, + "yield": 111 /* YieldKeyword */, + "async": 115 /* AsyncKeyword */, + "await": 116 /* AwaitKeyword */, + "of": 131 /* OfKeyword */, "{": 14 /* OpenBraceToken */, "}": 15 /* CloseBraceToken */, "(": 16 /* OpenParenToken */, @@ -2412,46 +2536,47 @@ var ts; ";": 22 /* SemicolonToken */, ",": 23 /* CommaToken */, "<": 24 /* LessThanToken */, - ">": 25 /* GreaterThanToken */, - "<=": 26 /* LessThanEqualsToken */, - ">=": 27 /* GreaterThanEqualsToken */, - "==": 28 /* EqualsEqualsToken */, - "!=": 29 /* ExclamationEqualsToken */, - "===": 30 /* EqualsEqualsEqualsToken */, - "!==": 31 /* ExclamationEqualsEqualsToken */, - "=>": 32 /* EqualsGreaterThanToken */, - "+": 33 /* PlusToken */, - "-": 34 /* MinusToken */, - "*": 35 /* AsteriskToken */, - "/": 36 /* SlashToken */, - "%": 37 /* PercentToken */, - "++": 38 /* PlusPlusToken */, - "--": 39 /* MinusMinusToken */, - "<<": 40 /* LessThanLessThanToken */, - ">>": 41 /* GreaterThanGreaterThanToken */, - ">>>": 42 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 43 /* AmpersandToken */, - "|": 44 /* BarToken */, - "^": 45 /* CaretToken */, - "!": 46 /* ExclamationToken */, - "~": 47 /* TildeToken */, - "&&": 48 /* AmpersandAmpersandToken */, - "||": 49 /* BarBarToken */, - "?": 50 /* QuestionToken */, - ":": 51 /* ColonToken */, - "=": 53 /* EqualsToken */, - "+=": 54 /* PlusEqualsToken */, - "-=": 55 /* MinusEqualsToken */, - "*=": 56 /* AsteriskEqualsToken */, - "/=": 57 /* SlashEqualsToken */, - "%=": 58 /* PercentEqualsToken */, - "<<=": 59 /* LessThanLessThanEqualsToken */, - ">>=": 60 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 61 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 62 /* AmpersandEqualsToken */, - "|=": 63 /* BarEqualsToken */, - "^=": 64 /* CaretEqualsToken */, - "@": 52 /* AtToken */ + ">": 26 /* GreaterThanToken */, + "<=": 27 /* LessThanEqualsToken */, + ">=": 28 /* GreaterThanEqualsToken */, + "==": 29 /* EqualsEqualsToken */, + "!=": 30 /* ExclamationEqualsToken */, + "===": 31 /* EqualsEqualsEqualsToken */, + "!==": 32 /* ExclamationEqualsEqualsToken */, + "=>": 33 /* EqualsGreaterThanToken */, + "+": 34 /* PlusToken */, + "-": 35 /* MinusToken */, + "*": 36 /* AsteriskToken */, + "/": 37 /* SlashToken */, + "%": 38 /* PercentToken */, + "++": 39 /* PlusPlusToken */, + "--": 40 /* MinusMinusToken */, + "<<": 41 /* LessThanLessThanToken */, + ">": 42 /* GreaterThanGreaterThanToken */, + ">>>": 43 /* GreaterThanGreaterThanGreaterThanToken */, + "&": 44 /* AmpersandToken */, + "|": 45 /* BarToken */, + "^": 46 /* CaretToken */, + "!": 47 /* ExclamationToken */, + "~": 48 /* TildeToken */, + "&&": 49 /* AmpersandAmpersandToken */, + "||": 50 /* BarBarToken */, + "?": 51 /* QuestionToken */, + ":": 52 /* ColonToken */, + "=": 54 /* EqualsToken */, + "+=": 55 /* PlusEqualsToken */, + "-=": 56 /* MinusEqualsToken */, + "*=": 57 /* AsteriskEqualsToken */, + "/=": 58 /* SlashEqualsToken */, + "%=": 59 /* PercentEqualsToken */, + "<<=": 60 /* LessThanLessThanEqualsToken */, + ">>=": 61 /* GreaterThanGreaterThanEqualsToken */, + ">>>=": 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */, + "&=": 63 /* AmpersandEqualsToken */, + "|=": 64 /* BarEqualsToken */, + "^=": 65 /* CaretEqualsToken */, + "@": 53 /* AtToken */ }; /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers @@ -2537,9 +2662,9 @@ var ts; } function makeReverseMap(source) { var result = []; - for (var name_3 in source) { - if (source.hasOwnProperty(name_3)) { - result[source[name_3]] = name_3; + for (var name_4 in source) { + if (source.hasOwnProperty(name_4)) { + result[source[name_4]] = name_4; } } return result; @@ -2601,7 +2726,7 @@ var ts; function computeLineAndCharacterOfPosition(lineStarts, position) { var lineNumber = ts.binarySearch(lineStarts, position); if (lineNumber < 0) { - // If the actual position was not found, + // If the actual position was not found, // the binary search returns the negative value of the next line start // e.g. if the line starts at [5, 10, 23, 80] and the position requested was 20 // then the search will return -2 @@ -2644,8 +2769,8 @@ var ts; // \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. + // 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 /* lineFeed */ || ch === 13 /* carriageReturn */ || ch === 8232 /* lineSeparator */ || @@ -2746,7 +2871,7 @@ var ts; } } ts.skipTrivia = skipTrivia; - // All conflict markers consist of the same character repeated seven times. If it is + // All conflict markers consist of the same character repeated seven times. If it is // a <<<<<<< or >>>>>>> marker then it is also followd by a space. var mergeConflictMarkerLength = "<<<<<<<".length; function isConflictMarkerTrivia(text, pos) { @@ -2791,12 +2916,12 @@ var ts; } return pos; } - // Extract comments from the given source text starting at the given position. If trailing is - // false, whitespace is skipped until the first line break and comments between that location - // and the next token are returned.If trailing is true, comments occurring between the given - // position and the next line break are returned.The return value is an array containing a - // TextRange for each comment. Single-line comment ranges include the beginning '//' characters - // but not the ending line break. Multi - line comment ranges include the beginning '/* and + // Extract comments from the given source text starting at the given position. If trailing is + // false, whitespace is skipped until the first line break and comments between that location + // and the next token are returned.If trailing is true, comments occurring between the given + // position and the next line break are returned.The return value is an array containing a + // TextRange for each comment. Single-line comment ranges include the beginning '//' characters + // but not the ending line break. Multi - line comment ranges include the beginning '/* and // ending '*/' characters.The return value is undefined if no comments were found. function getCommentRanges(text, pos, trailing) { var result; @@ -2893,7 +3018,8 @@ var ts; ts.isIdentifierPart = isIdentifierPart; /* @internal */ // Creates a scanner over a (possibly unspecified) range of a piece of text. - function createScanner(languageVersion, skipTrivia, text, onError, start, length) { + function createScanner(languageVersion, skipTrivia, languageVariant, text, onError, start, length) { + if (languageVariant === void 0) { languageVariant = 0 /* Standard */; } // Current position (end position of text of current token) var pos; // end of text @@ -2917,15 +3043,19 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 65 /* Identifier */ || token > 101 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 66 /* FirstReservedWord */ && token <= 101 /* LastReservedWord */; }, + isIdentifier: function () { return token === 66 /* Identifier */ || token > 102 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 67 /* FirstReservedWord */ && token <= 102 /* LastReservedWord */; }, isUnterminated: function () { return tokenIsUnterminated; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, reScanTemplateToken: reScanTemplateToken, + scanJsxIdentifier: scanJsxIdentifier, + reScanJsxToken: reScanJsxToken, + scanJsxToken: scanJsxToken, scan: scan, setText: setText, setScriptTarget: setScriptTarget, + setLanguageVariant: setLanguageVariant, setOnError: setOnError, setTextPos: setTextPos, tryScan: tryScan, @@ -3258,7 +3388,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 65 /* Identifier */; + return token = 66 /* Identifier */; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base !== 2 || base !== 8, "Expected either base 2 or base 8"); @@ -3328,11 +3458,11 @@ var ts; case 33 /* exclamation */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 31 /* ExclamationEqualsEqualsToken */; + return pos += 3, token = 32 /* ExclamationEqualsEqualsToken */; } - return pos += 2, token = 29 /* ExclamationEqualsToken */; + return pos += 2, token = 30 /* ExclamationEqualsToken */; } - return pos++, token = 46 /* ExclamationToken */; + return pos++, token = 47 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); @@ -3341,44 +3471,44 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 58 /* PercentEqualsToken */; + return pos += 2, token = 59 /* PercentEqualsToken */; } - return pos++, token = 37 /* PercentToken */; + return pos++, token = 38 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 48 /* AmpersandAmpersandToken */; + return pos += 2, token = 49 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 62 /* AmpersandEqualsToken */; + return pos += 2, token = 63 /* AmpersandEqualsToken */; } - return pos++, token = 43 /* AmpersandToken */; + return pos++, token = 44 /* AmpersandToken */; case 40 /* openParen */: return pos++, token = 16 /* OpenParenToken */; case 41 /* closeParen */: return pos++, token = 17 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 56 /* AsteriskEqualsToken */; + return pos += 2, token = 57 /* AsteriskEqualsToken */; } - return pos++, token = 35 /* AsteriskToken */; + return pos++, token = 36 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 38 /* PlusPlusToken */; + return pos += 2, token = 39 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 54 /* PlusEqualsToken */; + return pos += 2, token = 55 /* PlusEqualsToken */; } - return pos++, token = 33 /* PlusToken */; + return pos++, token = 34 /* PlusToken */; case 44 /* comma */: return pos++, token = 23 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 39 /* MinusMinusToken */; + return pos += 2, token = 40 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 55 /* MinusEqualsToken */; + return pos += 2, token = 56 /* MinusEqualsToken */; } - return pos++, token = 34 /* MinusToken */; + return pos++, token = 35 /* MinusToken */; case 46 /* dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanNumber(); @@ -3433,9 +3563,9 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 57 /* SlashEqualsToken */; + return pos += 2, token = 58 /* SlashEqualsToken */; } - return pos++, token = 36 /* SlashToken */; + return pos++, token = 37 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; @@ -3487,7 +3617,7 @@ var ts; tokenValue = "" + scanNumber(); return token = 7 /* NumericLiteral */; case 58 /* colon */: - return pos++, token = 51 /* ColonToken */; + return pos++, token = 52 /* ColonToken */; case 59 /* semicolon */: return pos++, token = 22 /* SemicolonToken */; case 60 /* lessThan */: @@ -3502,12 +3632,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 59 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 60 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 40 /* LessThanLessThanToken */; + return pos += 2, token = 41 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 26 /* LessThanEqualsToken */; + return pos += 2, token = 27 /* LessThanEqualsToken */; + } + if (text.charCodeAt(pos + 1) === 47 /* slash */ && languageVariant === 1 /* JSX */) { + return pos += 2, token = 25 /* LessThanSlashToken */; } return pos++, token = 24 /* LessThanToken */; case 61 /* equals */: @@ -3522,14 +3655,14 @@ var ts; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 30 /* EqualsEqualsEqualsToken */; + return pos += 3, token = 31 /* EqualsEqualsEqualsToken */; } - return pos += 2, token = 28 /* EqualsEqualsToken */; + return pos += 2, token = 29 /* EqualsEqualsToken */; } if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 32 /* EqualsGreaterThanToken */; + return pos += 2, token = 33 /* EqualsGreaterThanToken */; } - return pos++, token = 53 /* EqualsToken */; + return pos++, token = 54 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -3540,34 +3673,34 @@ var ts; return token = 6 /* ConflictMarkerTrivia */; } } - return pos++, token = 25 /* GreaterThanToken */; + return pos++, token = 26 /* GreaterThanToken */; case 63 /* question */: - return pos++, token = 50 /* QuestionToken */; + return pos++, token = 51 /* QuestionToken */; case 91 /* openBracket */: return pos++, token = 18 /* OpenBracketToken */; case 93 /* closeBracket */: return pos++, token = 19 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 64 /* CaretEqualsToken */; + return pos += 2, token = 65 /* CaretEqualsToken */; } - return pos++, token = 45 /* CaretToken */; + return pos++, token = 46 /* CaretToken */; case 123 /* openBrace */: return pos++, token = 14 /* OpenBraceToken */; case 124 /* bar */: if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 49 /* BarBarToken */; + return pos += 2, token = 50 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 63 /* BarEqualsToken */; + return pos += 2, token = 64 /* BarEqualsToken */; } - return pos++, token = 44 /* BarToken */; + return pos++, token = 45 /* BarToken */; case 125 /* closeBrace */: return pos++, token = 15 /* CloseBraceToken */; case 126 /* tilde */: - return pos++, token = 47 /* TildeToken */; + return pos++, token = 48 /* TildeToken */; case 64 /* at */: - return pos++, token = 52 /* AtToken */; + return pos++, token = 53 /* AtToken */; case 92 /* backslash */: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar)) { @@ -3603,27 +3736,27 @@ var ts; } } function reScanGreaterToken() { - if (token === 25 /* GreaterThanToken */) { + if (token === 26 /* GreaterThanToken */) { if (text.charCodeAt(pos) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 61 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 42 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 43 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 60 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 61 /* GreaterThanGreaterThanEqualsToken */; } - return pos++, token = 41 /* GreaterThanGreaterThanToken */; + return pos++, token = 42 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { - return pos++, token = 27 /* GreaterThanEqualsToken */; + return pos++, token = 28 /* GreaterThanEqualsToken */; } } return token; } function reScanSlashToken() { - if (token === 36 /* SlashToken */ || token === 57 /* SlashEqualsToken */) { + if (token === 37 /* SlashToken */ || token === 58 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -3680,6 +3813,55 @@ var ts; pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } + function reScanJsxToken() { + pos = tokenPos = startPos; + return token = scanJsxToken(); + } + function scanJsxToken() { + startPos = tokenPos = pos; + if (pos >= end) { + return token = 1 /* EndOfFileToken */; + } + var char = text.charCodeAt(pos); + if (char === 60 /* lessThan */) { + if (text.charCodeAt(pos + 1) === 47 /* slash */) { + pos += 2; + return token = 25 /* LessThanSlashToken */; + } + pos++; + return token = 24 /* LessThanToken */; + } + if (char === 123 /* openBrace */) { + pos++; + return token = 14 /* OpenBraceToken */; + } + while (pos < end) { + pos++; + char = text.charCodeAt(pos); + if ((char === 123 /* openBrace */) || (char === 60 /* lessThan */)) { + break; + } + } + return token = 233 /* JsxText */; + } + // Scans a JSX identifier; these differ from normal identifiers in that + // they allow dashes + function scanJsxIdentifier() { + if (token === 66 /* Identifier */) { + var firstCharPosition = pos; + while (pos < end) { + var ch = text.charCodeAt(pos); + if (ch === 45 /* minus */ || ((firstCharPosition === pos) ? isIdentifierStart(ch) : isIdentifierPart(ch))) { + pos++; + } + else { + break; + } + } + tokenValue += text.substr(firstCharPosition, pos - firstCharPosition); + } + return token; + } function speculationHelper(callback, isLookahead) { var savePos = pos; var saveStartPos = startPos; @@ -3717,6 +3899,9 @@ var ts; function setScriptTarget(scriptTarget) { languageVersion = scriptTarget; } + function setLanguageVariant(variant) { + languageVariant = variant; + } function setTextPos(textPos) { ts.Debug.assert(textPos >= 0); pos = textPos; @@ -3743,18 +3928,18 @@ var ts; })(ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); var ModuleInstanceState = ts.ModuleInstanceState; function getModuleInstanceState(node) { - // A module is uninstantiated if it contains only + // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 205 /* InterfaceDeclaration */ || node.kind === 206 /* TypeAliasDeclaration */) { + if (node.kind === 212 /* InterfaceDeclaration */ || node.kind === 213 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 212 /* ImportDeclaration */ || node.kind === 211 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { + else if ((node.kind === 219 /* ImportDeclaration */ || node.kind === 218 /* ImportEqualsDeclaration */) && !(node.flags & 1 /* Export */)) { return 0 /* NonInstantiated */; } - else if (node.kind === 209 /* ModuleBlock */) { + else if (node.kind === 216 /* ModuleBlock */) { var state = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -3773,7 +3958,7 @@ var ts; }); return state; } - else if (node.kind === 208 /* ModuleDeclaration */) { + else if (node.kind === 215 /* ModuleDeclaration */) { return getModuleInstanceState(node.body); } else { @@ -3783,7 +3968,7 @@ var ts; ts.getModuleInstanceState = getModuleInstanceState; var ContainerFlags; (function (ContainerFlags) { - // The current node is not a container, and no container manipulation should happen before + // The current node is not a container, and no container manipulation should happen before // recursing into it. ContainerFlags[ContainerFlags["None"] = 0] = "None"; // The current node is a container. It should be set as the current container (and block- @@ -3814,7 +3999,7 @@ var ts; var blockScopeContainer; var lastContainer; // If this file is an external module, then it is automatically in strict-mode according to - // ES6. If it is not an external module, then we'll determine if it is in strict mode or + // ES6. If it is not an external module, then we'll determine if it is in strict mode or // not depending on if we see "use strict" in certain places (or if we hit a class/namespace). var inStrictMode = !!file.externalModuleIndicator; var symbolCount = 0; @@ -3851,10 +4036,10 @@ var ts; // unless it is a well known Symbol. function getDeclarationName(node) { if (node.name) { - if (node.kind === 208 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */) { + if (node.kind === 215 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */) { return '"' + node.name.text + '"'; } - if (node.name.kind === 129 /* ComputedPropertyName */) { + if (node.name.kind === 133 /* ComputedPropertyName */) { var nameExpression = node.name.expression; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(nameExpression.name.text); @@ -3862,43 +4047,51 @@ var ts; return node.name.text; } switch (node.kind) { - case 137 /* Constructor */: + case 141 /* Constructor */: return "__constructor"; - case 145 /* FunctionType */: - case 140 /* CallSignature */: + case 149 /* FunctionType */: + case 144 /* CallSignature */: return "__call"; - case 146 /* ConstructorType */: - case 141 /* ConstructSignature */: + case 150 /* ConstructorType */: + case 145 /* ConstructSignature */: return "__new"; - case 142 /* IndexSignature */: + case 146 /* IndexSignature */: return "__index"; - case 218 /* ExportDeclaration */: + case 225 /* ExportDeclaration */: return "__export"; - case 217 /* ExportAssignment */: + case 224 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 203 /* FunctionDeclaration */: - case 204 /* ClassDeclaration */: - return node.flags & 256 /* Default */ ? "default" : undefined; + case 210 /* FunctionDeclaration */: + case 211 /* ClassDeclaration */: + return node.flags & 1024 /* Default */ ? "default" : undefined; } } function getDisplayName(node) { return node.name ? ts.declarationNameToString(node.name) : getDeclarationName(node); } + /** + * Declares a Symbol for the node and adds it to symbols. Reports errors for conflicting identifier names. + * @param symbolTable - The symbol table which node will be added to. + * @param parent - node's parent declaration. + * @param node - The declaration to be added to the symbol table + * @param includes - The SymbolFlags that node has in addition to its declaration type (eg: export, ambient, etc.) + * @param excludes - The flags which node cannot be declared alongside in a symbol table. Used to report forbidden declarations. + */ function declareSymbol(symbolTable, parent, node, includes, excludes) { ts.Debug.assert(!ts.hasDynamicName(node)); // The exported symbol for an export default function/class node is always named "default" - var name = node.flags & 256 /* Default */ && parent ? "default" : getDeclarationName(node); + var name = node.flags & 1024 /* Default */ && parent ? "default" : getDeclarationName(node); var symbol; if (name !== undefined) { // Check and see if the symbol table already has a symbol with this name. If not, // create a new symbol with this name and add it to the table. Note that we don't - // give the new symbol any flags *yet*. This ensures that it will not conflict - // witht he 'excludes' flags we pass in. + // give the new symbol any flags *yet*. This ensures that it will not conflict + // with the 'excludes' flags we pass in. // // If we do get an existing symbol, see if it conflicts with the new symbol we're // creating. For example, a 'var' symbol and a 'class' symbol will conflict within - // the same symbol table. If we have a conflict, report the issue on each - // declaration we have for this symbol, and then create a new symbol for this + // the same symbol table. If we have a conflict, report the issue on each + // declaration we have for this symbol, and then create a new symbol for this // declaration. // // If we created a new symbol, either because we didn't have a symbol with this name @@ -3940,7 +4133,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedNodeFlags(node) & 1 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 220 /* ExportSpecifier */ || (node.kind === 211 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 227 /* ExportSpecifier */ || (node.kind === 218 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -3952,14 +4145,14 @@ var ts; // ExportType, or ExportContainer flag, and an associated export symbol with all the correct flags set // on it. There are 2 main reasons: // - // 1. We treat locals and exports of the same name as mutually exclusive within a container. + // 1. We treat locals and exports of the same name as mutually exclusive within a container. // That means the binder will issue a Duplicate Identifier error if you mix locals and exports // with the same name in the same container. // TODO: Make this a more specific error and decouple it from the exclusion logic. // 2. When we checkIdentifier in the checker, we set its resolved symbol to the local symbol, // but return the export symbol (by calling getExportSymbolOfValueSymbolIfExported). That way // when the emitter comes back to it, it knows not to qualify the name if it was found in a containing scope. - if (hasExportModifier || container.flags & 65536 /* ExportContext */) { + if (hasExportModifier || container.flags & 262144 /* ExportContext */) { var exportKind = (symbolFlags & 107455 /* Value */ ? 1048576 /* ExportValue */ : 0) | (symbolFlags & 793056 /* Type */ ? 2097152 /* ExportType */ : 0) | (symbolFlags & 1536 /* Namespace */ ? 4194304 /* ExportNamespace */ : 0); @@ -3973,11 +4166,11 @@ var ts; } } } - // All container nodes are kept on a linked list in declaration order. This list is used by - // the getLocalNameOfContainer function in the type checker to validate that the local name + // All container nodes are kept on a linked list in declaration order. This list is used by + // the getLocalNameOfContainer function in the type checker to validate that the local name // used for a container is unique. function bindChildren(node) { - // Before we recurse into a node's chilren, we first save the existing parent, container + // Before we recurse into a node's chilren, we first save the existing parent, container // and block-container. Then after we pop out of processing the children, we restore // these saved values. var saveParent = parent; @@ -3991,9 +4184,9 @@ var ts; // may contain locals, we proactively initialize the .locals field. We do this because // it's highly likely that the .locals will be needed to place some child in (for example, // a parameter, or variable declaration). - // + // // However, we do not proactively create the .locals for block-containers because it's - // totally normal and common for block-containers to never actually have a block-scoped + // totally normal and common for block-containers to never actually have a block-scoped // variable in them. We don't want to end up allocating an object for every 'block' we // run into when most of them won't be necessary. // @@ -4021,39 +4214,39 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 177 /* ClassExpression */: - case 204 /* ClassDeclaration */: - case 205 /* InterfaceDeclaration */: - case 207 /* EnumDeclaration */: - case 148 /* TypeLiteral */: - case 157 /* ObjectLiteralExpression */: + case 183 /* ClassExpression */: + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: + case 214 /* EnumDeclaration */: + case 152 /* TypeLiteral */: + case 162 /* ObjectLiteralExpression */: return 1 /* IsContainer */; - case 140 /* CallSignature */: - case 141 /* ConstructSignature */: - case 142 /* IndexSignature */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 203 /* FunctionDeclaration */: - case 137 /* Constructor */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 145 /* FunctionType */: - case 146 /* ConstructorType */: - case 165 /* FunctionExpression */: - case 166 /* ArrowFunction */: - case 208 /* ModuleDeclaration */: - case 230 /* SourceFile */: - case 206 /* TypeAliasDeclaration */: + case 144 /* CallSignature */: + case 145 /* ConstructSignature */: + case 146 /* IndexSignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 210 /* FunctionDeclaration */: + case 141 /* Constructor */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 149 /* FunctionType */: + case 150 /* ConstructorType */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: + case 215 /* ModuleDeclaration */: + case 245 /* SourceFile */: + case 213 /* TypeAliasDeclaration */: return 5 /* IsContainerWithLocals */; - case 226 /* CatchClause */: - case 189 /* ForStatement */: - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: - case 210 /* CaseBlock */: + case 241 /* CatchClause */: + case 196 /* ForStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: + case 217 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 182 /* Block */: + case 189 /* Block */: // do not treat blocks directly inside a function as a block-scoped-container. - // Locals that reside in this block should go to the function locals. Othewise 'x' + // Locals that reside in this block should go to the function locals. Othewise 'x' // would not appear to be a redeclaration of a block scoped local in the following // example: // @@ -4066,7 +4259,7 @@ var ts; // the block, then there would be no collision. // // By not creating a new block-scoped-container here, we ensure that both 'var x' - // and 'let x' go into the Function-container's locals, and we do get a collision + // and 'let x' go into the Function-container's locals, and we do get a collision // conflict. return ts.isFunctionLike(node.parent) ? 0 /* None */ : 2 /* IsBlockScopedContainer */; } @@ -4088,38 +4281,38 @@ var ts; // members are declared (for example, a member of a class will go into a specific // symbol table depending on if it is static or not). We defer to specialized // handlers to take care of declaring these child members. - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 230 /* SourceFile */: + case 245 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 177 /* ClassExpression */: - case 204 /* ClassDeclaration */: + case 183 /* ClassExpression */: + case 211 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 207 /* EnumDeclaration */: + case 214 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 148 /* TypeLiteral */: - case 157 /* ObjectLiteralExpression */: - case 205 /* InterfaceDeclaration */: + case 152 /* TypeLiteral */: + case 162 /* ObjectLiteralExpression */: + case 212 /* InterfaceDeclaration */: // Interface/Object-types always have their children added to the 'members' of // their container. They are only accessible through an instance of their // container, and are never in scope otherwise (even inside the body of the // object / type / interface declaring them). An exception is type parameters, // which are in scope without qualification (similar to 'locals'). return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 145 /* FunctionType */: - case 146 /* ConstructorType */: - case 140 /* CallSignature */: - case 141 /* ConstructSignature */: - case 142 /* IndexSignature */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 137 /* Constructor */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 203 /* FunctionDeclaration */: - case 165 /* FunctionExpression */: - case 166 /* ArrowFunction */: - case 206 /* TypeAliasDeclaration */: + case 149 /* FunctionType */: + case 150 /* ConstructorType */: + case 144 /* CallSignature */: + case 145 /* ConstructSignature */: + case 146 /* IndexSignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 141 /* Constructor */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 210 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: + case 213 /* TypeAliasDeclaration */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -4149,11 +4342,11 @@ var ts; return false; } function hasExportDeclarations(node) { - var body = node.kind === 230 /* SourceFile */ ? node : node.body; - if (body.kind === 230 /* SourceFile */ || body.kind === 209 /* ModuleBlock */) { + var body = node.kind === 245 /* SourceFile */ ? node : node.body; + if (body.kind === 245 /* SourceFile */ || body.kind === 216 /* ModuleBlock */) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 218 /* ExportDeclaration */ || stat.kind === 217 /* ExportAssignment */) { + if (stat.kind === 225 /* ExportDeclaration */ || stat.kind === 224 /* ExportAssignment */) { return true; } } @@ -4164,10 +4357,10 @@ var ts; // A declaration source file or ambient module declaration that contains no export declarations (but possibly regular // declarations with export modifiers) is an export context in which declarations are implicitly exported. if (isAmbientContext(node) && !hasExportDeclarations(node)) { - node.flags |= 65536 /* ExportContext */; + node.flags |= 262144 /* ExportContext */; } else { - node.flags &= ~65536 /* ExportContext */; + node.flags &= ~262144 /* ExportContext */; } } function bindModuleDeclaration(node) { @@ -4198,8 +4391,8 @@ var ts; // For a given function symbol "<...>(...) => T" we want to generate a symbol identical // to the one we would get for: { <...>(...): T } // - // We do that by making an anonymous type literal symbol, and then setting the function - // symbol as its sole member. To the rest of the system, this symbol will be indistinguishable + // We do that by making an anonymous type literal symbol, and then setting the function + // symbol as its sole member. To the rest of the system, this symbol will be indistinguishable // from an actual type literal symbol you would have gotten had you used the long form. var symbol = createSymbol(131072 /* Signature */, getDeclarationName(node)); addDeclarationToSymbol(symbol, node, 131072 /* Signature */); @@ -4218,7 +4411,7 @@ var ts; var seen = {}; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.name.kind !== 65 /* Identifier */) { + if (prop.name.kind !== 66 /* Identifier */) { continue; } var identifier = prop.name; @@ -4230,7 +4423,7 @@ var ts; // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind = prop.kind === 227 /* PropertyAssignment */ || prop.kind === 228 /* ShorthandPropertyAssignment */ || prop.kind === 136 /* MethodDeclaration */ + var currentKind = prop.kind === 242 /* PropertyAssignment */ || prop.kind === 243 /* ShorthandPropertyAssignment */ || prop.kind === 140 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen[identifier.text]; @@ -4252,10 +4445,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 230 /* SourceFile */: + case 245 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -4276,8 +4469,8 @@ var ts; // check for reserved words used as identifiers in strict mode code. function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 102 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 110 /* LastFutureReservedWord */ && + node.originalKeywordKind >= 103 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 111 /* LastFutureReservedWord */ && !ts.isIdentifierName(node)) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length) { @@ -4286,7 +4479,7 @@ var ts; } } function getStrictModeIdentifierMessage(node) { - // Provide specialized messages to help the user understand why we think they're in + // Provide specialized messages to help the user understand why we think they're in // strict mode. if (ts.getContainingClass(node)) { return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode; @@ -4312,7 +4505,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 65 /* Identifier */) { + if (inStrictMode && node.expression.kind === 66 /* Identifier */) { // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its // UnaryExpression is a direct reference to a variable, function argument, or function name var span = ts.getErrorSpanForNode(file, node.expression); @@ -4320,11 +4513,11 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 65 /* Identifier */ && + return node.kind === 66 /* Identifier */ && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 65 /* Identifier */) { + if (name && name.kind === 66 /* Identifier */) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -4335,7 +4528,7 @@ var ts; } } function getStrictModeEvalOrArgumentsMessage(node) { - // Provide specialized messages to help the user understand why we think they're in + // Provide specialized messages to help the user understand why we think they're in // strict mode. if (ts.getContainingClass(node)) { return ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode; @@ -4352,7 +4545,7 @@ var ts; } } function checkStrictModeNumericLiteral(node) { - if (inStrictMode && node.flags & 16384 /* OctalLiteral */) { + if (inStrictMode && node.flags & 65536 /* OctalLiteral */) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); } } @@ -4368,7 +4561,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 38 /* PlusPlusToken */ || node.operator === 39 /* MinusMinusToken */) { + if (node.operator === 39 /* PlusPlusToken */ || node.operator === 40 /* MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -4393,17 +4586,17 @@ var ts; updateStrictMode(node); } // First we bind declaration nodes to a symbol if possible. We'll both create a symbol - // and then potentially add the symbol to an appropriate symbol table. Possible + // and then potentially add the symbol to an appropriate symbol table. Possible // destination symbol tables are: - // + // // 1) The 'exports' table of the current container's symbol. // 2) The 'members' table of the current container's symbol. // 3) The 'locals' table of the current container. // - // However, not all symbols will end up in any of these tables. 'Anonymous' symbols + // However, not all symbols will end up in any of these tables. 'Anonymous' symbols // (like TypeLiterals for example) will not be put in any table. bindWorker(node); - // Then we recurse into the children of the node to bind them as well. For certain + // Then we recurse into the children of the node to bind them as well. For certain // symbols we do specialized work when we recurse. For example, we'll keep track of // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. @@ -4412,17 +4605,17 @@ var ts; } function updateStrictMode(node) { switch (node.kind) { - case 230 /* SourceFile */: - case 209 /* ModuleBlock */: + case 245 /* SourceFile */: + case 216 /* ModuleBlock */: updateStrictModeStatementList(node.statements); return; - case 182 /* Block */: + case 189 /* Block */: if (ts.isFunctionLike(node.parent)) { updateStrictModeStatementList(node.statements); } return; - case 204 /* ClassDeclaration */: - case 177 /* ClassExpression */: + case 211 /* ClassDeclaration */: + case 183 /* ClassExpression */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return; @@ -4449,91 +4642,92 @@ var ts; } function bindWorker(node) { switch (node.kind) { - case 65 /* Identifier */: + case 66 /* Identifier */: return checkStrictModeIdentifier(node); - case 172 /* BinaryExpression */: + case 178 /* BinaryExpression */: return checkStrictModeBinaryExpression(node); - case 226 /* CatchClause */: + case 241 /* CatchClause */: return checkStrictModeCatchClause(node); - case 167 /* DeleteExpression */: + case 172 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 7 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 171 /* PostfixUnaryExpression */: + case 177 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 170 /* PrefixUnaryExpression */: + case 176 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 195 /* WithStatement */: + case 202 /* WithStatement */: return checkStrictModeWithStatement(node); - case 130 /* TypeParameter */: + case 134 /* TypeParameter */: return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530912 /* TypeParameterExcludes */); - case 131 /* Parameter */: + case 135 /* Parameter */: return bindParameter(node); - case 201 /* VariableDeclaration */: - case 155 /* BindingElement */: + case 208 /* VariableDeclaration */: + case 160 /* BindingElement */: return bindVariableDeclarationOrBindingElement(node); - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), 107455 /* PropertyExcludes */); - case 227 /* PropertyAssignment */: - case 228 /* ShorthandPropertyAssignment */: + case 242 /* PropertyAssignment */: + case 243 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 107455 /* PropertyExcludes */); - case 229 /* EnumMember */: + case 244 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */); - case 140 /* CallSignature */: - case 141 /* ConstructSignature */: - case 142 /* IndexSignature */: + case 144 /* CallSignature */: + case 145 /* ConstructSignature */: + case 146 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 536870912 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 107455 /* PropertyExcludes */ : 99263 /* MethodExcludes */); - case 203 /* FunctionDeclaration */: + case 210 /* FunctionDeclaration */: checkStrictModeFunctionName(node); return declareSymbolAndAddToSymbolTable(node, 16 /* Function */, 106927 /* FunctionExcludes */); - case 137 /* Constructor */: + case 141 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, 0 /* None */); - case 138 /* GetAccessor */: + case 142 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); - case 139 /* SetAccessor */: + case 143 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); - case 145 /* FunctionType */: - case 146 /* ConstructorType */: + case 149 /* FunctionType */: + case 150 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 148 /* TypeLiteral */: + case 152 /* TypeLiteral */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 157 /* ObjectLiteralExpression */: + case 162 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 165 /* FunctionExpression */: - case 166 /* ArrowFunction */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: checkStrictModeFunctionName(node); - return bindAnonymousDeclaration(node, 16 /* Function */, "__function"); - case 177 /* ClassExpression */: - case 204 /* ClassDeclaration */: + var bindingName = node.name ? node.name.text : "__function"; + return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); + case 183 /* ClassExpression */: + case 211 /* ClassDeclaration */: return bindClassLikeDeclaration(node); - case 205 /* InterfaceDeclaration */: - return bindBlockScopedDeclaration(node, 64 /* Interface */, 792992 /* InterfaceExcludes */); - case 206 /* TypeAliasDeclaration */: + case 212 /* InterfaceDeclaration */: + return bindBlockScopedDeclaration(node, 64 /* Interface */, 792960 /* InterfaceExcludes */); + case 213 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793056 /* TypeAliasExcludes */); - case 207 /* EnumDeclaration */: + case 214 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: return bindModuleDeclaration(node); - case 211 /* ImportEqualsDeclaration */: - case 214 /* NamespaceImport */: - case 216 /* ImportSpecifier */: - case 220 /* ExportSpecifier */: + case 218 /* ImportEqualsDeclaration */: + case 221 /* NamespaceImport */: + case 223 /* ImportSpecifier */: + case 227 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 213 /* ImportClause */: + case 220 /* ImportClause */: return bindImportClause(node); - case 218 /* ExportDeclaration */: + case 225 /* ExportDeclaration */: return bindExportDeclaration(node); - case 217 /* ExportAssignment */: + case 224 /* ExportAssignment */: return bindExportAssignment(node); - case 230 /* SourceFile */: + case 245 /* SourceFile */: return bindSourceFileIfExternalModule(); } } @@ -4548,7 +4742,7 @@ var ts; // Export assignment in some sort of block construct bindAnonymousDeclaration(node, 8388608 /* Alias */, getDeclarationName(node)); } - else if (node.expression.kind === 65 /* Identifier */) { + else if (node.expression.kind === 66 /* Identifier */) { // An export default clause with an identifier exports all meanings of that identifier declareSymbol(container.symbol.exports, container.symbol, node, 8388608 /* Alias */, 107455 /* PropertyExcludes */ | 8388608 /* AliasExcludes */); } @@ -4573,17 +4767,18 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 204 /* ClassDeclaration */) { - bindBlockScopedDeclaration(node, 32 /* Class */, 899583 /* ClassExcludes */); + if (node.kind === 211 /* ClassDeclaration */) { + bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { - bindAnonymousDeclaration(node, 32 /* Class */, "__class"); + var bindingName = node.name ? node.name.text : "__class"; + bindAnonymousDeclaration(node, 32 /* Class */, bindingName); } var symbol = node.symbol; // TypeScript 1.0 spec (April 2014): 8.4 - // Every class automatically contains a static property member named 'prototype', the + // Every class automatically contains a static property member named 'prototype', the // type of which is an instantiation of the class type with type Any supplied as a type - // argument for each type parameter. It is an error to explicitly declare a static + // argument for each type parameter. It is an error to explicitly declare a static // property member with the name 'prototype'. // // Note: we check for this here because this class may be merging into a module. The @@ -4641,10 +4836,10 @@ var ts; else { declareSymbolAndAddToSymbolTable(node, 1 /* FunctionScopedVariable */, 107455 /* ParameterExcludes */); } - // If this is a property-parameter, then also declare the property symbol into the + // If this is a property-parameter, then also declare the property symbol into the // containing class. if (node.flags & 112 /* AccessibilityModifier */ && - node.parent.kind === 137 /* Constructor */ && + node.parent.kind === 141 /* Constructor */ && ts.isClassLike(node.parent.parent)) { var classDeclaration = node.parent.parent; declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 /* Property */, 107455 /* PropertyExcludes */); @@ -4663,10 +4858,12 @@ var ts; (function (ts) { function getDeclarationOfKind(symbol, kind) { var declarations = symbol.declarations; - for (var _i = 0; _i < declarations.length; _i++) { - var declaration = declarations[_i]; - if (declaration.kind === kind) { - return declaration; + if (declarations) { + for (var _i = 0; _i < declarations.length; _i++) { + var declaration = declarations[_i]; + if (declaration.kind === kind) { + return declaration; + } } } return undefined; @@ -4711,28 +4908,28 @@ var ts; // Returns true if this node contains a parse error anywhere underneath it. function containsParseError(node) { aggregateChildData(node); - return (node.parserContextFlags & 128 /* ThisNodeOrAnySubNodesHasError */) !== 0; + return (node.parserContextFlags & 64 /* ThisNodeOrAnySubNodesHasError */) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.parserContextFlags & 256 /* HasAggregatedChildData */)) { + if (!(node.parserContextFlags & 128 /* HasAggregatedChildData */)) { // A node is considered to contain a parse error if: // a) the parser explicitly marked that it had an error // b) any of it's children reported that it had an error. - var thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & 32 /* ThisNodeHasError */) !== 0) || + var thisNodeOrAnySubNodesHasError = ((node.parserContextFlags & 16 /* ThisNodeHasError */) !== 0) || ts.forEachChild(node, containsParseError); - // If so, mark ourselves accordingly. + // If so, mark ourselves accordingly. if (thisNodeOrAnySubNodesHasError) { - node.parserContextFlags |= 128 /* ThisNodeOrAnySubNodesHasError */; + node.parserContextFlags |= 64 /* ThisNodeOrAnySubNodesHasError */; } // Also mark that we've propogated the child information to this node. This way we can // always consult the bit directly on this node without needing to check its children // again. - node.parserContextFlags |= 256 /* HasAggregatedChildData */; + node.parserContextFlags |= 128 /* HasAggregatedChildData */; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 230 /* SourceFile */) { + while (node && node.kind !== 245 /* SourceFile */) { node = node.parent; } return node; @@ -4756,13 +4953,13 @@ var ts; ts.getStartPosOfNode = getStartPosOfNode; // Returns true if this node is missing from the actual source code. 'missing' is different // from 'undefined/defined'. When a node is undefined (which can happen for optional nodes - // in the tree), it is definitel missing. HOwever, a node may be defined, but still be + // in the tree), it is definitel missing. HOwever, a node may be defined, but still be // missing. This happens whenever the parser knows it needs to parse something, but can't // get anything in the source code that it expects at that location. For example: // // let a: ; // - // Here, the Type in the Type-Annotation is not-optional (as there is a colon in the source + // Here, the Type in the Type-Annotation is not-optional (as there is a colon in the source // code). So the parser will attempt to parse out a type, and will create an actual node. // However, this node will be 'missing' in the sense that no actual source-code/tokens are // contained within it. @@ -4770,7 +4967,7 @@ var ts; if (!node) { return true; } - return node.pos === node.end && node.kind !== 1 /* EndOfFileToken */; + return node.pos === node.end && node.pos >= 0 && node.kind !== 1 /* EndOfFileToken */; } ts.nodeIsMissing = nodeIsMissing; function nodeIsPresent(node) { @@ -4793,12 +4990,13 @@ var ts; return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end); } ts.getNonDecoratorTokenPosOfNode = getNonDecoratorTokenPosOfNode; - function getSourceTextOfNodeFromSourceFile(sourceFile, node) { + function getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia) { + if (includeTrivia === void 0) { includeTrivia = false; } if (nodeIsMissing(node)) { return ""; } var text = sourceFile.text; - return text.substring(ts.skipTrivia(text, node.pos), node.end); + return text.substring(includeTrivia ? node.pos : ts.skipTrivia(text, node.pos), node.end); } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function getTextOfNodeFromSourceText(sourceText, node) { @@ -4808,8 +5006,9 @@ var ts; return sourceText.substring(ts.skipTrivia(sourceText, node.pos), node.end); } ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText; - function getTextOfNode(node) { - return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node); + function getTextOfNode(node, includeTrivia) { + if (includeTrivia === void 0) { includeTrivia = false; } + return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); } ts.getTextOfNode = getTextOfNode; // Add an extra underscore to identifiers that start with two underscores to avoid issues with magic names like '__proto__' @@ -4829,11 +5028,11 @@ var ts; } ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName; function isBlockOrCatchScoped(declaration) { - return (getCombinedNodeFlags(declaration) & 12288 /* BlockScoped */) !== 0 || + return (getCombinedNodeFlags(declaration) & 49152 /* BlockScoped */) !== 0 || isCatchClauseVariableDeclaration(declaration); } ts.isBlockOrCatchScoped = isBlockOrCatchScoped; - // Gets the nearest enclosing block scope container that has the provided node + // Gets the nearest enclosing block scope container that has the provided node // as a descendant, that is not the provided node. function getEnclosingBlockScopeContainer(node) { var current = node.parent; @@ -4842,15 +5041,15 @@ var ts; return current; } switch (current.kind) { - case 230 /* SourceFile */: - case 210 /* CaseBlock */: - case 226 /* CatchClause */: - case 208 /* ModuleDeclaration */: - case 189 /* ForStatement */: - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: + case 245 /* SourceFile */: + case 217 /* CaseBlock */: + case 241 /* CatchClause */: + case 215 /* ModuleDeclaration */: + case 196 /* ForStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: return current; - case 182 /* Block */: + case 189 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block if (!isFunctionLike(current.parent)) { @@ -4863,9 +5062,9 @@ var ts; ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer; function isCatchClauseVariableDeclaration(declaration) { return declaration && - declaration.kind === 201 /* VariableDeclaration */ && + declaration.kind === 208 /* VariableDeclaration */ && declaration.parent && - declaration.parent.kind === 226 /* CatchClause */; + declaration.parent.kind === 241 /* CatchClause */; } ts.isCatchClauseVariableDeclaration = isCatchClauseVariableDeclaration; // Return display name of an identifier @@ -4895,7 +5094,7 @@ var ts; } ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; function getSpanOfTokenAtPosition(sourceFile, pos) { - var scanner = ts.createScanner(sourceFile.languageVersion, true, sourceFile.text, undefined, pos); + var scanner = ts.createScanner(sourceFile.languageVersion, true, sourceFile.languageVariant, sourceFile.text, undefined, pos); scanner.scan(); var start = scanner.getTokenPos(); return ts.createTextSpanFromBounds(start, scanner.getTextPos()); @@ -4904,7 +5103,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 230 /* SourceFile */: + case 245 /* SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -4913,21 +5112,21 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 201 /* VariableDeclaration */: - case 155 /* BindingElement */: - case 204 /* ClassDeclaration */: - case 177 /* ClassExpression */: - case 205 /* InterfaceDeclaration */: - case 208 /* ModuleDeclaration */: - case 207 /* EnumDeclaration */: - case 229 /* EnumMember */: - case 203 /* FunctionDeclaration */: - case 165 /* FunctionExpression */: + case 208 /* VariableDeclaration */: + case 160 /* BindingElement */: + case 211 /* ClassDeclaration */: + case 183 /* ClassExpression */: + case 212 /* InterfaceDeclaration */: + case 215 /* ModuleDeclaration */: + case 214 /* EnumDeclaration */: + case 244 /* EnumMember */: + case 210 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: errorNode = node.name; break; } if (errorNode === undefined) { - // If we don't have a better node, then just set the error on the first token of + // If we don't have a better node, then just set the error on the first token of // construct. return getSpanOfTokenAtPosition(sourceFile, node.pos); } @@ -4942,57 +5141,57 @@ var ts; } ts.isExternalModule = isExternalModule; function isDeclarationFile(file) { - return (file.flags & 2048 /* DeclarationFile */) !== 0; + return (file.flags & 8192 /* DeclarationFile */) !== 0; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 207 /* EnumDeclaration */ && isConst(node); + return node.kind === 214 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 155 /* BindingElement */ || isBindingPattern(node))) { + while (node && (node.kind === 160 /* BindingElement */ || isBindingPattern(node))) { node = node.parent; } return node; } - // Returns the node flags for this node and all relevant parent nodes. This is done so that + // Returns the node flags for this node and all relevant parent nodes. This is done so that // nodes like variable declarations and binding elements can returned a view of their flags // that includes the modifiers from their container. i.e. flags like export/declare aren't - // stored on the variable declaration directly, but on the containing variable statement + // stored on the variable declaration directly, but on the containing variable statement // (if it has one). Similarly, flags for let/const are store on the variable declaration // list. By calling this function, all those flags are combined so that the client can treat // the node as if it actually had those flags. function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 201 /* VariableDeclaration */) { + if (node.kind === 208 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 202 /* VariableDeclarationList */) { + if (node && node.kind === 209 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 183 /* VariableStatement */) { + if (node && node.kind === 190 /* VariableStatement */) { flags |= node.flags; } return flags; } ts.getCombinedNodeFlags = getCombinedNodeFlags; function isConst(node) { - return !!(getCombinedNodeFlags(node) & 8192 /* Const */); + return !!(getCombinedNodeFlags(node) & 32768 /* Const */); } ts.isConst = isConst; function isLet(node) { - return !!(getCombinedNodeFlags(node) & 4096 /* Let */); + return !!(getCombinedNodeFlags(node) & 16384 /* Let */); } ts.isLet = isLet; function isPrologueDirective(node) { - return node.kind === 185 /* ExpressionStatement */ && node.expression.kind === 8 /* StringLiteral */; + return node.kind === 192 /* ExpressionStatement */ && node.expression.kind === 8 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { // If parameter/type parameter, the prev token trailing comments are part of this node too - if (node.kind === 131 /* Parameter */ || node.kind === 130 /* TypeParameter */) { + if (node.kind === 135 /* Parameter */ || node.kind === 134 /* TypeParameter */) { // e.g. (/** blah */ a, /** blah */ b); // e.g.: ( // /** blah */ a, @@ -5016,40 +5215,40 @@ var ts; ts.getJsDocComments = getJsDocComments; ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*/; function isTypeNode(node) { - if (144 /* FirstTypeNode */ <= node.kind && node.kind <= 152 /* LastTypeNode */) { + if (148 /* FirstTypeNode */ <= node.kind && node.kind <= 157 /* LastTypeNode */) { return true; } switch (node.kind) { - case 112 /* AnyKeyword */: - case 121 /* NumberKeyword */: - case 123 /* StringKeyword */: - case 113 /* BooleanKeyword */: - case 124 /* SymbolKeyword */: + case 114 /* AnyKeyword */: + case 125 /* NumberKeyword */: + case 127 /* StringKeyword */: + case 117 /* BooleanKeyword */: + case 128 /* SymbolKeyword */: return true; - case 99 /* VoidKeyword */: - return node.parent.kind !== 169 /* VoidExpression */; + case 100 /* VoidKeyword */: + return node.parent.kind !== 174 /* VoidExpression */; case 8 /* StringLiteral */: // Specialized signatures can have string literals as their parameters' type names - return node.parent.kind === 131 /* Parameter */; - case 179 /* ExpressionWithTypeArguments */: + return node.parent.kind === 135 /* Parameter */; + case 185 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 65 /* Identifier */: + case 66 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 128 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 132 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 158 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 163 /* PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // fall through - case 128 /* QualifiedName */: - case 158 /* PropertyAccessExpression */: + case 132 /* QualifiedName */: + case 163 /* PropertyAccessExpression */: // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 65 /* Identifier */ || node.kind === 128 /* QualifiedName */ || node.kind === 158 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); + ts.Debug.assert(node.kind === 66 /* Identifier */ || node.kind === 132 /* QualifiedName */ || node.kind === 163 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isTypeNode'."); var parent_1 = node.parent; - if (parent_1.kind === 147 /* TypeQuery */) { + if (parent_1.kind === 151 /* TypeQuery */) { return false; } // Do not recursively call isTypeNode on the parent. In the example: @@ -5058,38 +5257,38 @@ var ts; // // Calling isTypeNode would consider the qualified name A.B a type node. Only C or // A.B.C is a type node. - if (144 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 152 /* LastTypeNode */) { + if (148 /* FirstTypeNode */ <= parent_1.kind && parent_1.kind <= 157 /* LastTypeNode */) { return true; } switch (parent_1.kind) { - case 179 /* ExpressionWithTypeArguments */: + case 185 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent_1); - case 130 /* TypeParameter */: + case 134 /* TypeParameter */: return node === parent_1.constraint; - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: - case 131 /* Parameter */: - case 201 /* VariableDeclaration */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: + case 135 /* Parameter */: + case 208 /* VariableDeclaration */: return node === parent_1.type; - case 203 /* FunctionDeclaration */: - case 165 /* FunctionExpression */: - case 166 /* ArrowFunction */: - case 137 /* Constructor */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: + case 210 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: + case 141 /* Constructor */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: return node === parent_1.type; - case 140 /* CallSignature */: - case 141 /* ConstructSignature */: - case 142 /* IndexSignature */: + case 144 /* CallSignature */: + case 145 /* ConstructSignature */: + case 146 /* IndexSignature */: return node === parent_1.type; - case 163 /* TypeAssertionExpression */: + case 168 /* TypeAssertionExpression */: return node === parent_1.type; - case 160 /* CallExpression */: - case 161 /* NewExpression */: + case 165 /* CallExpression */: + case 166 /* NewExpression */: return parent_1.typeArguments && ts.indexOf(parent_1.typeArguments, node) >= 0; - case 162 /* TaggedTemplateExpression */: + case 167 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -5103,23 +5302,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 194 /* ReturnStatement */: + case 201 /* ReturnStatement */: return visitor(node); - case 210 /* CaseBlock */: - case 182 /* Block */: - case 186 /* IfStatement */: - case 187 /* DoStatement */: - case 188 /* WhileStatement */: - case 189 /* ForStatement */: - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: - case 195 /* WithStatement */: - case 196 /* SwitchStatement */: - case 223 /* CaseClause */: - case 224 /* DefaultClause */: - case 197 /* LabeledStatement */: - case 199 /* TryStatement */: - case 226 /* CatchClause */: + case 217 /* CaseBlock */: + case 189 /* Block */: + case 193 /* IfStatement */: + case 194 /* DoStatement */: + case 195 /* WhileStatement */: + case 196 /* ForStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: + case 202 /* WithStatement */: + case 203 /* SwitchStatement */: + case 238 /* CaseClause */: + case 239 /* DefaultClause */: + case 204 /* LabeledStatement */: + case 206 /* TryStatement */: + case 241 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -5129,29 +5328,29 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 175 /* YieldExpression */: + case 181 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 207 /* EnumDeclaration */: - case 205 /* InterfaceDeclaration */: - case 208 /* ModuleDeclaration */: - case 206 /* TypeAliasDeclaration */: - case 204 /* ClassDeclaration */: - case 177 /* ClassExpression */: + case 214 /* EnumDeclaration */: + case 212 /* InterfaceDeclaration */: + case 215 /* ModuleDeclaration */: + case 213 /* TypeAliasDeclaration */: + case 211 /* ClassDeclaration */: + case 183 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. return; default: if (isFunctionLike(node)) { - var name_4 = node.name; - if (name_4 && name_4.kind === 129 /* ComputedPropertyName */) { + var name_5 = node.name; + if (name_5 && name_5.kind === 133 /* ComputedPropertyName */) { // Note that we will not include methods/accessors of a class because they would require // first descending into the class. This is by design. - traverse(name_4.expression); + traverse(name_5.expression); return; } } @@ -5167,14 +5366,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 155 /* BindingElement */: - case 229 /* EnumMember */: - case 131 /* Parameter */: - case 227 /* PropertyAssignment */: - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: - case 228 /* ShorthandPropertyAssignment */: - case 201 /* VariableDeclaration */: + case 160 /* BindingElement */: + case 244 /* EnumMember */: + case 135 /* Parameter */: + case 242 /* PropertyAssignment */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: + case 243 /* ShorthandPropertyAssignment */: + case 208 /* VariableDeclaration */: return true; } } @@ -5182,29 +5381,29 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 138 /* GetAccessor */ || node.kind === 139 /* SetAccessor */); + return node && (node.kind === 142 /* GetAccessor */ || node.kind === 143 /* SetAccessor */); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 204 /* ClassDeclaration */ || node.kind === 177 /* ClassExpression */); + return node && (node.kind === 211 /* ClassDeclaration */ || node.kind === 183 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { if (node) { switch (node.kind) { - case 137 /* Constructor */: - case 165 /* FunctionExpression */: - case 203 /* FunctionDeclaration */: - case 166 /* ArrowFunction */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 140 /* CallSignature */: - case 141 /* ConstructSignature */: - case 142 /* IndexSignature */: - case 145 /* FunctionType */: - case 146 /* ConstructorType */: + case 141 /* Constructor */: + case 170 /* FunctionExpression */: + case 210 /* FunctionDeclaration */: + case 171 /* ArrowFunction */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 144 /* CallSignature */: + case 145 /* ConstructSignature */: + case 146 /* IndexSignature */: + case 149 /* FunctionType */: + case 150 /* ConstructorType */: return true; } } @@ -5212,11 +5411,11 @@ var ts; } ts.isFunctionLike = isFunctionLike; function isFunctionBlock(node) { - return node && node.kind === 182 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 189 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 136 /* MethodDeclaration */ && node.parent.kind === 157 /* ObjectLiteralExpression */; + return node && node.kind === 140 /* MethodDeclaration */ && node.parent.kind === 162 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function getContainingFunction(node) { @@ -5244,7 +5443,7 @@ var ts; return undefined; } switch (node.kind) { - case 129 /* ComputedPropertyName */: + case 133 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'this' container. // A computed property name in a class needs to be a this container @@ -5259,9 +5458,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 132 /* Decorator */: - // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 131 /* Parameter */ && isClassElement(node.parent.parent)) { + case 136 /* Decorator */: + // Decorators are always applied outside of the body of a class or method. + if (node.parent.kind === 135 /* Parameter */ && isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -5272,23 +5471,23 @@ var ts; node = node.parent; } break; - case 166 /* ArrowFunction */: + case 171 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // Fall through - case 203 /* FunctionDeclaration */: - case 165 /* FunctionExpression */: - case 208 /* ModuleDeclaration */: - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 137 /* Constructor */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 207 /* EnumDeclaration */: - case 230 /* SourceFile */: + case 210 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: + case 215 /* ModuleDeclaration */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 141 /* Constructor */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 214 /* EnumDeclaration */: + case 245 /* SourceFile */: return node; } } @@ -5300,7 +5499,7 @@ var ts; if (!node) return node; switch (node.kind) { - case 129 /* ComputedPropertyName */: + case 133 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'super' container. // A computed property name in a class needs to be a super container @@ -5315,9 +5514,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 132 /* Decorator */: - // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 131 /* Parameter */ && isClassElement(node.parent.parent)) { + case 136 /* Decorator */: + // Decorators are always applied outside of the body of a class or method. + if (node.parent.kind === 135 /* Parameter */ && isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -5328,26 +5527,41 @@ var ts; node = node.parent; } break; - case 203 /* FunctionDeclaration */: - case 165 /* FunctionExpression */: - case 166 /* ArrowFunction */: + case 210 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: if (!includeFunctions) { continue; } - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 137 /* Constructor */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 141 /* Constructor */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: return node; } } } ts.getSuperContainer = getSuperContainer; + function getEntityNameFromTypeNode(node) { + if (node) { + switch (node.kind) { + case 148 /* TypeReference */: + return node.typeName; + case 185 /* ExpressionWithTypeArguments */: + return node.expression; + case 66 /* Identifier */: + case 132 /* QualifiedName */: + return node; + } + } + return undefined; + } + ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { - if (node.kind === 162 /* TaggedTemplateExpression */) { + if (node.kind === 167 /* TaggedTemplateExpression */) { return node.tag; } // Will either be a CallExpression, NewExpression, or Decorator. @@ -5356,44 +5570,44 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 204 /* ClassDeclaration */: + case 211 /* ClassDeclaration */: // classes are valid targets return true; - case 134 /* PropertyDeclaration */: + case 138 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 204 /* ClassDeclaration */; - case 131 /* Parameter */: + return node.parent.kind === 211 /* ClassDeclaration */; + case 135 /* Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; - return node.parent.body && node.parent.parent.kind === 204 /* ClassDeclaration */; - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 136 /* MethodDeclaration */: + return node.parent.body && node.parent.parent.kind === 211 /* ClassDeclaration */; + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 140 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. - return node.body && node.parent.kind === 204 /* ClassDeclaration */; + return node.body && node.parent.kind === 211 /* ClassDeclaration */; } return false; } ts.nodeCanBeDecorated = nodeCanBeDecorated; function nodeIsDecorated(node) { switch (node.kind) { - case 204 /* ClassDeclaration */: + case 211 /* ClassDeclaration */: if (node.decorators) { return true; } return false; - case 134 /* PropertyDeclaration */: - case 131 /* Parameter */: + case 138 /* PropertyDeclaration */: + case 135 /* Parameter */: if (node.decorators) { return true; } return false; - case 138 /* GetAccessor */: + case 142 /* GetAccessor */: if (node.body && node.decorators) { return true; } return false; - case 136 /* MethodDeclaration */: - case 139 /* SetAccessor */: + case 140 /* MethodDeclaration */: + case 143 /* SetAccessor */: if (node.body && node.decorators) { return true; } @@ -5404,10 +5618,10 @@ var ts; ts.nodeIsDecorated = nodeIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 204 /* ClassDeclaration */: + case 211 /* ClassDeclaration */: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 136 /* MethodDeclaration */: - case 139 /* SetAccessor */: + case 140 /* MethodDeclaration */: + case 143 /* SetAccessor */: return ts.forEach(node.parameters, nodeIsDecorated); } return false; @@ -5419,44 +5633,47 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function isExpression(node) { switch (node.kind) { - case 93 /* ThisKeyword */: - case 91 /* SuperKeyword */: - case 89 /* NullKeyword */: - case 95 /* TrueKeyword */: - case 80 /* FalseKeyword */: + case 94 /* ThisKeyword */: + case 92 /* SuperKeyword */: + case 90 /* NullKeyword */: + case 96 /* TrueKeyword */: + case 81 /* FalseKeyword */: case 9 /* RegularExpressionLiteral */: - case 156 /* ArrayLiteralExpression */: - case 157 /* ObjectLiteralExpression */: - case 158 /* PropertyAccessExpression */: - case 159 /* ElementAccessExpression */: - case 160 /* CallExpression */: - case 161 /* NewExpression */: - case 162 /* TaggedTemplateExpression */: - case 163 /* TypeAssertionExpression */: - case 164 /* ParenthesizedExpression */: - case 165 /* FunctionExpression */: - case 177 /* ClassExpression */: - case 166 /* ArrowFunction */: - case 169 /* VoidExpression */: - case 167 /* DeleteExpression */: - case 168 /* TypeOfExpression */: - case 170 /* PrefixUnaryExpression */: - case 171 /* PostfixUnaryExpression */: - case 172 /* BinaryExpression */: - case 173 /* ConditionalExpression */: - case 176 /* SpreadElementExpression */: - case 174 /* TemplateExpression */: + case 161 /* ArrayLiteralExpression */: + case 162 /* ObjectLiteralExpression */: + case 163 /* PropertyAccessExpression */: + case 164 /* ElementAccessExpression */: + case 165 /* CallExpression */: + case 166 /* NewExpression */: + case 167 /* TaggedTemplateExpression */: + case 186 /* AsExpression */: + case 168 /* TypeAssertionExpression */: + case 169 /* ParenthesizedExpression */: + case 170 /* FunctionExpression */: + case 183 /* ClassExpression */: + case 171 /* ArrowFunction */: + case 174 /* VoidExpression */: + case 172 /* DeleteExpression */: + case 173 /* TypeOfExpression */: + case 176 /* PrefixUnaryExpression */: + case 177 /* PostfixUnaryExpression */: + case 178 /* BinaryExpression */: + case 179 /* ConditionalExpression */: + case 182 /* SpreadElementExpression */: + case 180 /* TemplateExpression */: case 10 /* NoSubstitutionTemplateLiteral */: - case 178 /* OmittedExpression */: - case 175 /* YieldExpression */: + case 184 /* OmittedExpression */: + case 230 /* JsxElement */: + case 231 /* JsxSelfClosingElement */: + case 181 /* YieldExpression */: return true; - case 128 /* QualifiedName */: - while (node.parent.kind === 128 /* QualifiedName */) { + case 132 /* QualifiedName */: + while (node.parent.kind === 132 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 147 /* TypeQuery */; - case 65 /* Identifier */: - if (node.parent.kind === 147 /* TypeQuery */) { + return node.parent.kind === 151 /* TypeQuery */; + case 66 /* Identifier */: + if (node.parent.kind === 151 /* TypeQuery */) { return true; } // fall through @@ -5464,44 +5681,45 @@ var ts; case 8 /* StringLiteral */: var parent_2 = node.parent; switch (parent_2.kind) { - case 201 /* VariableDeclaration */: - case 131 /* Parameter */: - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: - case 229 /* EnumMember */: - case 227 /* PropertyAssignment */: - case 155 /* BindingElement */: + case 208 /* VariableDeclaration */: + case 135 /* Parameter */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: + case 244 /* EnumMember */: + case 242 /* PropertyAssignment */: + case 160 /* BindingElement */: return parent_2.initializer === node; - case 185 /* ExpressionStatement */: - case 186 /* IfStatement */: - case 187 /* DoStatement */: - case 188 /* WhileStatement */: - case 194 /* ReturnStatement */: - case 195 /* WithStatement */: - case 196 /* SwitchStatement */: - case 223 /* CaseClause */: - case 198 /* ThrowStatement */: - case 196 /* SwitchStatement */: + case 192 /* ExpressionStatement */: + case 193 /* IfStatement */: + case 194 /* DoStatement */: + case 195 /* WhileStatement */: + case 201 /* ReturnStatement */: + case 202 /* WithStatement */: + case 203 /* SwitchStatement */: + case 238 /* CaseClause */: + case 205 /* ThrowStatement */: + case 203 /* SwitchStatement */: return parent_2.expression === node; - case 189 /* ForStatement */: + case 196 /* ForStatement */: var forStatement = parent_2; - return (forStatement.initializer === node && forStatement.initializer.kind !== 202 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 209 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: var forInStatement = parent_2; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 202 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 209 /* VariableDeclarationList */) || forInStatement.expression === node; - case 163 /* TypeAssertionExpression */: + case 168 /* TypeAssertionExpression */: + case 186 /* AsExpression */: return node === parent_2.expression; - case 180 /* TemplateSpan */: + case 187 /* TemplateSpan */: return node === parent_2.expression; - case 129 /* ComputedPropertyName */: + case 133 /* ComputedPropertyName */: return node === parent_2.expression; - case 132 /* Decorator */: + case 136 /* Decorator */: return true; - case 179 /* ExpressionWithTypeArguments */: + case 185 /* ExpressionWithTypeArguments */: return parent_2.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_2); default: if (isExpression(parent_2)) { @@ -5519,7 +5737,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 211 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 222 /* ExternalModuleReference */; + return node.kind === 218 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 229 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -5528,20 +5746,20 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 211 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 222 /* ExternalModuleReference */; + return node.kind === 218 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 229 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function getExternalModuleName(node) { - if (node.kind === 212 /* ImportDeclaration */) { + if (node.kind === 219 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 211 /* ImportEqualsDeclaration */) { + if (node.kind === 218 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 222 /* ExternalModuleReference */) { + if (reference.kind === 229 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 218 /* ExportDeclaration */) { + if (node.kind === 225 /* ExportDeclaration */) { return node.moduleSpecifier; } } @@ -5549,15 +5767,15 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 131 /* Parameter */: + case 135 /* Parameter */: return node.questionToken !== undefined; - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: return node.questionToken !== undefined; - case 228 /* ShorthandPropertyAssignment */: - case 227 /* PropertyAssignment */: - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: + case 243 /* ShorthandPropertyAssignment */: + case 242 /* PropertyAssignment */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -5565,9 +5783,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 243 /* JSDocFunctionType */ && + return node.kind === 258 /* JSDocFunctionType */ && node.parameters.length > 0 && - node.parameters[0].type.kind === 245 /* JSDocConstructorType */; + node.parameters[0].type.kind === 260 /* JSDocConstructorType */; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getJSDocTag(node, kind) { @@ -5581,29 +5799,29 @@ var ts; } } function getJSDocTypeTag(node) { - return getJSDocTag(node, 251 /* JSDocTypeTag */); + return getJSDocTag(node, 266 /* JSDocTypeTag */); } ts.getJSDocTypeTag = getJSDocTypeTag; function getJSDocReturnTag(node) { - return getJSDocTag(node, 250 /* JSDocReturnTag */); + return getJSDocTag(node, 265 /* JSDocReturnTag */); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getJSDocTag(node, 252 /* JSDocTemplateTag */); + return getJSDocTag(node, 267 /* JSDocTemplateTag */); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function getCorrespondingJSDocParameterTag(parameter) { - if (parameter.name && parameter.name.kind === 65 /* Identifier */) { - // If it's a parameter, see if the parent has a jsdoc comment with an @param + if (parameter.name && parameter.name.kind === 66 /* Identifier */) { + // If it's a parameter, see if the parent has a jsdoc comment with an @param // annotation. var parameterName = parameter.name.text; var docComment = parameter.parent.jsDocComment; if (docComment) { return ts.forEach(docComment.tags, function (t) { - if (t.kind === 249 /* JSDocParameterTag */) { + if (t.kind === 264 /* JSDocParameterTag */) { var parameterTag = t; - var name_5 = parameterTag.preParameterName || parameterTag.postParameterName; - if (name_5.text === parameterName) { + var name_6 = parameterTag.preParameterName || parameterTag.postParameterName; + if (name_6.text === parameterName) { return t; } } @@ -5618,13 +5836,13 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { if (node) { - if (node.parserContextFlags & 64 /* JavaScriptFile */) { - if (node.type && node.type.kind === 244 /* JSDocVariadicType */) { + if (node.parserContextFlags & 32 /* JavaScriptFile */) { + if (node.type && node.type.kind === 259 /* JSDocVariadicType */) { return true; } var paramTag = getCorrespondingJSDocParameterTag(node); if (paramTag && paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 244 /* JSDocVariadicType */; + return paramTag.typeExpression.type.kind === 259 /* JSDocVariadicType */; } } return node.dotDotDotToken !== undefined; @@ -5645,12 +5863,12 @@ var ts; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isBindingPattern(node) { - return !!node && (node.kind === 154 /* ArrayBindingPattern */ || node.kind === 153 /* ObjectBindingPattern */); + return !!node && (node.kind === 159 /* ArrayBindingPattern */ || node.kind === 158 /* ObjectBindingPattern */); } ts.isBindingPattern = isBindingPattern; function isInAmbientContext(node) { while (node) { - if (node.flags & (2 /* Ambient */ | 2048 /* DeclarationFile */)) { + if (node.flags & (2 /* Ambient */ | 8192 /* DeclarationFile */)) { return true; } node = node.parent; @@ -5660,34 +5878,34 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 166 /* ArrowFunction */: - case 155 /* BindingElement */: - case 204 /* ClassDeclaration */: - case 177 /* ClassExpression */: - case 137 /* Constructor */: - case 207 /* EnumDeclaration */: - case 229 /* EnumMember */: - case 220 /* ExportSpecifier */: - case 203 /* FunctionDeclaration */: - case 165 /* FunctionExpression */: - case 138 /* GetAccessor */: - case 213 /* ImportClause */: - case 211 /* ImportEqualsDeclaration */: - case 216 /* ImportSpecifier */: - case 205 /* InterfaceDeclaration */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 208 /* ModuleDeclaration */: - case 214 /* NamespaceImport */: - case 131 /* Parameter */: - case 227 /* PropertyAssignment */: - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: - case 139 /* SetAccessor */: - case 228 /* ShorthandPropertyAssignment */: - case 206 /* TypeAliasDeclaration */: - case 130 /* TypeParameter */: - case 201 /* VariableDeclaration */: + case 171 /* ArrowFunction */: + case 160 /* BindingElement */: + case 211 /* ClassDeclaration */: + case 183 /* ClassExpression */: + case 141 /* Constructor */: + case 214 /* EnumDeclaration */: + case 244 /* EnumMember */: + case 227 /* ExportSpecifier */: + case 210 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: + case 142 /* GetAccessor */: + case 220 /* ImportClause */: + case 218 /* ImportEqualsDeclaration */: + case 223 /* ImportSpecifier */: + case 212 /* InterfaceDeclaration */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 215 /* ModuleDeclaration */: + case 221 /* NamespaceImport */: + case 135 /* Parameter */: + case 242 /* PropertyAssignment */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: + case 143 /* SetAccessor */: + case 243 /* ShorthandPropertyAssignment */: + case 213 /* TypeAliasDeclaration */: + case 134 /* TypeParameter */: + case 208 /* VariableDeclaration */: return true; } return false; @@ -5695,25 +5913,25 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 193 /* BreakStatement */: - case 192 /* ContinueStatement */: - case 200 /* DebuggerStatement */: - case 187 /* DoStatement */: - case 185 /* ExpressionStatement */: - case 184 /* EmptyStatement */: - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: - case 189 /* ForStatement */: - case 186 /* IfStatement */: - case 197 /* LabeledStatement */: - case 194 /* ReturnStatement */: - case 196 /* SwitchStatement */: - case 94 /* ThrowKeyword */: - case 199 /* TryStatement */: - case 183 /* VariableStatement */: - case 188 /* WhileStatement */: - case 195 /* WithStatement */: - case 217 /* ExportAssignment */: + case 200 /* BreakStatement */: + case 199 /* ContinueStatement */: + case 207 /* DebuggerStatement */: + case 194 /* DoStatement */: + case 192 /* ExpressionStatement */: + case 191 /* EmptyStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: + case 196 /* ForStatement */: + case 193 /* IfStatement */: + case 204 /* LabeledStatement */: + case 201 /* ReturnStatement */: + case 203 /* SwitchStatement */: + case 95 /* ThrowKeyword */: + case 206 /* TryStatement */: + case 190 /* VariableStatement */: + case 195 /* WhileStatement */: + case 202 /* WithStatement */: + case 224 /* ExportAssignment */: return true; default: return false; @@ -5722,13 +5940,13 @@ var ts; ts.isStatement = isStatement; function isClassElement(n) { switch (n.kind) { - case 137 /* Constructor */: - case 134 /* PropertyDeclaration */: - case 136 /* MethodDeclaration */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 135 /* MethodSignature */: - case 142 /* IndexSignature */: + case 141 /* Constructor */: + case 138 /* PropertyDeclaration */: + case 140 /* MethodDeclaration */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 139 /* MethodSignature */: + case 146 /* IndexSignature */: return true; default: return false; @@ -5737,11 +5955,11 @@ var ts; ts.isClassElement = isClassElement; // True if the given identifier, string literal, or number literal is the name of a declaration node function isDeclarationName(name) { - if (name.kind !== 65 /* Identifier */ && name.kind !== 8 /* StringLiteral */ && name.kind !== 7 /* NumericLiteral */) { + if (name.kind !== 66 /* Identifier */ && name.kind !== 8 /* StringLiteral */ && name.kind !== 7 /* NumericLiteral */) { return false; } var parent = name.parent; - if (parent.kind === 216 /* ImportSpecifier */ || parent.kind === 220 /* ExportSpecifier */) { + if (parent.kind === 223 /* ImportSpecifier */ || parent.kind === 227 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -5756,31 +5974,31 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 229 /* EnumMember */: - case 227 /* PropertyAssignment */: - case 158 /* PropertyAccessExpression */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 244 /* EnumMember */: + case 242 /* PropertyAssignment */: + case 163 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 128 /* QualifiedName */: + case 132 /* QualifiedName */: // Name on right hand side of dot in a type query if (parent.right === node) { - while (parent.kind === 128 /* QualifiedName */) { + while (parent.kind === 132 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 147 /* TypeQuery */; + return parent.kind === 151 /* TypeQuery */; } return false; - case 155 /* BindingElement */: - case 216 /* ImportSpecifier */: + case 160 /* BindingElement */: + case 223 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 220 /* ExportSpecifier */: + case 227 /* ExportSpecifier */: // Any name in an export specifier return true; } @@ -5796,26 +6014,26 @@ var ts; // export = ... // export default ... function isAliasSymbolDeclaration(node) { - return node.kind === 211 /* ImportEqualsDeclaration */ || - node.kind === 213 /* ImportClause */ && !!node.name || - node.kind === 214 /* NamespaceImport */ || - node.kind === 216 /* ImportSpecifier */ || - node.kind === 220 /* ExportSpecifier */ || - node.kind === 217 /* ExportAssignment */ && node.expression.kind === 65 /* Identifier */; + return node.kind === 218 /* ImportEqualsDeclaration */ || + node.kind === 220 /* ImportClause */ && !!node.name || + node.kind === 221 /* NamespaceImport */ || + node.kind === 223 /* ImportSpecifier */ || + node.kind === 227 /* ExportSpecifier */ || + node.kind === 224 /* ExportAssignment */ && node.expression.kind === 66 /* Identifier */; } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 79 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 80 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 102 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 103 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 79 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 80 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -5884,13 +6102,17 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 66 /* FirstKeyword */ <= token && token <= 127 /* LastKeyword */; + return 67 /* FirstKeyword */ <= token && token <= 131 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { return 2 /* FirstTriviaToken */ <= token && token <= 6 /* LastTriviaToken */; } ts.isTrivia = isTrivia; + function isAsyncFunctionLike(node) { + return isFunctionLike(node) && (node.flags & 512 /* Async */) !== 0 && !isAccessor(node); + } + ts.isAsyncFunctionLike = isAsyncFunctionLike; /** * A declaration has a dynamic name if both of the following are true: * 1. The declaration has a computed property name @@ -5900,7 +6122,7 @@ var ts; */ function hasDynamicName(declaration) { return declaration.name && - declaration.name.kind === 129 /* ComputedPropertyName */ && + declaration.name.kind === 133 /* ComputedPropertyName */ && !isWellKnownSymbolSyntactically(declaration.name.expression); } ts.hasDynamicName = hasDynamicName; @@ -5910,14 +6132,14 @@ var ts; * where Symbol is literally the word "Symbol", and name is any identifierName */ function isWellKnownSymbolSyntactically(node) { - return node.kind === 158 /* PropertyAccessExpression */ && isESSymbolIdentifier(node.expression); + return node.kind === 163 /* PropertyAccessExpression */ && isESSymbolIdentifier(node.expression); } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 65 /* Identifier */ || name.kind === 8 /* StringLiteral */ || name.kind === 7 /* NumericLiteral */) { + if (name.kind === 66 /* Identifier */ || name.kind === 8 /* StringLiteral */ || name.kind === 7 /* NumericLiteral */) { return name.text; } - if (name.kind === 129 /* ComputedPropertyName */) { + if (name.kind === 133 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -5935,19 +6157,21 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 65 /* Identifier */ && node.text === "Symbol"; + return node.kind === 66 /* Identifier */ && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isModifier(token) { switch (token) { - case 108 /* PublicKeyword */: - case 106 /* PrivateKeyword */: - case 107 /* ProtectedKeyword */: - case 109 /* StaticKeyword */: - case 78 /* ExportKeyword */: - case 115 /* DeclareKeyword */: - case 70 /* ConstKeyword */: - case 73 /* DefaultKeyword */: + case 112 /* AbstractKeyword */: + case 115 /* AsyncKeyword */: + case 71 /* ConstKeyword */: + case 119 /* DeclareKeyword */: + case 74 /* DefaultKeyword */: + case 79 /* ExportKeyword */: + case 109 /* PublicKeyword */: + case 107 /* PrivateKeyword */: + case 108 /* ProtectedKeyword */: + case 110 /* StaticKeyword */: return true; } return false; @@ -5955,18 +6179,18 @@ var ts; ts.isModifier = isModifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 131 /* Parameter */; + return root.kind === 135 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 155 /* BindingElement */) { + while (node.kind === 160 /* BindingElement */) { node = node.parent.parent; } return node; } ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(n) { - return isFunctionLike(n) || n.kind === 208 /* ModuleDeclaration */ || n.kind === 230 /* SourceFile */; + return isFunctionLike(n) || n.kind === 215 /* ModuleDeclaration */ || n.kind === 245 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -5975,8 +6199,6 @@ var ts; ts.nodeIsSynthesized = nodeIsSynthesized; function createSynthesizedNode(kind, startsOnNewLine) { var node = ts.createNode(kind); - node.pos = -1; - node.end = -1; node.startsOnNewLine = startsOnNewLine; return node; } @@ -6086,6 +6308,11 @@ var ts; } } ts.escapeString = escapeString; + function isIntrinsicJsxName(name) { + var ch = name.substr(0, 1); + return ch.toLowerCase() === ch; + } + ts.isIntrinsicJsxName = isIntrinsicJsxName; function get16BitUnicodeEscapeSequence(charCode) { var hexCharCode = charCode.toString(16).toUpperCase(); var paddedHexCode = ("0000" + hexCharCode).slice(-4); @@ -6202,12 +6429,16 @@ var ts; ts.getLineOfLocalPosition = getLineOfLocalPosition; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 137 /* Constructor */ && nodeIsPresent(member.body)) { + if (member.kind === 141 /* Constructor */ && nodeIsPresent(member.body)) { return member; } }); } ts.getFirstConstructorWithBody = getFirstConstructorWithBody; + function getSetAccessorTypeAnnotationNode(accessor) { + return accessor && accessor.parameters.length > 0 && accessor.parameters[0].type; + } + ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode; function shouldEmitToOwnFile(sourceFile, compilerOptions) { if (!isDeclarationFile(sourceFile)) { if ((isExternalModule(sourceFile) || !compilerOptions.out)) { @@ -6227,10 +6458,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 138 /* GetAccessor */) { + if (accessor.kind === 142 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 139 /* SetAccessor */) { + else if (accessor.kind === 143 /* SetAccessor */) { setAccessor = accessor; } else { @@ -6239,7 +6470,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 138 /* GetAccessor */ || member.kind === 139 /* SetAccessor */) + if ((member.kind === 142 /* GetAccessor */ || member.kind === 143 /* SetAccessor */) && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -6250,10 +6481,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 138 /* GetAccessor */ && !getAccessor) { + if (member.kind === 142 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 139 /* SetAccessor */ && !setAccessor) { + if (member.kind === 143 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -6386,14 +6617,16 @@ var ts; ts.writeCommentRange = writeCommentRange; function modifierToFlag(token) { switch (token) { - case 109 /* StaticKeyword */: return 128 /* Static */; - case 108 /* PublicKeyword */: return 16 /* Public */; - case 107 /* ProtectedKeyword */: return 64 /* Protected */; - case 106 /* PrivateKeyword */: return 32 /* Private */; - case 78 /* ExportKeyword */: return 1 /* Export */; - case 115 /* DeclareKeyword */: return 2 /* Ambient */; - case 70 /* ConstKeyword */: return 8192 /* Const */; - case 73 /* DefaultKeyword */: return 256 /* Default */; + case 110 /* StaticKeyword */: return 128 /* Static */; + case 109 /* PublicKeyword */: return 16 /* Public */; + case 108 /* ProtectedKeyword */: return 64 /* Protected */; + case 107 /* PrivateKeyword */: return 32 /* Private */; + case 112 /* AbstractKeyword */: return 256 /* Abstract */; + case 79 /* ExportKeyword */: return 1 /* Export */; + case 119 /* DeclareKeyword */: return 2 /* Ambient */; + case 71 /* ConstKeyword */: return 32768 /* Const */; + case 74 /* DefaultKeyword */: return 1024 /* Default */; + case 115 /* AsyncKeyword */: return 512 /* Async */; } return 0; } @@ -6401,27 +6634,29 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 158 /* PropertyAccessExpression */: - case 159 /* ElementAccessExpression */: - case 161 /* NewExpression */: - case 160 /* CallExpression */: - case 162 /* TaggedTemplateExpression */: - case 156 /* ArrayLiteralExpression */: - case 164 /* ParenthesizedExpression */: - case 157 /* ObjectLiteralExpression */: - case 177 /* ClassExpression */: - case 165 /* FunctionExpression */: - case 65 /* Identifier */: + case 163 /* PropertyAccessExpression */: + case 164 /* ElementAccessExpression */: + case 166 /* NewExpression */: + case 165 /* CallExpression */: + case 230 /* JsxElement */: + case 231 /* JsxSelfClosingElement */: + case 167 /* TaggedTemplateExpression */: + case 161 /* ArrayLiteralExpression */: + case 169 /* ParenthesizedExpression */: + case 162 /* ObjectLiteralExpression */: + case 183 /* ClassExpression */: + case 170 /* FunctionExpression */: + case 66 /* Identifier */: case 9 /* RegularExpressionLiteral */: case 7 /* NumericLiteral */: case 8 /* StringLiteral */: case 10 /* NoSubstitutionTemplateLiteral */: - case 174 /* TemplateExpression */: - case 80 /* FalseKeyword */: - case 89 /* NullKeyword */: - case 93 /* ThisKeyword */: - case 95 /* TrueKeyword */: - case 91 /* SuperKeyword */: + case 180 /* TemplateExpression */: + case 81 /* FalseKeyword */: + case 90 /* NullKeyword */: + case 94 /* ThisKeyword */: + case 96 /* TrueKeyword */: + case 92 /* SuperKeyword */: return true; } } @@ -6429,12 +6664,12 @@ var ts; } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isAssignmentOperator(token) { - return token >= 53 /* FirstAssignment */ && token <= 64 /* LastAssignment */; + return token >= 54 /* FirstAssignment */ && token <= 65 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; function isExpressionWithTypeArgumentsInClassExtendsClause(node) { - return node.kind === 179 /* ExpressionWithTypeArguments */ && - node.parent.token === 79 /* ExtendsKeyword */ && + return node.kind === 185 /* ExpressionWithTypeArguments */ && + node.parent.token === 80 /* ExtendsKeyword */ && isClassLike(node.parent.parent); } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; @@ -6445,10 +6680,10 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 65 /* Identifier */) { + if (node.kind === 66 /* Identifier */) { return true; } - else if (node.kind === 158 /* PropertyAccessExpression */) { + else if (node.kind === 163 /* PropertyAccessExpression */) { return isSupportedExpressionWithTypeArgumentsRest(node.expression); } else { @@ -6456,18 +6691,22 @@ var ts; } } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 128 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 158 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 132 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 163 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function getLocalSymbolForExportDefault(symbol) { - return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 256 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; + return symbol && symbol.valueDeclaration && (symbol.valueDeclaration.flags & 1024 /* Default */) ? symbol.valueDeclaration.localSymbol : undefined; } ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault; function isJavaScript(fileName) { return ts.fileExtensionIs(fileName, ".js"); } ts.isJavaScript = isJavaScript; + function isTsx(fileName) { + return ts.fileExtensionIs(fileName, ".tsx"); + } + ts.isTsx = isTsx; /** * Replace each instance of non-ascii characters by one, two, three, or four escape sequences * representing the UTF-8 encoding of the character, and return the expanded char code list. @@ -6475,7 +6714,6 @@ var ts; function getExpandedCharCodes(input) { var output = []; var length = input.length; - var leadSurrogate = undefined; for (var i = 0; i < length; i++) { var charCode = input.charCodeAt(i); // handel utf8 @@ -6677,17 +6915,17 @@ var ts; // // 0 10 20 30 40 50 60 70 80 90 100 // ------------------------------------------------------------------------------------------------------- - // | / - // | /---- - // T1 | /---- - // | /---- - // | /---- + // | / + // | /---- + // T1 | /---- + // | /---- + // | /---- // ------------------------------------------------------------------------------------------------------- - // | \ - // | \ - // T2 | \ - // | \ - // | \ + // | \ + // | \ + // T2 | \ + // | \ + // | \ // ------------------------------------------------------------------------------------------------------- // // Merging these turns out to not be too difficult. First, determining the new start of the change is trivial @@ -6695,17 +6933,17 @@ var ts; // // 0 10 20 30 40 50 60 70 80 90 100 // ------------------------------------------------------------*------------------------------------------ - // | / - // | /---- - // T1 | /---- - // | /---- - // | /---- + // | / + // | /---- + // T1 | /---- + // | /---- + // | /---- // ----------------------------------------$-------------------$------------------------------------------ - // . | \ - // . | \ - // T2 . | \ - // . | \ - // . | \ + // . | \ + // . | \ + // T2 . | \ + // . | \ + // . | \ // ----------------------------------------------------------------------*-------------------------------- // // (Note the dots represent the newly inferrred start. @@ -6716,22 +6954,22 @@ var ts; // // 0 10 20 30 40 50 60 70 80 90 100 // --------------------------------------------------------------------------------*---------------------- - // | / - // | /---- - // T1 | /---- - // | /---- - // | /---- + // | / + // | /---- + // T1 | /---- + // | /---- + // | /---- // ------------------------------------------------------------$------------------------------------------ - // . | \ - // . | \ - // T2 . | \ - // . | \ - // . | \ + // . | \ + // . | \ + // T2 . | \ + // . | \ + // . | \ // ----------------------------------------------------------------------*-------------------------------- // // In other words (in this case), we're recognizing that the second edit happened after where the first edit // ended with a delta of 20 characters (60 - 40). Thus, if we go back in time to where the first edit started - // that's the same as if we started at char 80 instead of 60. + // that's the same as if we started at char 80 instead of 60. // // As it so happens, the same logic applies if the second edit precedes the first edit. In that case rahter // than pusing the first edit forward to match the second, we'll push the second edit forward to match the @@ -6741,7 +6979,7 @@ var ts; // semantics: { { start: 10, length: 70 }, newLength: 60 } // // The math then works out as follows. - // If we have { oldStart1, oldEnd1, newEnd1 } and { oldStart2, oldEnd2, newEnd2 } then we can compute the + // If we have { oldStart1, oldEnd1, newEnd1 } and { oldStart2, oldEnd2, newEnd2 } then we can compute the // final result like so: // // { @@ -6763,9 +7001,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 130 /* TypeParameter */) { + if (d && d.kind === 134 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 205 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 212 /* InterfaceDeclaration */) { return current; } } @@ -6777,7 +7015,7 @@ var ts; /// var ts; (function (ts) { - var nodeConstructors = new Array(254 /* Count */); + var nodeConstructors = new Array(269 /* Count */); /* @internal */ ts.parseTime = 0; function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); @@ -6822,20 +7060,20 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 128 /* QualifiedName */: + case 132 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 130 /* TypeParameter */: + case 134 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.expression); - case 131 /* Parameter */: - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: - case 227 /* PropertyAssignment */: - case 228 /* ShorthandPropertyAssignment */: - case 201 /* VariableDeclaration */: - case 155 /* BindingElement */: + case 135 /* Parameter */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: + case 242 /* PropertyAssignment */: + case 243 /* ShorthandPropertyAssignment */: + case 208 /* VariableDeclaration */: + case 160 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -6844,24 +7082,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 145 /* FunctionType */: - case 146 /* ConstructorType */: - case 140 /* CallSignature */: - case 141 /* ConstructSignature */: - case 142 /* IndexSignature */: + case 149 /* FunctionType */: + case 150 /* ConstructorType */: + case 144 /* CallSignature */: + case 145 /* ConstructSignature */: + case 146 /* IndexSignature */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 137 /* Constructor */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 165 /* FunctionExpression */: - case 203 /* FunctionDeclaration */: - case 166 /* ArrowFunction */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 141 /* Constructor */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 170 /* FunctionExpression */: + case 210 /* FunctionDeclaration */: + case 171 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -6872,267 +7110,290 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 144 /* TypeReference */: + case 148 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 143 /* TypePredicate */: + case 147 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 147 /* TypeQuery */: + case 151 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 148 /* TypeLiteral */: + case 152 /* TypeLiteral */: return visitNodes(cbNodes, node.members); - case 149 /* ArrayType */: + case 153 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 150 /* TupleType */: + case 154 /* TupleType */: return visitNodes(cbNodes, node.elementTypes); - case 151 /* UnionType */: + case 155 /* UnionType */: + case 156 /* IntersectionType */: return visitNodes(cbNodes, node.types); - case 152 /* ParenthesizedType */: + case 157 /* ParenthesizedType */: return visitNode(cbNode, node.type); - case 153 /* ObjectBindingPattern */: - case 154 /* ArrayBindingPattern */: + case 158 /* ObjectBindingPattern */: + case 159 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 156 /* ArrayLiteralExpression */: + case 161 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 157 /* ObjectLiteralExpression */: + case 162 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 158 /* PropertyAccessExpression */: + case 163 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.dotToken) || visitNode(cbNode, node.name); - case 159 /* ElementAccessExpression */: + case 164 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 160 /* CallExpression */: - case 161 /* NewExpression */: + case 165 /* CallExpression */: + case 166 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 162 /* TaggedTemplateExpression */: + case 167 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 163 /* TypeAssertionExpression */: + case 168 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 164 /* ParenthesizedExpression */: + case 169 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 167 /* DeleteExpression */: + case 172 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 168 /* TypeOfExpression */: + case 173 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 169 /* VoidExpression */: + case 174 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 170 /* PrefixUnaryExpression */: + case 176 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 175 /* YieldExpression */: + case 181 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 171 /* PostfixUnaryExpression */: + case 175 /* AwaitExpression */: + return visitNode(cbNode, node.expression); + case 177 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 172 /* BinaryExpression */: + case 178 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 173 /* ConditionalExpression */: + case 186 /* AsExpression */: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.type); + case 179 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 176 /* SpreadElementExpression */: + case 182 /* SpreadElementExpression */: return visitNode(cbNode, node.expression); - case 182 /* Block */: - case 209 /* ModuleBlock */: + case 189 /* Block */: + case 216 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 230 /* SourceFile */: + case 245 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 183 /* VariableStatement */: + case 190 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 202 /* VariableDeclarationList */: + case 209 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 185 /* ExpressionStatement */: + case 192 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 186 /* IfStatement */: + case 193 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 187 /* DoStatement */: + case 194 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 188 /* WhileStatement */: + case 195 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 189 /* ForStatement */: + case 196 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 190 /* ForInStatement */: + case 197 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 191 /* ForOfStatement */: + case 198 /* ForOfStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 192 /* ContinueStatement */: - case 193 /* BreakStatement */: + case 199 /* ContinueStatement */: + case 200 /* BreakStatement */: return visitNode(cbNode, node.label); - case 194 /* ReturnStatement */: + case 201 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 195 /* WithStatement */: + case 202 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 196 /* SwitchStatement */: + case 203 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 210 /* CaseBlock */: + case 217 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 223 /* CaseClause */: + case 238 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 224 /* DefaultClause */: + case 239 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 197 /* LabeledStatement */: + case 204 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 198 /* ThrowStatement */: + case 205 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 199 /* TryStatement */: + case 206 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 226 /* CatchClause */: + case 241 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 132 /* Decorator */: + case 136 /* Decorator */: return visitNode(cbNode, node.expression); - case 204 /* ClassDeclaration */: - case 177 /* ClassExpression */: + case 211 /* ClassDeclaration */: + case 183 /* ClassExpression */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 205 /* InterfaceDeclaration */: + case 212 /* InterfaceDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.heritageClauses) || visitNodes(cbNodes, node.members); - case 206 /* TypeAliasDeclaration */: + case 213 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 207 /* EnumDeclaration */: + case 214 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 229 /* EnumMember */: + case 244 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 211 /* ImportEqualsDeclaration */: + case 218 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 212 /* ImportDeclaration */: + case 219 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 213 /* ImportClause */: + case 220 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 214 /* NamespaceImport */: + case 221 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 215 /* NamedImports */: - case 219 /* NamedExports */: + case 222 /* NamedImports */: + case 226 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 218 /* ExportDeclaration */: + case 225 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 216 /* ImportSpecifier */: - case 220 /* ExportSpecifier */: + case 223 /* ImportSpecifier */: + case 227 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 217 /* ExportAssignment */: + case 224 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 174 /* TemplateExpression */: + case 180 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 180 /* TemplateSpan */: + case 187 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 129 /* ComputedPropertyName */: + case 133 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 225 /* HeritageClause */: + case 240 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 179 /* ExpressionWithTypeArguments */: + case 185 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 222 /* ExternalModuleReference */: + case 229 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 221 /* MissingDeclaration */: + case 228 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 231 /* JSDocTypeExpression */: + case 230 /* JsxElement */: + return visitNode(cbNode, node.openingElement) || + visitNodes(cbNodes, node.children) || + visitNode(cbNode, node.closingElement); + case 231 /* JsxSelfClosingElement */: + case 232 /* JsxOpeningElement */: + return visitNode(cbNode, node.tagName) || + visitNodes(cbNodes, node.attributes); + case 235 /* JsxAttribute */: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 236 /* JsxSpreadAttribute */: + return visitNode(cbNode, node.expression); + case 237 /* JsxExpression */: + return visitNode(cbNode, node.expression); + case 234 /* JsxClosingElement */: + return visitNode(cbNode, node.tagName); + case 246 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 235 /* JSDocUnionType */: + case 250 /* JSDocUnionType */: return visitNodes(cbNodes, node.types); - case 236 /* JSDocTupleType */: + case 251 /* JSDocTupleType */: return visitNodes(cbNodes, node.types); - case 234 /* JSDocArrayType */: + case 249 /* JSDocArrayType */: return visitNode(cbNode, node.elementType); - case 238 /* JSDocNonNullableType */: + case 253 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 237 /* JSDocNullableType */: + case 252 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 239 /* JSDocRecordType */: + case 254 /* JSDocRecordType */: return visitNodes(cbNodes, node.members); - case 241 /* JSDocTypeReference */: + case 256 /* JSDocTypeReference */: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 242 /* JSDocOptionalType */: + case 257 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 243 /* JSDocFunctionType */: + case 258 /* JSDocFunctionType */: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 244 /* JSDocVariadicType */: + case 259 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 245 /* JSDocConstructorType */: + case 260 /* JSDocConstructorType */: return visitNode(cbNode, node.type); - case 246 /* JSDocThisType */: + case 261 /* JSDocThisType */: return visitNode(cbNode, node.type); - case 240 /* JSDocRecordMember */: + case 255 /* JSDocRecordMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 247 /* JSDocComment */: + case 262 /* JSDocComment */: return visitNodes(cbNodes, node.tags); - case 249 /* JSDocParameterTag */: + case 264 /* JSDocParameterTag */: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 250 /* JSDocReturnTag */: + case 265 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 251 /* JSDocTypeTag */: + case 266 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 252 /* JSDocTemplateTag */: + case 267 /* JSDocTemplateTag */: return visitNodes(cbNodes, node.typeParameters); } } @@ -7177,7 +7438,7 @@ var ts; // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. var scanner = ts.createScanner(2 /* Latest */, true); - var disallowInAndDecoratorContext = 2 /* DisallowIn */ | 16 /* Decorator */; + var disallowInAndDecoratorContext = 1 /* DisallowIn */ | 4 /* Decorator */; var sourceFile; var parseDiagnostics; var syntaxCursor; @@ -7277,12 +7538,13 @@ var ts; identifiers = {}; identifierCount = 0; nodeCount = 0; - contextFlags = ts.isJavaScript(fileName) ? 64 /* JavaScriptFile */ : 0 /* None */; + contextFlags = ts.isJavaScript(fileName) ? 32 /* JavaScriptFile */ : 0 /* None */; parseErrorBeforeNextFinishedNode = false; // Initialize and prime the scanner before parsing the source elements. scanner.setText(sourceText); scanner.setOnError(scanError); scanner.setScriptTarget(languageVersion); + scanner.setLanguageVariant(ts.isTsx(fileName) ? 1 /* JSX */ : 0 /* Standard */); } function clearState() { // Clear out the text the scanner is pointing at, so it doesn't keep anything alive unnecessarily. @@ -7311,7 +7573,7 @@ var ts; if (setParentNodes) { fixupParentReferences(sourceFile); } - // If this is a javascript file, proactively see if we can get JSDoc comments for + // If this is a javascript file, proactively see if we can get JSDoc comments for // relevant nodes in the file. We'll use these to provide typing informaion if they're // available. if (ts.isJavaScript(fileName)) { @@ -7326,9 +7588,9 @@ var ts; // Add additional cases as necessary depending on how we see JSDoc comments used // in the wild. switch (node.kind) { - case 183 /* VariableStatement */: - case 203 /* FunctionDeclaration */: - case 131 /* Parameter */: + case 190 /* VariableStatement */: + case 210 /* FunctionDeclaration */: + case 135 /* Parameter */: addJSDocComment(node); } forEachChild(node, visit); @@ -7369,14 +7631,15 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion) { - var sourceFile = createNode(230 /* SourceFile */, 0); + var sourceFile = createNode(245 /* SourceFile */, 0); sourceFile.pos = 0; sourceFile.end = sourceText.length; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; sourceFile.languageVersion = languageVersion; sourceFile.fileName = ts.normalizePath(fileName); - sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 2048 /* DeclarationFile */ : 0; + sourceFile.flags = ts.fileExtensionIs(sourceFile.fileName, ".d.ts") ? 8192 /* DeclarationFile */ : 0; + sourceFile.languageVariant = ts.isTsx(sourceFile.fileName) ? 1 /* JSX */ : 0 /* Standard */; return sourceFile; } function setContextFlag(val, flag) { @@ -7388,89 +7651,96 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 2 /* DisallowIn */); + setContextFlag(val, 1 /* DisallowIn */); } function setYieldContext(val) { - setContextFlag(val, 4 /* Yield */); - } - function setGeneratorParameterContext(val) { - setContextFlag(val, 8 /* GeneratorParameter */); + setContextFlag(val, 2 /* Yield */); } function setDecoratorContext(val) { - setContextFlag(val, 16 /* Decorator */); + setContextFlag(val, 4 /* Decorator */); } - function doOutsideOfContext(flags, func) { - var currentContextFlags = contextFlags & flags; - if (currentContextFlags) { - setContextFlag(false, currentContextFlags); + function setAwaitContext(val) { + setContextFlag(val, 8 /* Await */); + } + function doOutsideOfContext(context, func) { + // contextFlagsToClear will contain only the context flags that are + // currently set that we need to temporarily clear + // We don't just blindly reset to the previous flags to ensure + // that we do not mutate cached flags for the incremental + // parser (ThisNodeHasError, ThisNodeOrAnySubNodesHasError, and + // HasAggregatedChildData). + var contextFlagsToClear = context & contextFlags; + if (contextFlagsToClear) { + // clear the requested context flags + setContextFlag(false, contextFlagsToClear); var result = func(); - setContextFlag(true, currentContextFlags); + // restore the context flags we just cleared + setContextFlag(true, contextFlagsToClear); return result; } // no need to do anything special as we are not in any of the requested contexts return func(); } - function allowInAnd(func) { - if (contextFlags & 2 /* DisallowIn */) { - setDisallowInContext(false); + function doInsideOfContext(context, func) { + // contextFlagsToSet will contain only the context flags that + // are not currently set that we need to temporarily enable. + // We don't just blindly reset to the previous flags to ensure + // that we do not mutate cached flags for the incremental + // parser (ThisNodeHasError, ThisNodeOrAnySubNodesHasError, and + // HasAggregatedChildData). + var contextFlagsToSet = context & ~contextFlags; + if (contextFlagsToSet) { + // set the requested context flags + setContextFlag(true, contextFlagsToSet); var result = func(); - setDisallowInContext(true); + // reset the context flags we just set + setContextFlag(false, contextFlagsToSet); return result; } - // no need to do anything special if 'in' is already allowed. + // no need to do anything special as we are already in all of the requested contexts return func(); } + function allowInAnd(func) { + return doOutsideOfContext(1 /* DisallowIn */, func); + } function disallowInAnd(func) { - if (contextFlags & 2 /* DisallowIn */) { - // no need to do anything special if 'in' is already disallowed. - return func(); - } - setDisallowInContext(true); - var result = func(); - setDisallowInContext(false); - return result; + return doInsideOfContext(1 /* DisallowIn */, func); } function doInYieldContext(func) { - if (contextFlags & 4 /* Yield */) { - // no need to do anything special if we're already in the [Yield] context. - return func(); - } - setYieldContext(true); - var result = func(); - setYieldContext(false); - return result; + return doInsideOfContext(2 /* Yield */, func); } function doOutsideOfYieldContext(func) { - if (contextFlags & 4 /* Yield */) { - setYieldContext(false); - var result = func(); - setYieldContext(true); - return result; - } - // no need to do anything special if we're not in the [Yield] context. - return func(); + return doOutsideOfContext(2 /* Yield */, func); } function doInDecoratorContext(func) { - if (contextFlags & 16 /* Decorator */) { - // no need to do anything special if we're already in the [Decorator] context. - return func(); - } - setDecoratorContext(true); - var result = func(); - setDecoratorContext(false); - return result; + return doInsideOfContext(4 /* Decorator */, func); + } + function doInAwaitContext(func) { + return doInsideOfContext(8 /* Await */, func); + } + function doOutsideOfAwaitContext(func) { + return doOutsideOfContext(8 /* Await */, func); + } + function doInYieldAndAwaitContext(func) { + return doInsideOfContext(2 /* Yield */ | 8 /* Await */, func); + } + function doOutsideOfYieldAndAwaitContext(func) { + return doOutsideOfContext(2 /* Yield */ | 8 /* Await */, func); + } + function inContext(flags) { + return (contextFlags & flags) !== 0; } function inYieldContext() { - return (contextFlags & 4 /* Yield */) !== 0; - } - function inGeneratorParameterContext() { - return (contextFlags & 8 /* GeneratorParameter */) !== 0; + return inContext(2 /* Yield */); } function inDisallowInContext() { - return (contextFlags & 2 /* DisallowIn */) !== 0; + return inContext(1 /* DisallowIn */); } function inDecoratorContext() { - return (contextFlags & 16 /* Decorator */) !== 0; + return inContext(4 /* Decorator */); + } + function inAwaitContext() { + return inContext(8 /* Await */); } function parseErrorAtCurrentToken(message, arg0) { var start = scanner.getTokenPos(); @@ -7512,6 +7782,9 @@ var ts; function reScanTemplateToken() { return token = scanner.reScanTemplateToken(); } + function scanJsxIdentifier() { + return token = scanner.scanJsxIdentifier(); + } function speculationHelper(callback, isLookAhead) { // Keep track of the state we'll need to rollback to if lookahead fails (or if the // caller asked us to always reset our state). @@ -7554,15 +7827,20 @@ var ts; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token === 65 /* Identifier */) { + if (token === 66 /* Identifier */) { return true; } // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is // considered a keyword and is not an identifier. - if (token === 110 /* YieldKeyword */ && inYieldContext()) { + if (token === 111 /* YieldKeyword */ && inYieldContext()) { return false; } - return token > 101 /* LastReservedWord */; + // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is + // considered a keyword and is not an identifier. + if (token === 116 /* AwaitKeyword */ && inAwaitContext()) { + return false; + } + return token > 102 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage) { if (token === kind) { @@ -7640,7 +7918,7 @@ var ts; // flag so that we don't mark any subsequent nodes. if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.parserContextFlags |= 32 /* ThisNodeHasError */; + node.parserContextFlags |= 16 /* ThisNodeHasError */; } return node; } @@ -7665,16 +7943,16 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(65 /* Identifier */); + var node = createNode(66 /* Identifier */); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token !== 65 /* Identifier */) { + if (token !== 66 /* Identifier */) { node.originalKeywordKind = token; } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(65 /* Identifier */, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(66 /* Identifier */, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -7706,27 +7984,15 @@ var ts; return token === 8 /* StringLiteral */ || token === 7 /* NumericLiteral */ || isIdentifierOrKeyword(); } function parseComputedPropertyName() { - // PropertyName[Yield,GeneratorParameter] : - // LiteralPropertyName - // [+GeneratorParameter] ComputedPropertyName - // [~GeneratorParameter] ComputedPropertyName[?Yield] - // - // ComputedPropertyName[Yield] : - // [ AssignmentExpression[In, ?Yield] ] - // - var node = createNode(129 /* ComputedPropertyName */); + // PropertyName [Yield]: + // LiteralPropertyName + // ComputedPropertyName[?Yield] + var node = createNode(133 /* ComputedPropertyName */); parseExpected(18 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker // will error if it sees a comma expression. - var yieldContext = inYieldContext(); - if (inGeneratorParameterContext()) { - setYieldContext(false); - } node.expression = allowInAnd(parseExpression); - if (inGeneratorParameterContext()) { - setYieldContext(yieldContext); - } parseExpected(19 /* CloseBracketToken */); return finishNode(node); } @@ -7734,18 +8000,18 @@ var ts; return token === t && tryParse(nextTokenCanFollowModifier); } function nextTokenCanFollowModifier() { - if (token === 70 /* ConstKeyword */) { + if (token === 71 /* ConstKeyword */) { // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 77 /* EnumKeyword */; + return nextToken() === 78 /* EnumKeyword */; } - if (token === 78 /* ExportKeyword */) { + if (token === 79 /* ExportKeyword */) { nextToken(); - if (token === 73 /* DefaultKeyword */) { + if (token === 74 /* DefaultKeyword */) { return lookAhead(nextTokenIsClassOrFunction); } - return token !== 35 /* AsteriskToken */ && token !== 14 /* OpenBraceToken */ && canFollowModifier(); + return token !== 36 /* AsteriskToken */ && token !== 14 /* OpenBraceToken */ && canFollowModifier(); } - if (token === 73 /* DefaultKeyword */) { + if (token === 74 /* DefaultKeyword */) { return nextTokenIsClassOrFunction(); } nextToken(); @@ -7757,12 +8023,12 @@ var ts; function canFollowModifier() { return token === 18 /* OpenBracketToken */ || token === 14 /* OpenBraceToken */ - || token === 35 /* AsteriskToken */ + || token === 36 /* AsteriskToken */ || isLiteralPropertyName(); } function nextTokenIsClassOrFunction() { nextToken(); - return token === 69 /* ClassKeyword */ || token === 83 /* FunctionKeyword */; + return token === 70 /* ClassKeyword */ || token === 84 /* FunctionKeyword */; } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -7782,7 +8048,7 @@ var ts; // outer module. We just want to consume and move on. return !(token === 22 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token === 67 /* CaseKeyword */ || token === 73 /* DefaultKeyword */; + return token === 68 /* CaseKeyword */ || token === 74 /* DefaultKeyword */; case 4 /* TypeMembers */: return isStartOfTypeMember(); case 5 /* ClassMembers */: @@ -7796,7 +8062,7 @@ var ts; // which would be a candidate for improved error reporting. return token === 18 /* OpenBracketToken */ || isLiteralPropertyName(); case 12 /* ObjectLiteralMembers */: - return token === 18 /* OpenBracketToken */ || token === 35 /* AsteriskToken */ || isLiteralPropertyName(); + return token === 18 /* OpenBracketToken */ || token === 36 /* AsteriskToken */ || isLiteralPropertyName(); case 9 /* ObjectBindingElements */: return isLiteralPropertyName(); case 7 /* HeritageClauseElement */: @@ -7818,25 +8084,29 @@ var ts; return isIdentifierOrPattern(); case 10 /* ArrayBindingElements */: return token === 23 /* CommaToken */ || token === 21 /* DotDotDotToken */ || isIdentifierOrPattern(); - case 15 /* TypeParameters */: + case 17 /* TypeParameters */: return isIdentifier(); case 11 /* ArgumentExpressions */: - case 13 /* ArrayLiteralMembers */: + case 15 /* ArrayLiteralMembers */: return token === 23 /* CommaToken */ || token === 21 /* DotDotDotToken */ || isStartOfExpression(); - case 14 /* Parameters */: + case 16 /* Parameters */: return isStartOfParameter(); - case 16 /* TypeArguments */: - case 17 /* TupleElementTypes */: + case 18 /* TypeArguments */: + case 19 /* TupleElementTypes */: return token === 23 /* CommaToken */ || isStartOfType(); - case 18 /* HeritageClauses */: + case 20 /* HeritageClauses */: return isHeritageClause(); - case 19 /* ImportOrExportSpecifiers */: + case 21 /* ImportOrExportSpecifiers */: return isIdentifierOrKeyword(); - case 20 /* JSDocFunctionParameters */: - case 21 /* JSDocTypeArguments */: - case 23 /* JSDocTupleTypes */: + case 13 /* JsxAttributes */: + return isIdentifierOrKeyword() || token === 14 /* OpenBraceToken */; + case 14 /* JsxChildren */: + return true; + case 22 /* JSDocFunctionParameters */: + case 23 /* JSDocTypeArguments */: + case 25 /* JSDocTupleTypes */: return JSDocParser.isJSDocType(); - case 22 /* JSDocRecordMembers */: + case 24 /* JSDocRecordMembers */: return isSimplePropertyName(); } ts.Debug.fail("Non-exhaustive case in 'isListElement'."); @@ -7847,12 +8117,12 @@ var ts; // if we see "extends {}" then only treat the {} as what we're extending (and not // the class body) if we have: // - // extends {} { + // extends {} { // extends {}, // extends {} extends // extends {} implements var next = nextToken(); - return next === 23 /* CommaToken */ || next === 14 /* OpenBraceToken */ || next === 79 /* ExtendsKeyword */ || next === 102 /* ImplementsKeyword */; + return next === 23 /* CommaToken */ || next === 14 /* OpenBraceToken */ || next === 80 /* ExtendsKeyword */ || next === 103 /* ImplementsKeyword */; } return true; } @@ -7860,9 +8130,13 @@ var ts; nextToken(); return isIdentifier(); } + function nextTokenIsIdentifierOrKeyword() { + nextToken(); + return isIdentifierOrKeyword(); + } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token === 102 /* ImplementsKeyword */ || - token === 79 /* ExtendsKeyword */) { + if (token === 103 /* ImplementsKeyword */ || + token === 80 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -7885,39 +8159,43 @@ var ts; case 6 /* EnumMembers */: case 12 /* ObjectLiteralMembers */: case 9 /* ObjectBindingElements */: - case 19 /* ImportOrExportSpecifiers */: + case 21 /* ImportOrExportSpecifiers */: return token === 15 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token === 15 /* CloseBraceToken */ || token === 67 /* CaseKeyword */ || token === 73 /* DefaultKeyword */; + return token === 15 /* CloseBraceToken */ || token === 68 /* CaseKeyword */ || token === 74 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token === 14 /* OpenBraceToken */ || token === 79 /* ExtendsKeyword */ || token === 102 /* ImplementsKeyword */; + return token === 14 /* OpenBraceToken */ || token === 80 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); - case 15 /* TypeParameters */: + case 17 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token === 25 /* GreaterThanToken */ || token === 16 /* OpenParenToken */ || token === 14 /* OpenBraceToken */ || token === 79 /* ExtendsKeyword */ || token === 102 /* ImplementsKeyword */; + return token === 26 /* GreaterThanToken */ || token === 16 /* OpenParenToken */ || token === 14 /* OpenBraceToken */ || token === 80 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery return token === 17 /* CloseParenToken */ || token === 22 /* SemicolonToken */; - case 13 /* ArrayLiteralMembers */: - case 17 /* TupleElementTypes */: + case 15 /* ArrayLiteralMembers */: + case 19 /* TupleElementTypes */: case 10 /* ArrayBindingElements */: return token === 19 /* CloseBracketToken */; - case 14 /* Parameters */: + case 16 /* Parameters */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery return token === 17 /* CloseParenToken */ || token === 19 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; - case 16 /* TypeArguments */: + case 18 /* TypeArguments */: // Tokens other than '>' are here for better error recovery - return token === 25 /* GreaterThanToken */ || token === 16 /* OpenParenToken */; - case 18 /* HeritageClauses */: + return token === 26 /* GreaterThanToken */ || token === 16 /* OpenParenToken */; + case 20 /* HeritageClauses */: return token === 14 /* OpenBraceToken */ || token === 15 /* CloseBraceToken */; - case 20 /* JSDocFunctionParameters */: - return token === 17 /* CloseParenToken */ || token === 51 /* ColonToken */ || token === 15 /* CloseBraceToken */; - case 21 /* JSDocTypeArguments */: - return token === 25 /* GreaterThanToken */ || token === 15 /* CloseBraceToken */; - case 23 /* JSDocTupleTypes */: + case 13 /* JsxAttributes */: + return token === 26 /* GreaterThanToken */ || token === 37 /* SlashToken */; + case 14 /* JsxChildren */: + return token === 24 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + case 22 /* JSDocFunctionParameters */: + return token === 17 /* CloseParenToken */ || token === 52 /* ColonToken */ || token === 15 /* CloseBraceToken */; + case 23 /* JSDocTypeArguments */: + return token === 26 /* GreaterThanToken */ || token === 15 /* CloseBraceToken */; + case 25 /* JSDocTupleTypes */: return token === 19 /* CloseBracketToken */ || token === 15 /* CloseBraceToken */; - case 22 /* JSDocRecordMembers */: + case 24 /* JSDocRecordMembers */: return token === 15 /* CloseBraceToken */; } } @@ -7936,7 +8214,7 @@ var ts; // For better error recovery, if we see an '=>' then we just stop immediately. We've got an // arrow function here and it's going to be very unlikely that we'll resynchronize and get // another variable declaration. - if (token === 32 /* EqualsGreaterThanToken */) { + if (token === 33 /* EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -7944,7 +8222,7 @@ var ts; } // True if positioned at element or terminator of the current list or any enclosing list function isInSomeParsingContext() { - for (var kind = 0; kind < 24 /* Count */; kind++) { + for (var kind = 0; kind < 26 /* Count */; kind++) { if (parsingContext & (1 << kind)) { if (isListElement(kind, true) || isListTerminator(kind)) { return true; @@ -8020,7 +8298,7 @@ var ts; // differently depending on what mode it is in. // // This also applies to all our other context flags as well. - var nodeContextFlags = node.parserContextFlags & 62 /* ParserGeneratedFlags */; + var nodeContextFlags = node.parserContextFlags & 31 /* ParserGeneratedFlags */; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -8053,22 +8331,22 @@ var ts; return isReusableTypeMember(node); case 8 /* VariableDeclarations */: return isReusableVariableDeclaration(node); - case 14 /* Parameters */: + case 16 /* Parameters */: return isReusableParameter(node); // Any other lists we do not care about reusing nodes in. But feel free to add if // you can do so safely. Danger areas involve nodes that may involve speculative // parsing. If speculative parsing is involved with the node, then the range the // parser reached while looking ahead might be in the edited range (see the example // in canReuseVariableDeclaratorNode for a good case of this). - case 18 /* HeritageClauses */: + case 20 /* HeritageClauses */: // This would probably be safe to reuse. There is no speculative parsing with // heritage clauses. - case 15 /* TypeParameters */: + case 17 /* TypeParameters */: // This would probably be safe to reuse. There is no speculative parsing with // type parameters. Note that that's because type *parameters* only occur in // unambiguous *type* contexts. While type *arguments* occur in very ambiguous // *expression* contexts. - case 17 /* TupleElementTypes */: + case 19 /* TupleElementTypes */: // This would probably be safe to reuse. There is no speculative parsing with // tuple types. // Technically, type argument list types are probably safe to reuse. While @@ -8076,7 +8354,7 @@ var ts; // produced from speculative parsing a < as a type argument list), we only have // the types because speculative parsing succeeded. Thus, the lookahead never // went past the end of the list and rewound. - case 16 /* TypeArguments */: + case 18 /* TypeArguments */: // Note: these are almost certainly not safe to ever reuse. Expressions commonly // need a large amount of lookahead, and we should not reuse them as they may // have actually intersected the edit. @@ -8090,26 +8368,30 @@ var ts; // name list, and there can be left hand side expressions (which can have type // arguments.) case 7 /* HeritageClauseElement */: + // Perhaps safe to reuse, but it's unlikely we'd see more than a dozen attributes + // on any given element. Same for children. + case 13 /* JsxAttributes */: + case 14 /* JsxChildren */: } return false; } function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 137 /* Constructor */: - case 142 /* IndexSignature */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 134 /* PropertyDeclaration */: - case 181 /* SemicolonClassElement */: + case 141 /* Constructor */: + case 146 /* IndexSignature */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 138 /* PropertyDeclaration */: + case 188 /* SemicolonClassElement */: return true; - case 136 /* MethodDeclaration */: + case 140 /* MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal // may have a method calls "constructor(...)" and we must reparse that // into an actual .ConstructorDeclaration. var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 65 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 114 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 66 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 118 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -8118,8 +8400,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 223 /* CaseClause */: - case 224 /* DefaultClause */: + case 238 /* CaseClause */: + case 239 /* DefaultClause */: return true; } } @@ -8128,58 +8410,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 203 /* FunctionDeclaration */: - case 183 /* VariableStatement */: - case 182 /* Block */: - case 186 /* IfStatement */: - case 185 /* ExpressionStatement */: - case 198 /* ThrowStatement */: - case 194 /* ReturnStatement */: - case 196 /* SwitchStatement */: - case 193 /* BreakStatement */: - case 192 /* ContinueStatement */: - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: - case 189 /* ForStatement */: - case 188 /* WhileStatement */: - case 195 /* WithStatement */: - case 184 /* EmptyStatement */: - case 199 /* TryStatement */: - case 197 /* LabeledStatement */: - case 187 /* DoStatement */: - case 200 /* DebuggerStatement */: - case 212 /* ImportDeclaration */: - case 211 /* ImportEqualsDeclaration */: - case 218 /* ExportDeclaration */: - case 217 /* ExportAssignment */: - case 208 /* ModuleDeclaration */: - case 204 /* ClassDeclaration */: - case 205 /* InterfaceDeclaration */: - case 207 /* EnumDeclaration */: - case 206 /* TypeAliasDeclaration */: + case 210 /* FunctionDeclaration */: + case 190 /* VariableStatement */: + case 189 /* Block */: + case 193 /* IfStatement */: + case 192 /* ExpressionStatement */: + case 205 /* ThrowStatement */: + case 201 /* ReturnStatement */: + case 203 /* SwitchStatement */: + case 200 /* BreakStatement */: + case 199 /* ContinueStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: + case 196 /* ForStatement */: + case 195 /* WhileStatement */: + case 202 /* WithStatement */: + case 191 /* EmptyStatement */: + case 206 /* TryStatement */: + case 204 /* LabeledStatement */: + case 194 /* DoStatement */: + case 207 /* DebuggerStatement */: + case 219 /* ImportDeclaration */: + case 218 /* ImportEqualsDeclaration */: + case 225 /* ExportDeclaration */: + case 224 /* ExportAssignment */: + case 215 /* ModuleDeclaration */: + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: + case 214 /* EnumDeclaration */: + case 213 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 229 /* EnumMember */; + return node.kind === 244 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 141 /* ConstructSignature */: - case 135 /* MethodSignature */: - case 142 /* IndexSignature */: - case 133 /* PropertySignature */: - case 140 /* CallSignature */: + case 145 /* ConstructSignature */: + case 139 /* MethodSignature */: + case 146 /* IndexSignature */: + case 137 /* PropertySignature */: + case 144 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 201 /* VariableDeclaration */) { + if (node.kind !== 208 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -8200,7 +8482,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 131 /* Parameter */) { + if (node.kind !== 135 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -8231,17 +8513,19 @@ var ts; case 10 /* ArrayBindingElements */: return ts.Diagnostics.Array_element_destructuring_pattern_expected; case 11 /* ArgumentExpressions */: return ts.Diagnostics.Argument_expression_expected; case 12 /* ObjectLiteralMembers */: return ts.Diagnostics.Property_assignment_expected; - case 13 /* ArrayLiteralMembers */: return ts.Diagnostics.Expression_or_comma_expected; - case 14 /* Parameters */: return ts.Diagnostics.Parameter_declaration_expected; - case 15 /* TypeParameters */: return ts.Diagnostics.Type_parameter_declaration_expected; - case 16 /* TypeArguments */: return ts.Diagnostics.Type_argument_expected; - case 17 /* TupleElementTypes */: return ts.Diagnostics.Type_expected; - case 18 /* HeritageClauses */: return ts.Diagnostics.Unexpected_token_expected; - case 19 /* ImportOrExportSpecifiers */: return ts.Diagnostics.Identifier_expected; - case 20 /* JSDocFunctionParameters */: return ts.Diagnostics.Parameter_declaration_expected; - case 21 /* JSDocTypeArguments */: return ts.Diagnostics.Type_argument_expected; - case 23 /* JSDocTupleTypes */: return ts.Diagnostics.Type_expected; - case 22 /* JSDocRecordMembers */: return ts.Diagnostics.Property_assignment_expected; + case 15 /* ArrayLiteralMembers */: return ts.Diagnostics.Expression_or_comma_expected; + case 16 /* Parameters */: return ts.Diagnostics.Parameter_declaration_expected; + case 17 /* TypeParameters */: return ts.Diagnostics.Type_parameter_declaration_expected; + case 18 /* TypeArguments */: return ts.Diagnostics.Type_argument_expected; + case 19 /* TupleElementTypes */: return ts.Diagnostics.Type_expected; + case 20 /* HeritageClauses */: return ts.Diagnostics.Unexpected_token_expected; + case 21 /* ImportOrExportSpecifiers */: return ts.Diagnostics.Identifier_expected; + case 13 /* JsxAttributes */: return ts.Diagnostics.Identifier_expected; + case 14 /* JsxChildren */: return ts.Diagnostics.Identifier_expected; + case 22 /* JSDocFunctionParameters */: return ts.Diagnostics.Parameter_declaration_expected; + case 23 /* JSDocTypeArguments */: return ts.Diagnostics.Type_argument_expected; + case 25 /* JSDocTupleTypes */: return ts.Diagnostics.Type_expected; + case 24 /* JSDocRecordMembers */: return ts.Diagnostics.Property_assignment_expected; } } ; @@ -8315,7 +8599,7 @@ var ts; function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); while (parseOptional(20 /* DotToken */)) { - var node = createNode(128 /* QualifiedName */, entity.pos); + var node = createNode(132 /* QualifiedName */, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -8348,13 +8632,13 @@ var ts; // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(65 /* Identifier */, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(66 /* Identifier */, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(174 /* TemplateExpression */); + var template = createNode(180 /* TemplateExpression */); template.head = parseLiteralNode(); ts.Debug.assert(template.head.kind === 11 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = []; @@ -8367,7 +8651,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(180 /* TemplateSpan */); + var span = createNode(187 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token === 15 /* CloseBraceToken */) { @@ -8402,37 +8686,37 @@ var ts; if (node.kind === 7 /* NumericLiteral */ && sourceText.charCodeAt(tokenPos) === 48 /* _0 */ && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { - node.flags |= 16384 /* OctalLiteral */; + node.flags |= 65536 /* OctalLiteral */; } return node; } // TYPES function parseTypeReferenceOrTypePredicate() { var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - if (typeName.kind === 65 /* Identifier */ && token === 117 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (typeName.kind === 66 /* Identifier */ && token === 121 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var node_1 = createNode(143 /* TypePredicate */, typeName.pos); + var node_1 = createNode(147 /* TypePredicate */, typeName.pos); node_1.parameterName = typeName; node_1.type = parseType(); return finishNode(node_1); } - var node = createNode(144 /* TypeReference */, typeName.pos); + var node = createNode(148 /* TypeReference */, typeName.pos); node.typeName = typeName; if (!scanner.hasPrecedingLineBreak() && token === 24 /* LessThanToken */) { - node.typeArguments = parseBracketedList(16 /* TypeArguments */, parseType, 24 /* LessThanToken */, 25 /* GreaterThanToken */); + node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 24 /* LessThanToken */, 26 /* GreaterThanToken */); } return finishNode(node); } function parseTypeQuery() { - var node = createNode(147 /* TypeQuery */); - parseExpected(97 /* TypeOfKeyword */); + var node = createNode(151 /* TypeQuery */); + parseExpected(98 /* TypeOfKeyword */); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(130 /* TypeParameter */); + var node = createNode(134 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(79 /* ExtendsKeyword */)) { + if (parseOptional(80 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the // user writes a constraint that is an expression and not an actual type, then parse // it out as an expression (so we can recover well), but report that a type is needed @@ -8455,11 +8739,11 @@ var ts; } function parseTypeParameters() { if (token === 24 /* LessThanToken */) { - return parseBracketedList(15 /* TypeParameters */, parseTypeParameter, 24 /* LessThanToken */, 25 /* GreaterThanToken */); + return parseBracketedList(17 /* TypeParameters */, parseTypeParameter, 24 /* LessThanToken */, 26 /* GreaterThanToken */); } } function parseParameterType() { - if (parseOptional(51 /* ColonToken */)) { + if (parseOptional(52 /* ColonToken */)) { return token === 8 /* StringLiteral */ ? parseLiteralNode(true) : parseType(); @@ -8467,7 +8751,7 @@ var ts; return undefined; } function isStartOfParameter() { - return token === 21 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifier(token) || token === 52 /* AtToken */; + return token === 21 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifier(token) || token === 53 /* AtToken */; } function setModifiers(node, modifiers) { if (modifiers) { @@ -8476,14 +8760,13 @@ var ts; } } function parseParameter() { - var node = createNode(131 /* Parameter */); + var node = createNode(135 /* Parameter */); node.decorators = parseDecorators(); setModifiers(node, parseModifiers()); node.dotDotDotToken = parseOptionalToken(21 /* DotDotDotToken */); - // SingleNameBinding[Yield,GeneratorParameter] : See 13.2.3 - // [+GeneratorParameter]BindingIdentifier[Yield]Initializer[In]opt - // [~GeneratorParameter]BindingIdentifier[?Yield]Initializer[In, ?Yield]opt - node.name = inGeneratorParameterContext() ? doInYieldContext(parseIdentifierOrPattern) : parseIdentifierOrPattern(); + // FormalParameter [Yield,Await]: + // BindingElement[?Yield,?Await] + node.name = parseIdentifierOrPattern(); if (ts.getFullWidth(node.name) === 0 && node.flags === 0 && ts.isModifier(token)) { // in cases like // 'use strict' @@ -8495,9 +8778,9 @@ var ts; // to avoid this we'll advance cursor to the next token. nextToken(); } - node.questionToken = parseOptionalToken(50 /* QuestionToken */); + node.questionToken = parseOptionalToken(51 /* QuestionToken */); node.type = parseParameterType(); - node.initializer = inGeneratorParameterContext() ? doOutsideOfYieldContext(parseParameterInitializer) : parseParameterInitializer(); + node.initializer = parseBindingElementInitializer(true); // Do not check for initializers in an ambient context for parameters. This is not // a grammar error because the grammar allows arbitrary call signatures in // an ambient context. @@ -8508,13 +8791,16 @@ var ts; // ambient contexts. return finishNode(node); } + function parseBindingElementInitializer(inParameter) { + return inParameter ? parseParameterInitializer() : parseNonParameterInitializer(); + } function parseParameterInitializer() { return parseInitializer(true); } - function fillSignature(returnToken, yieldAndGeneratorParameterContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 32 /* EqualsGreaterThanToken */; + function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { + var returnTokenRequired = returnToken === 33 /* EqualsGreaterThanToken */; signature.typeParameters = parseTypeParameters(); - signature.parameters = parseParameterList(yieldAndGeneratorParameterContext, requireCompleteParameterList); + signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { parseExpected(returnToken); signature.type = parseType(); @@ -8523,33 +8809,28 @@ var ts; signature.type = parseType(); } } - // Note: after careful analysis of the grammar, it does not appear to be possible to - // have 'Yield' And 'GeneratorParameter' not in sync. i.e. any production calling - // this FormalParameters production either always sets both to true, or always sets - // both to false. As such we only have a single parameter to represent both. - function parseParameterList(yieldAndGeneratorParameterContext, requireCompleteParameterList) { - // FormalParameters[Yield,GeneratorParameter] : - // ... + function parseParameterList(yieldContext, awaitContext, requireCompleteParameterList) { + // FormalParameters [Yield,Await]: (modified) + // [empty] + // FormalParameterList[?Yield,Await] // - // FormalParameter[Yield,GeneratorParameter] : - // BindingElement[?Yield, ?GeneratorParameter] + // FormalParameter[Yield,Await]: (modified) + // BindingElement[?Yield,Await] // - // BindingElement[Yield, GeneratorParameter ] : See 13.2.3 - // SingleNameBinding[?Yield, ?GeneratorParameter] - // [+GeneratorParameter]BindingPattern[?Yield, GeneratorParameter]Initializer[In]opt - // [~GeneratorParameter]BindingPattern[?Yield]Initializer[In, ?Yield]opt + // BindingElement [Yield,Await]: (modified) + // SingleNameBinding[?Yield,?Await] + // BindingPattern[?Yield,?Await]Initializer [In, ?Yield,?Await] opt // - // SingleNameBinding[Yield, GeneratorParameter] : See 13.2.3 - // [+GeneratorParameter]BindingIdentifier[Yield]Initializer[In]opt - // [~GeneratorParameter]BindingIdentifier[?Yield]Initializer[In, ?Yield]opt + // SingleNameBinding [Yield,Await]: + // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt if (parseExpected(16 /* OpenParenToken */)) { var savedYieldContext = inYieldContext(); - var savedGeneratorParameterContext = inGeneratorParameterContext(); - setYieldContext(yieldAndGeneratorParameterContext); - setGeneratorParameterContext(yieldAndGeneratorParameterContext); - var result = parseDelimitedList(14 /* Parameters */, parseParameter); + var savedAwaitContext = inAwaitContext(); + setYieldContext(yieldContext); + setAwaitContext(awaitContext); + var result = parseDelimitedList(16 /* Parameters */, parseParameter); setYieldContext(savedYieldContext); - setGeneratorParameterContext(savedGeneratorParameterContext); + setAwaitContext(savedAwaitContext); if (!parseExpected(17 /* CloseParenToken */) && requireCompleteParameterList) { // Caller insisted that we had to end with a ) We didn't. So just return // undefined here. @@ -8573,10 +8854,10 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 141 /* ConstructSignature */) { - parseExpected(88 /* NewKeyword */); + if (kind === 145 /* ConstructSignature */) { + parseExpected(89 /* NewKeyword */); } - fillSignature(51 /* ColonToken */, false, false, node); + fillSignature(52 /* ColonToken */, false, false, false, node); parseTypeMemberSemicolon(); return finishNode(node); } @@ -8623,24 +8904,24 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token === 51 /* ColonToken */ || token === 23 /* CommaToken */) { + if (token === 52 /* ColonToken */ || token === 23 /* CommaToken */) { return true; } // Question mark could be an indexer with an optional property, // or it could be a conditional expression in a computed property. - if (token !== 50 /* QuestionToken */) { + if (token !== 51 /* QuestionToken */) { return false; } // If any of the following tokens are after the question mark, it cannot // be a conditional expression, so treat it as an indexer. nextToken(); - return token === 51 /* ColonToken */ || token === 23 /* CommaToken */ || token === 19 /* CloseBracketToken */; + return token === 52 /* ColonToken */ || token === 23 /* CommaToken */ || token === 19 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(142 /* IndexSignature */, fullStart); + var node = createNode(146 /* IndexSignature */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - node.parameters = parseBracketedList(14 /* Parameters */, parseParameter, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); + node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); @@ -8648,19 +8929,19 @@ var ts; function parsePropertyOrMethodSignature() { var fullStart = scanner.getStartPos(); var name = parsePropertyName(); - var questionToken = parseOptionalToken(50 /* QuestionToken */); + var questionToken = parseOptionalToken(51 /* QuestionToken */); if (token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { - var method = createNode(135 /* MethodSignature */, fullStart); + var method = createNode(139 /* MethodSignature */, fullStart); method.name = name; method.questionToken = questionToken; // Method signatues don't exist in expression contexts. So they have neither - // [Yield] nor [GeneratorParameter] - fillSignature(51 /* ColonToken */, false, false, method); + // [Yield] nor [Await] + fillSignature(52 /* ColonToken */, false, false, false, method); parseTypeMemberSemicolon(); return finishNode(method); } else { - var property = createNode(133 /* PropertySignature */, fullStart); + var property = createNode(137 /* PropertySignature */, fullStart); property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); @@ -8694,23 +8975,23 @@ var ts; nextToken(); return token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */ || - token === 50 /* QuestionToken */ || - token === 51 /* ColonToken */ || + token === 51 /* QuestionToken */ || + token === 52 /* ColonToken */ || canParseSemicolon(); } function parseTypeMember() { switch (token) { case 16 /* OpenParenToken */: case 24 /* LessThanToken */: - return parseSignatureMember(140 /* CallSignature */); + return parseSignatureMember(144 /* CallSignature */); case 18 /* OpenBracketToken */: // Indexer or computed property return isIndexSignature() ? parseIndexSignatureDeclaration(scanner.getStartPos(), undefined, undefined) : parsePropertyOrMethodSignature(); - case 88 /* NewKeyword */: + case 89 /* NewKeyword */: if (lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(141 /* ConstructSignature */); + return parseSignatureMember(145 /* ConstructSignature */); } // fall through. case 8 /* StringLiteral */: @@ -8747,7 +9028,7 @@ var ts; return token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */; } function parseTypeLiteral() { - var node = createNode(148 /* TypeLiteral */); + var node = createNode(152 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -8763,12 +9044,12 @@ var ts; return members; } function parseTupleType() { - var node = createNode(150 /* TupleType */); - node.elementTypes = parseBracketedList(17 /* TupleElementTypes */, parseType, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); + var node = createNode(154 /* TupleType */); + node.elementTypes = parseBracketedList(19 /* TupleElementTypes */, parseType, 18 /* OpenBracketToken */, 19 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(152 /* ParenthesizedType */); + var node = createNode(157 /* ParenthesizedType */); parseExpected(16 /* OpenParenToken */); node.type = parseType(); parseExpected(17 /* CloseParenToken */); @@ -8776,10 +9057,10 @@ var ts; } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 146 /* ConstructorType */) { - parseExpected(88 /* NewKeyword */); + if (kind === 150 /* ConstructorType */) { + parseExpected(89 /* NewKeyword */); } - fillSignature(32 /* EqualsGreaterThanToken */, false, false, node); + fillSignature(33 /* EqualsGreaterThanToken */, false, false, false, node); return finishNode(node); } function parseKeywordAndNoDot() { @@ -8788,17 +9069,17 @@ var ts; } function parseNonArrayType() { switch (token) { - case 112 /* AnyKeyword */: - case 123 /* StringKeyword */: - case 121 /* NumberKeyword */: - case 113 /* BooleanKeyword */: - case 124 /* SymbolKeyword */: + case 114 /* AnyKeyword */: + case 127 /* StringKeyword */: + case 125 /* NumberKeyword */: + case 117 /* BooleanKeyword */: + case 128 /* SymbolKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReferenceOrTypePredicate(); - case 99 /* VoidKeyword */: + case 100 /* VoidKeyword */: return parseTokenNode(); - case 97 /* TypeOfKeyword */: + case 98 /* TypeOfKeyword */: return parseTypeQuery(); case 14 /* OpenBraceToken */: return parseTypeLiteral(); @@ -8812,17 +9093,17 @@ var ts; } function isStartOfType() { switch (token) { - case 112 /* AnyKeyword */: - case 123 /* StringKeyword */: - case 121 /* NumberKeyword */: - case 113 /* BooleanKeyword */: - case 124 /* SymbolKeyword */: - case 99 /* VoidKeyword */: - case 97 /* TypeOfKeyword */: + case 114 /* AnyKeyword */: + case 127 /* StringKeyword */: + case 125 /* NumberKeyword */: + case 117 /* BooleanKeyword */: + case 128 /* SymbolKeyword */: + case 100 /* VoidKeyword */: + case 98 /* TypeOfKeyword */: case 14 /* OpenBraceToken */: case 18 /* OpenBracketToken */: case 24 /* LessThanToken */: - case 88 /* NewKeyword */: + case 89 /* NewKeyword */: return true; case 16 /* OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, @@ -8840,27 +9121,33 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak() && parseOptional(18 /* OpenBracketToken */)) { parseExpected(19 /* CloseBracketToken */); - var node = createNode(149 /* ArrayType */, type.pos); + var node = createNode(153 /* ArrayType */, type.pos); node.elementType = type; type = finishNode(node); } return type; } - function parseUnionTypeOrHigher() { - var type = parseArrayTypeOrHigher(); - if (token === 44 /* BarToken */) { + function parseUnionOrIntersectionType(kind, parseConstituentType, operator) { + var type = parseConstituentType(); + if (token === operator) { var types = [type]; types.pos = type.pos; - while (parseOptional(44 /* BarToken */)) { - types.push(parseArrayTypeOrHigher()); + while (parseOptional(operator)) { + types.push(parseConstituentType()); } types.end = getNodeEnd(); - var node = createNode(151 /* UnionType */, type.pos); + var node = createNode(kind, type.pos); node.types = types; type = finishNode(node); } return type; } + function parseIntersectionTypeOrHigher() { + return parseUnionOrIntersectionType(156 /* IntersectionType */, parseArrayTypeOrHigher, 44 /* AmpersandToken */); + } + function parseUnionTypeOrHigher() { + return parseUnionOrIntersectionType(155 /* UnionType */, parseIntersectionTypeOrHigher, 45 /* BarToken */); + } function isStartOfFunctionType() { if (token === 24 /* LessThanToken */) { return true; @@ -8876,8 +9163,8 @@ var ts; } if (isIdentifier() || ts.isModifier(token)) { nextToken(); - if (token === 51 /* ColonToken */ || token === 23 /* CommaToken */ || - token === 50 /* QuestionToken */ || token === 53 /* EqualsToken */ || + if (token === 52 /* ColonToken */ || token === 23 /* CommaToken */ || + token === 51 /* QuestionToken */ || token === 54 /* EqualsToken */ || isIdentifier() || ts.isModifier(token)) { // ( id : // ( id , @@ -8888,7 +9175,7 @@ var ts; } if (token === 17 /* CloseParenToken */) { nextToken(); - if (token === 32 /* EqualsGreaterThanToken */) { + if (token === 33 /* EqualsGreaterThanToken */) { // ( id ) => return true; } @@ -8899,35 +9186,28 @@ var ts; function parseType() { // The rules about 'yield' only apply to actual code/expression contexts. They don't // apply to 'type' contexts. So we disable these parameters here before moving on. - var savedYieldContext = inYieldContext(); - var savedGeneratorParameterContext = inGeneratorParameterContext(); - setYieldContext(false); - setGeneratorParameterContext(false); - var result = parseTypeWorker(); - setYieldContext(savedYieldContext); - setGeneratorParameterContext(savedGeneratorParameterContext); - return result; + return doOutsideOfContext(10 /* TypeExcludesFlags */, parseTypeWorker); } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(145 /* FunctionType */); + return parseFunctionOrConstructorType(149 /* FunctionType */); } - if (token === 88 /* NewKeyword */) { - return parseFunctionOrConstructorType(146 /* ConstructorType */); + if (token === 89 /* NewKeyword */) { + return parseFunctionOrConstructorType(150 /* ConstructorType */); } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(51 /* ColonToken */) ? parseType() : undefined; + return parseOptional(52 /* ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token) { - case 93 /* ThisKeyword */: - case 91 /* SuperKeyword */: - case 89 /* NullKeyword */: - case 95 /* TrueKeyword */: - case 80 /* FalseKeyword */: + case 94 /* ThisKeyword */: + case 92 /* SuperKeyword */: + case 90 /* NullKeyword */: + case 96 /* TrueKeyword */: + case 81 /* FalseKeyword */: case 7 /* NumericLiteral */: case 8 /* StringLiteral */: case 10 /* NoSubstitutionTemplateLiteral */: @@ -8935,12 +9215,12 @@ var ts; case 16 /* OpenParenToken */: case 18 /* OpenBracketToken */: case 14 /* OpenBraceToken */: - case 83 /* FunctionKeyword */: - case 69 /* ClassKeyword */: - case 88 /* NewKeyword */: - case 36 /* SlashToken */: - case 57 /* SlashEqualsToken */: - case 65 /* Identifier */: + case 84 /* FunctionKeyword */: + case 70 /* ClassKeyword */: + case 89 /* NewKeyword */: + case 37 /* SlashToken */: + case 58 /* SlashEqualsToken */: + case 66 /* Identifier */: return true; default: return isIdentifier(); @@ -8951,20 +9231,21 @@ var ts; return true; } switch (token) { - case 33 /* PlusToken */: - case 34 /* MinusToken */: - case 47 /* TildeToken */: - case 46 /* ExclamationToken */: - case 74 /* DeleteKeyword */: - case 97 /* TypeOfKeyword */: - case 99 /* VoidKeyword */: - case 38 /* PlusPlusToken */: - case 39 /* MinusMinusToken */: + case 34 /* PlusToken */: + case 35 /* MinusToken */: + case 48 /* TildeToken */: + case 47 /* ExclamationToken */: + case 75 /* DeleteKeyword */: + case 98 /* TypeOfKeyword */: + case 100 /* VoidKeyword */: + case 39 /* PlusPlusToken */: + case 40 /* MinusMinusToken */: case 24 /* LessThanToken */: - case 110 /* YieldKeyword */: - // Yield always starts an expression. Either it is an identifier (in which case + case 116 /* AwaitKeyword */: + case 111 /* YieldKeyword */: + // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in - // a generator, or in strict mode (or both)) and it started a yield expression. + // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. return true; default: // Error tolerance. If we see the start of some binary operator, we consider @@ -8980,11 +9261,14 @@ var ts; function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. return token !== 14 /* OpenBraceToken */ && - token !== 83 /* FunctionKeyword */ && - token !== 69 /* ClassKeyword */ && - token !== 52 /* AtToken */ && + token !== 84 /* FunctionKeyword */ && + token !== 70 /* ClassKeyword */ && + token !== 53 /* AtToken */ && isStartOfExpression(); } + function allowInAndParseExpression() { + return allowInAnd(parseExpression); + } function parseExpression() { // Expression[in]: // AssignmentExpression[in] @@ -9005,7 +9289,7 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token !== 53 /* EqualsToken */) { + if (token !== 54 /* EqualsToken */) { // It's not uncommon during typing for the user to miss writing the '=' token. Check if // there is no newline after the last token and if we're on an expression. If so, parse // this as an equals-value clause with a missing equals. @@ -9022,7 +9306,7 @@ var ts; } // Initializer[In, Yield] : // = AssignmentExpression[?In, ?Yield] - parseExpected(53 /* EqualsToken */); + parseExpected(54 /* EqualsToken */); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -9060,7 +9344,7 @@ var ts; // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 65 /* Identifier */ && token === 32 /* EqualsGreaterThanToken */) { + if (expr.kind === 66 /* Identifier */ && token === 33 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } // Now see if we might be in cases '2' or '3'. @@ -9076,7 +9360,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token === 110 /* YieldKeyword */) { + if (token === 111 /* YieldKeyword */) { // If we have a 'yield' keyword, and htis is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { @@ -9105,15 +9389,15 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(175 /* YieldExpression */); + var node = createNode(181 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token === 35 /* AsteriskToken */ || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(35 /* AsteriskToken */); + (token === 36 /* AsteriskToken */ || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(36 /* AsteriskToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -9124,16 +9408,16 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier) { - ts.Debug.assert(token === 32 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - var node = createNode(166 /* ArrowFunction */, identifier.pos); - var parameter = createNode(131 /* Parameter */, identifier.pos); + ts.Debug.assert(token === 33 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + var node = createNode(171 /* ArrowFunction */, identifier.pos); + var parameter = createNode(135 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = [parameter]; node.parameters.pos = parameter.pos; node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(32 /* EqualsGreaterThanToken */, false, ts.Diagnostics._0_expected, "=>"); - node.body = parseArrowFunctionExpressionBody(); + node.equalsGreaterThanToken = parseExpectedToken(33 /* EqualsGreaterThanToken */, false, ts.Diagnostics._0_expected, "=>"); + node.body = parseArrowFunctionExpressionBody(false); return finishNode(node); } function tryParseParenthesizedArrowFunctionExpression() { @@ -9153,12 +9437,13 @@ var ts; // Didn't appear to actually be a parenthesized arrow function. Just bail out. return undefined; } + var isAsync = !!(arrowFunction.flags & 512 /* Async */); // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token; - arrowFunction.equalsGreaterThanToken = parseExpectedToken(32 /* EqualsGreaterThanToken */, false, ts.Diagnostics._0_expected, "=>"); - arrowFunction.body = (lastToken === 32 /* EqualsGreaterThanToken */ || lastToken === 14 /* OpenBraceToken */) - ? parseArrowFunctionExpressionBody() + arrowFunction.equalsGreaterThanToken = parseExpectedToken(33 /* EqualsGreaterThanToken */, false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 33 /* EqualsGreaterThanToken */ || lastToken === 14 /* OpenBraceToken */) + ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); } @@ -9167,10 +9452,10 @@ var ts; // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { + if (token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */ || token === 115 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token === 32 /* EqualsGreaterThanToken */) { + if (token === 33 /* EqualsGreaterThanToken */) { // ERROR RECOVERY TWEAK: // If we see a standalone => try to parse it as an arrow function expression as that's // likely what the user intended to write. @@ -9180,6 +9465,15 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { + if (token === 115 /* AsyncKeyword */) { + nextToken(); + if (scanner.hasPrecedingLineBreak()) { + return 0 /* False */; + } + if (token !== 16 /* OpenParenToken */ && token !== 24 /* LessThanToken */) { + return 0 /* False */; + } + } var first = token; var second = nextToken(); if (first === 16 /* OpenParenToken */) { @@ -9190,8 +9484,8 @@ var ts; // but this is probably what the user intended. var third = nextToken(); switch (third) { - case 32 /* EqualsGreaterThanToken */: - case 51 /* ColonToken */: + case 33 /* EqualsGreaterThanToken */: + case 52 /* ColonToken */: case 14 /* OpenBraceToken */: return 1 /* True */; default: @@ -9222,7 +9516,7 @@ var ts; } // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. - if (nextToken() === 51 /* ColonToken */) { + if (nextToken() === 52 /* ColonToken */) { return 1 /* True */; } // This *could* be a parenthesized arrow function. @@ -9236,6 +9530,30 @@ var ts; if (!isIdentifier()) { return 0 /* False */; } + // JSX overrides + if (sourceFile.languageVariant === 1 /* JSX */) { + var isArrowFunctionInJsx = lookAhead(function () { + var third = nextToken(); + if (third === 80 /* ExtendsKeyword */) { + var fourth = nextToken(); + switch (fourth) { + case 54 /* EqualsToken */: + case 26 /* GreaterThanToken */: + return false; + default: + return true; + } + } + else if (third === 23 /* CommaToken */) { + return true; + } + return false; + }); + if (isArrowFunctionInJsx) { + return 1 /* True */; + } + return 0 /* False */; + } // This *could* be a parenthesized arrow function. return 2 /* Unknown */; } @@ -9244,7 +9562,9 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(166 /* ArrowFunction */); + var node = createNode(171 /* ArrowFunction */); + setModifiers(node, parseModifiersForArrowFunction()); + var isAsync = !!(node.flags & 512 /* Async */); // Arrow functions are never generators. // // If we're speculatively parsing a signature for a parenthesized arrow function, then @@ -9252,7 +9572,7 @@ var ts; // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - fillSignature(51 /* ColonToken */, false, !allowAmbiguity, node); + fillSignature(52 /* ColonToken */, false, isAsync, !allowAmbiguity, node); // If we couldn't get parameters, we definitely could not parse out an arrow function. if (!node.parameters) { return undefined; @@ -9265,19 +9585,19 @@ var ts; // - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation. // // So we need just a bit of lookahead to ensure that it can only be a signature. - if (!allowAmbiguity && token !== 32 /* EqualsGreaterThanToken */ && token !== 14 /* OpenBraceToken */) { + if (!allowAmbiguity && token !== 33 /* EqualsGreaterThanToken */ && token !== 14 /* OpenBraceToken */) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } return node; } - function parseArrowFunctionExpressionBody() { + function parseArrowFunctionExpressionBody(isAsync) { if (token === 14 /* OpenBraceToken */) { - return parseFunctionBlock(false, false); + return parseFunctionBlock(false, isAsync, false); } if (token !== 22 /* SemicolonToken */ && - token !== 83 /* FunctionKeyword */ && - token !== 69 /* ClassKeyword */ && + token !== 84 /* FunctionKeyword */ && + token !== 70 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -9294,23 +9614,25 @@ var ts; // up preemptively closing the containing construct. // // Note: even when 'ignoreMissingOpenBrace' is passed as true, parseBody will still error. - return parseFunctionBlock(false, true); + return parseFunctionBlock(false, isAsync, true); } - return parseAssignmentExpressionOrHigher(); + return isAsync + ? doInAwaitContext(parseAssignmentExpressionOrHigher) + : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); } function parseConditionalExpressionRest(leftOperand) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(50 /* QuestionToken */); + var questionToken = parseOptionalToken(51 /* QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(173 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(179 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(51 /* ColonToken */, false, ts.Diagnostics._0_expected, ts.tokenToString(51 /* ColonToken */)); + node.colonToken = parseExpectedToken(52 /* ColonToken */, false, ts.Diagnostics._0_expected, ts.tokenToString(52 /* ColonToken */)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -9319,7 +9641,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 86 /* InKeyword */ || t === 127 /* OfKeyword */; + return t === 87 /* InKeyword */ || t === 131 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -9331,53 +9653,70 @@ var ts; if (newPrecedence <= precedence) { break; } - if (token === 86 /* InKeyword */ && inDisallowInContext()) { + if (token === 87 /* InKeyword */ && inDisallowInContext()) { break; } - leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence)); + if (token === 113 /* AsKeyword */) { + // Make sure we *do* perform ASI for constructs like this: + // var x = foo + // as (Bar) + // This should be parsed as an initialized variable, followed + // by a function call to 'as' with the argument 'Bar' + if (scanner.hasPrecedingLineBreak()) { + break; + } + else { + nextToken(); + leftOperand = makeAsExpression(leftOperand, parseType()); + } + } + else { + leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence)); + } } return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token === 86 /* InKeyword */) { + if (inDisallowInContext() && token === 87 /* InKeyword */) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token) { - case 49 /* BarBarToken */: + case 50 /* BarBarToken */: return 1; - case 48 /* AmpersandAmpersandToken */: + case 49 /* AmpersandAmpersandToken */: return 2; - case 44 /* BarToken */: + case 45 /* BarToken */: return 3; - case 45 /* CaretToken */: + case 46 /* CaretToken */: return 4; - case 43 /* AmpersandToken */: + case 44 /* AmpersandToken */: return 5; - case 28 /* EqualsEqualsToken */: - case 29 /* ExclamationEqualsToken */: - case 30 /* EqualsEqualsEqualsToken */: - case 31 /* ExclamationEqualsEqualsToken */: + case 29 /* EqualsEqualsToken */: + case 30 /* ExclamationEqualsToken */: + case 31 /* EqualsEqualsEqualsToken */: + case 32 /* ExclamationEqualsEqualsToken */: return 6; case 24 /* LessThanToken */: - case 25 /* GreaterThanToken */: - case 26 /* LessThanEqualsToken */: - case 27 /* GreaterThanEqualsToken */: - case 87 /* InstanceOfKeyword */: - case 86 /* InKeyword */: + case 26 /* GreaterThanToken */: + case 27 /* LessThanEqualsToken */: + case 28 /* GreaterThanEqualsToken */: + case 88 /* InstanceOfKeyword */: + case 87 /* InKeyword */: + case 113 /* AsKeyword */: return 7; - case 40 /* LessThanLessThanToken */: - case 41 /* GreaterThanGreaterThanToken */: - case 42 /* GreaterThanGreaterThanGreaterThanToken */: + case 41 /* LessThanLessThanToken */: + case 42 /* GreaterThanGreaterThanToken */: + case 43 /* GreaterThanGreaterThanGreaterThanToken */: return 8; - case 33 /* PlusToken */: - case 34 /* MinusToken */: + case 34 /* PlusToken */: + case 35 /* MinusToken */: return 9; - case 35 /* AsteriskToken */: - case 36 /* SlashToken */: - case 37 /* PercentToken */: + case 36 /* AsteriskToken */: + case 37 /* SlashToken */: + case 38 /* PercentToken */: return 10; } // -1 is lower than all other precedences. Returning it will cause binary expression @@ -9385,54 +9724,85 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(172 /* BinaryExpression */, left.pos); + var node = createNode(178 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } + function makeAsExpression(left, right) { + var node = createNode(186 /* AsExpression */, left.pos); + node.expression = left; + node.type = right; + return finishNode(node); + } function parsePrefixUnaryExpression() { - var node = createNode(170 /* PrefixUnaryExpression */); + var node = createNode(176 /* PrefixUnaryExpression */); node.operator = token; nextToken(); node.operand = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(167 /* DeleteExpression */); + var node = createNode(172 /* DeleteExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(168 /* TypeOfExpression */); + var node = createNode(173 /* TypeOfExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(169 /* VoidExpression */); + var node = createNode(174 /* VoidExpression */); + nextToken(); + node.expression = parseUnaryExpressionOrHigher(); + return finishNode(node); + } + function isAwaitExpression() { + if (token === 116 /* AwaitKeyword */) { + if (inAwaitContext()) { + return true; + } + // here we are using similar heuristics as 'isYieldExpression' + return lookAhead(nextTokenIsIdentifierOnSameLine); + } + return false; + } + function parseAwaitExpression() { + var node = createNode(175 /* AwaitExpression */); nextToken(); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } function parseUnaryExpressionOrHigher() { + if (isAwaitExpression()) { + return parseAwaitExpression(); + } switch (token) { - case 33 /* PlusToken */: - case 34 /* MinusToken */: - case 47 /* TildeToken */: - case 46 /* ExclamationToken */: - case 38 /* PlusPlusToken */: - case 39 /* MinusMinusToken */: + case 34 /* PlusToken */: + case 35 /* MinusToken */: + case 48 /* TildeToken */: + case 47 /* ExclamationToken */: + case 39 /* PlusPlusToken */: + case 40 /* MinusMinusToken */: return parsePrefixUnaryExpression(); - case 74 /* DeleteKeyword */: + case 75 /* DeleteKeyword */: return parseDeleteExpression(); - case 97 /* TypeOfKeyword */: + case 98 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 99 /* VoidKeyword */: + case 100 /* VoidKeyword */: return parseVoidExpression(); case 24 /* LessThanToken */: - return parseTypeAssertion(); + if (sourceFile.languageVariant !== 1 /* JSX */) { + return parseTypeAssertion(); + } + if (lookAhead(nextTokenIsIdentifierOrKeyword)) { + return parseJsxElementOrSelfClosingElement(); + } + // Fall through default: return parsePostfixExpressionOrHigher(); } @@ -9440,8 +9810,8 @@ var ts; function parsePostfixExpressionOrHigher() { var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token === 38 /* PlusPlusToken */ || token === 39 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(171 /* PostfixUnaryExpression */, expression.pos); + if ((token === 39 /* PlusPlusToken */ || token === 40 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(177 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token; nextToken(); @@ -9480,7 +9850,7 @@ var ts; // the last two CallExpression productions. Or we have a MemberExpression which either // completes the LeftHandSideExpression, or starts the beginning of the first four // CallExpression productions. - var expression = token === 91 /* SuperKeyword */ + var expression = token === 92 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); // Now, we *may* be complete. However, we might have consumed the start of a @@ -9545,17 +9915,141 @@ var ts; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(158 /* PropertyAccessExpression */, expression.pos); + var node = createNode(163 /* PropertyAccessExpression */, expression.pos); node.expression = expression; node.dotToken = parseExpectedToken(20 /* DotToken */, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } + function parseJsxElementOrSelfClosingElement() { + var opening = parseJsxOpeningOrSelfClosingElement(); + if (opening.kind === 232 /* JsxOpeningElement */) { + var node = createNode(230 /* JsxElement */, opening.pos); + node.openingElement = opening; + node.children = parseJsxChildren(node.openingElement.tagName); + node.closingElement = parseJsxClosingElement(); + return finishNode(node); + } + else { + ts.Debug.assert(opening.kind === 231 /* JsxSelfClosingElement */); + // Nothing else to do for self-closing elements + return opening; + } + } + function parseJsxText() { + var node = createNode(233 /* JsxText */, scanner.getStartPos()); + token = scanner.scanJsxToken(); + return finishNode(node); + } + function parseJsxChild() { + switch (token) { + case 233 /* JsxText */: + return parseJsxText(); + case 14 /* OpenBraceToken */: + return parseJsxExpression(); + case 24 /* LessThanToken */: + return parseJsxElementOrSelfClosingElement(); + } + ts.Debug.fail('Unknown JSX child kind ' + token); + } + function parseJsxChildren(openingTagName) { + var result = []; + result.pos = scanner.getStartPos(); + var saveParsingContext = parsingContext; + parsingContext |= 1 << 14 /* JsxChildren */; + while (true) { + token = scanner.reScanJsxToken(); + if (token === 25 /* LessThanSlashToken */) { + break; + } + else if (token === 1 /* EndOfFileToken */) { + parseErrorAtCurrentToken(ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNodeFromSourceText(sourceText, openingTagName)); + break; + } + result.push(parseJsxChild()); + } + result.end = scanner.getTokenPos(); + parsingContext = saveParsingContext; + return result; + } + function parseJsxOpeningOrSelfClosingElement() { + var fullStart = scanner.getStartPos(); + parseExpected(24 /* LessThanToken */); + var tagName = parseJsxElementName(); + var attributes = parseList(13 /* JsxAttributes */, parseJsxAttribute); + var node; + if (parseOptional(26 /* GreaterThanToken */)) { + node = createNode(232 /* JsxOpeningElement */, fullStart); + } + else { + parseExpected(37 /* SlashToken */); + parseExpected(26 /* GreaterThanToken */); + node = createNode(231 /* JsxSelfClosingElement */, fullStart); + } + node.tagName = tagName; + node.attributes = attributes; + return finishNode(node); + } + function parseJsxElementName() { + scanJsxIdentifier(); + var elementName = parseIdentifierName(); + while (parseOptional(20 /* DotToken */)) { + scanJsxIdentifier(); + var node = createNode(132 /* QualifiedName */, elementName.pos); + node.left = elementName; + node.right = parseIdentifierName(); + elementName = finishNode(node); + } + return elementName; + } + function parseJsxExpression() { + var node = createNode(237 /* JsxExpression */); + parseExpected(14 /* OpenBraceToken */); + if (token !== 15 /* CloseBraceToken */) { + node.expression = parseExpression(); + } + parseExpected(15 /* CloseBraceToken */); + return finishNode(node); + } + function parseJsxAttribute() { + if (token === 14 /* OpenBraceToken */) { + return parseJsxSpreadAttribute(); + } + scanJsxIdentifier(); + var node = createNode(235 /* JsxAttribute */); + node.name = parseIdentifierName(); + if (parseOptional(54 /* EqualsToken */)) { + switch (token) { + case 8 /* StringLiteral */: + node.initializer = parseLiteralNode(); + break; + default: + node.initializer = parseJsxExpression(); + break; + } + } + return finishNode(node); + } + function parseJsxSpreadAttribute() { + var node = createNode(236 /* JsxSpreadAttribute */); + parseExpected(14 /* OpenBraceToken */); + parseExpected(21 /* DotDotDotToken */); + node.expression = parseExpression(); + parseExpected(15 /* CloseBraceToken */); + return finishNode(node); + } + function parseJsxClosingElement() { + var node = createNode(234 /* JsxClosingElement */); + parseExpected(25 /* LessThanSlashToken */); + node.tagName = parseJsxElementName(); + parseExpected(26 /* GreaterThanToken */); + return finishNode(node); + } function parseTypeAssertion() { - var node = createNode(163 /* TypeAssertionExpression */); + var node = createNode(168 /* TypeAssertionExpression */); parseExpected(24 /* LessThanToken */); node.type = parseType(); - parseExpected(25 /* GreaterThanToken */); + parseExpected(26 /* GreaterThanToken */); node.expression = parseUnaryExpressionOrHigher(); return finishNode(node); } @@ -9563,16 +10057,16 @@ var ts; while (true) { var dotToken = parseOptionalToken(20 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(158 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(163 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.dotToken = dotToken; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); continue; } - // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName + // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName if (!inDecoratorContext() && parseOptional(18 /* OpenBracketToken */)) { - var indexedAccess = createNode(159 /* ElementAccessExpression */, expression.pos); + var indexedAccess = createNode(164 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; // It's not uncommon for a user to write: "new Type[]". // Check for that common pattern and report a better error message. @@ -9588,7 +10082,7 @@ var ts; continue; } if (token === 10 /* NoSubstitutionTemplateLiteral */ || token === 11 /* TemplateHead */) { - var tagExpression = createNode(162 /* TaggedTemplateExpression */, expression.pos); + var tagExpression = createNode(167 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; tagExpression.template = token === 10 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() @@ -9611,7 +10105,7 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(160 /* CallExpression */, expression.pos); + var callExpr = createNode(165 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); @@ -9619,7 +10113,7 @@ var ts; continue; } else if (token === 16 /* OpenParenToken */) { - var callExpr = createNode(160 /* CallExpression */, expression.pos); + var callExpr = createNode(165 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -9638,8 +10132,8 @@ var ts; if (!parseOptional(24 /* LessThanToken */)) { return undefined; } - var typeArguments = parseDelimitedList(16 /* TypeArguments */, parseType); - if (!parseExpected(25 /* GreaterThanToken */)) { + var typeArguments = parseDelimitedList(18 /* TypeArguments */, parseType); + if (!parseExpected(26 /* GreaterThanToken */)) { // If it doesn't have the closing > then it's definitely not an type argument list. return undefined; } @@ -9657,18 +10151,18 @@ var ts; case 20 /* DotToken */: // foo. case 17 /* CloseParenToken */: // foo) case 19 /* CloseBracketToken */: // foo] - case 51 /* ColonToken */: // foo: + case 52 /* ColonToken */: // foo: case 22 /* SemicolonToken */: // foo; - case 50 /* QuestionToken */: // foo? - case 28 /* EqualsEqualsToken */: // foo == - case 30 /* EqualsEqualsEqualsToken */: // foo === - case 29 /* ExclamationEqualsToken */: // foo != - case 31 /* ExclamationEqualsEqualsToken */: // foo !== - case 48 /* AmpersandAmpersandToken */: // foo && - case 49 /* BarBarToken */: // foo || - case 45 /* CaretToken */: // foo ^ - case 43 /* AmpersandToken */: // foo & - case 44 /* BarToken */: // foo | + case 51 /* QuestionToken */: // foo? + case 29 /* EqualsEqualsToken */: // foo == + case 31 /* EqualsEqualsEqualsToken */: // foo === + case 30 /* ExclamationEqualsToken */: // foo != + case 32 /* ExclamationEqualsEqualsToken */: // foo !== + case 49 /* AmpersandAmpersandToken */: // foo && + case 50 /* BarBarToken */: // foo || + case 46 /* CaretToken */: // foo ^ + case 44 /* AmpersandToken */: // foo & + case 45 /* BarToken */: // foo | case 15 /* CloseBraceToken */: // foo } case 1 /* EndOfFileToken */: // these cases can't legally follow a type arg list. However, they're not legal @@ -9678,7 +10172,7 @@ var ts; case 23 /* CommaToken */: // foo, case 14 /* OpenBraceToken */: // foo { // We don't want to treat these as type arguments. Otherwise we'll parse this - // as an invocation expression. Instead, we want to parse out the expression + // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. default: // Anything else treat as an expression. @@ -9691,11 +10185,11 @@ var ts; case 8 /* StringLiteral */: case 10 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 93 /* ThisKeyword */: - case 91 /* SuperKeyword */: - case 89 /* NullKeyword */: - case 95 /* TrueKeyword */: - case 80 /* FalseKeyword */: + case 94 /* ThisKeyword */: + case 92 /* SuperKeyword */: + case 90 /* NullKeyword */: + case 96 /* TrueKeyword */: + case 81 /* FalseKeyword */: return parseTokenNode(); case 16 /* OpenParenToken */: return parseParenthesizedExpression(); @@ -9703,14 +10197,22 @@ var ts; return parseArrayLiteralExpression(); case 14 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 69 /* ClassKeyword */: - return parseClassExpression(); - case 83 /* FunctionKeyword */: + case 115 /* AsyncKeyword */: + // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. + // If we encounter `async [no LineTerminator here] function` then this is an async + // function; otherwise, its an identifier. + if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { + break; + } return parseFunctionExpression(); - case 88 /* NewKeyword */: + case 70 /* ClassKeyword */: + return parseClassExpression(); + case 84 /* FunctionKeyword */: + return parseFunctionExpression(); + case 89 /* NewKeyword */: return parseNewExpression(); - case 36 /* SlashToken */: - case 57 /* SlashEqualsToken */: + case 37 /* SlashToken */: + case 58 /* SlashEqualsToken */: if (reScanSlashToken() === 9 /* RegularExpressionLiteral */) { return parseLiteralNode(); } @@ -9721,41 +10223,41 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(164 /* ParenthesizedExpression */); + var node = createNode(169 /* ParenthesizedExpression */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(17 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(176 /* SpreadElementExpression */); + var node = createNode(182 /* SpreadElementExpression */); parseExpected(21 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token === 21 /* DotDotDotToken */ ? parseSpreadElement() : - token === 23 /* CommaToken */ ? createNode(178 /* OmittedExpression */) : + token === 23 /* CommaToken */ ? createNode(184 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(156 /* ArrayLiteralExpression */); + var node = createNode(161 /* ArrayLiteralExpression */); parseExpected(18 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) - node.flags |= 512 /* MultiLine */; - node.elements = parseDelimitedList(13 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); + node.flags |= 2048 /* MultiLine */; + node.elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); parseExpected(19 /* CloseBracketToken */); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(116 /* GetKeyword */)) { - return parseAccessorDeclaration(138 /* GetAccessor */, fullStart, decorators, modifiers); + if (parseContextualModifier(120 /* GetKeyword */)) { + return parseAccessorDeclaration(142 /* GetAccessor */, fullStart, decorators, modifiers); } - else if (parseContextualModifier(122 /* SetKeyword */)) { - return parseAccessorDeclaration(139 /* SetAccessor */, fullStart, decorators, modifiers); + else if (parseContextualModifier(126 /* SetKeyword */)) { + return parseAccessorDeclaration(143 /* SetAccessor */, fullStart, decorators, modifiers); } return undefined; } @@ -9767,56 +10269,64 @@ var ts; if (accessor) { return accessor; } - var asteriskToken = parseOptionalToken(35 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(36 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); var nameToken = token; var propertyName = parsePropertyName(); // Disallowing of optional property assignments happens in the grammar checker. - var questionToken = parseOptionalToken(50 /* QuestionToken */); + var questionToken = parseOptionalToken(51 /* QuestionToken */); if (asteriskToken || token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } // Parse to check if it is short-hand property assignment or normal property assignment if ((token === 23 /* CommaToken */ || token === 15 /* CloseBraceToken */) && tokenIsIdentifier) { - var shorthandDeclaration = createNode(228 /* ShorthandPropertyAssignment */, fullStart); + var shorthandDeclaration = createNode(243 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; return finishNode(shorthandDeclaration); } else { - var propertyAssignment = createNode(227 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(242 /* PropertyAssignment */, fullStart); propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(51 /* ColonToken */); + parseExpected(52 /* ColonToken */); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return finishNode(propertyAssignment); } } function parseObjectLiteralExpression() { - var node = createNode(157 /* ObjectLiteralExpression */); + var node = createNode(162 /* ObjectLiteralExpression */); parseExpected(14 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { - node.flags |= 512 /* MultiLine */; + node.flags |= 2048 /* MultiLine */; } node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, true); parseExpected(15 /* CloseBraceToken */); return finishNode(node); } function parseFunctionExpression() { - // GeneratorExpression : - // function * BindingIdentifier[Yield]opt (FormalParameters[Yield, GeneratorParameter]) { GeneratorBody[Yield] } + // GeneratorExpression: + // function* BindingIdentifier [Yield][opt](FormalParameters[Yield]){ GeneratorBody } + // // FunctionExpression: - // function BindingIdentifieropt(FormalParameters) { FunctionBody } + // function BindingIdentifier[opt](FormalParameters){ FunctionBody } var saveDecoratorContext = inDecoratorContext(); if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(165 /* FunctionExpression */); - parseExpected(83 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(35 /* AsteriskToken */); - node.name = node.asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(51 /* ColonToken */, !!node.asteriskToken, false, node); - node.body = parseFunctionBlock(!!node.asteriskToken, false); + var node = createNode(170 /* FunctionExpression */); + setModifiers(node, parseModifiers()); + parseExpected(84 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(36 /* AsteriskToken */); + var isGenerator = !!node.asteriskToken; + var isAsync = !!(node.flags & 512 /* Async */); + node.name = + isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalIdentifier) : + isGenerator ? doInYieldContext(parseOptionalIdentifier) : + isAsync ? doInAwaitContext(parseOptionalIdentifier) : + parseOptionalIdentifier(); + fillSignature(52 /* ColonToken */, isGenerator, isAsync, false, node); + node.body = parseFunctionBlock(isGenerator, isAsync, false); if (saveDecoratorContext) { setDecoratorContext(true); } @@ -9826,8 +10336,8 @@ var ts; return isIdentifier() ? parseIdentifier() : undefined; } function parseNewExpression() { - var node = createNode(161 /* NewExpression */); - parseExpected(88 /* NewKeyword */); + var node = createNode(166 /* NewExpression */); + parseExpected(89 /* NewKeyword */); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); if (node.typeArguments || token === 16 /* OpenParenToken */) { @@ -9837,7 +10347,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(182 /* Block */); + var node = createNode(189 /* Block */); if (parseExpected(14 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(15 /* CloseBraceToken */); @@ -9847,10 +10357,12 @@ var ts; } return finishNode(node); } - function parseFunctionBlock(allowYield, ignoreMissingOpenBrace, diagnosticMessage) { + function parseFunctionBlock(allowYield, allowAwait, ignoreMissingOpenBrace, diagnosticMessage) { var savedYieldContext = inYieldContext(); setYieldContext(allowYield); - // We may be in a [Decorator] context when parsing a function expression or + var savedAwaitContext = inAwaitContext(); + setAwaitContext(allowAwait); + // We may be in a [Decorator] context when parsing a function expression or // arrow function. The body of the function is not in [Decorator] context. var saveDecoratorContext = inDecoratorContext(); if (saveDecoratorContext) { @@ -9861,28 +10373,29 @@ var ts; setDecoratorContext(true); } setYieldContext(savedYieldContext); + setAwaitContext(savedAwaitContext); return block; } function parseEmptyStatement() { - var node = createNode(184 /* EmptyStatement */); + var node = createNode(191 /* EmptyStatement */); parseExpected(22 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(186 /* IfStatement */); - parseExpected(84 /* IfKeyword */); + var node = createNode(193 /* IfStatement */); + parseExpected(85 /* IfKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(17 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(76 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(77 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(187 /* DoStatement */); - parseExpected(75 /* DoKeyword */); + var node = createNode(194 /* DoStatement */); + parseExpected(76 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(100 /* WhileKeyword */); + parseExpected(101 /* WhileKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(17 /* CloseParenToken */); @@ -9894,8 +10407,8 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(188 /* WhileStatement */); - parseExpected(100 /* WhileKeyword */); + var node = createNode(195 /* WhileStatement */); + parseExpected(101 /* WhileKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(17 /* CloseParenToken */); @@ -9904,11 +10417,11 @@ var ts; } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(82 /* ForKeyword */); + parseExpected(83 /* ForKeyword */); parseExpected(16 /* OpenParenToken */); var initializer = undefined; if (token !== 22 /* SemicolonToken */) { - if (token === 98 /* VarKeyword */ || token === 104 /* LetKeyword */ || token === 70 /* ConstKeyword */) { + if (token === 99 /* VarKeyword */ || token === 105 /* LetKeyword */ || token === 71 /* ConstKeyword */) { initializer = parseVariableDeclarationList(true); } else { @@ -9916,22 +10429,22 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(86 /* InKeyword */)) { - var forInStatement = createNode(190 /* ForInStatement */, pos); + if (parseOptional(87 /* InKeyword */)) { + var forInStatement = createNode(197 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(17 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } - else if (parseOptional(127 /* OfKeyword */)) { - var forOfStatement = createNode(191 /* ForOfStatement */, pos); + else if (parseOptional(131 /* OfKeyword */)) { + var forOfStatement = createNode(198 /* ForOfStatement */, pos); forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(17 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } else { - var forStatement = createNode(189 /* ForStatement */, pos); + var forStatement = createNode(196 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(22 /* SemicolonToken */); if (token !== 22 /* SemicolonToken */ && token !== 17 /* CloseParenToken */) { @@ -9949,7 +10462,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 193 /* BreakStatement */ ? 66 /* BreakKeyword */ : 71 /* ContinueKeyword */); + parseExpected(kind === 200 /* BreakStatement */ ? 67 /* BreakKeyword */ : 72 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -9957,8 +10470,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(194 /* ReturnStatement */); - parseExpected(90 /* ReturnKeyword */); + var node = createNode(201 /* ReturnStatement */); + parseExpected(91 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -9966,8 +10479,8 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(195 /* WithStatement */); - parseExpected(101 /* WithKeyword */); + var node = createNode(202 /* WithStatement */); + parseExpected(102 /* WithKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(17 /* CloseParenToken */); @@ -9975,30 +10488,30 @@ var ts; return finishNode(node); } function parseCaseClause() { - var node = createNode(223 /* CaseClause */); - parseExpected(67 /* CaseKeyword */); + var node = createNode(238 /* CaseClause */); + parseExpected(68 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(51 /* ColonToken */); + parseExpected(52 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(224 /* DefaultClause */); - parseExpected(73 /* DefaultKeyword */); - parseExpected(51 /* ColonToken */); + var node = createNode(239 /* DefaultClause */); + parseExpected(74 /* DefaultKeyword */); + parseExpected(52 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token === 67 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token === 68 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(196 /* SwitchStatement */); - parseExpected(92 /* SwitchKeyword */); + var node = createNode(203 /* SwitchStatement */); + parseExpected(93 /* SwitchKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(17 /* CloseParenToken */); - var caseBlock = createNode(210 /* CaseBlock */, scanner.getStartPos()); + var caseBlock = createNode(217 /* CaseBlock */, scanner.getStartPos()); parseExpected(14 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(15 /* CloseBraceToken */); @@ -10013,29 +10526,29 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(198 /* ThrowStatement */); - parseExpected(94 /* ThrowKeyword */); + var node = createNode(205 /* ThrowStatement */); + parseExpected(95 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(199 /* TryStatement */); - parseExpected(96 /* TryKeyword */); + var node = createNode(206 /* TryStatement */); + parseExpected(97 /* TryKeyword */); node.tryBlock = parseBlock(false); - node.catchClause = token === 68 /* CatchKeyword */ ? parseCatchClause() : undefined; + node.catchClause = token === 69 /* CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. - if (!node.catchClause || token === 81 /* FinallyKeyword */) { - parseExpected(81 /* FinallyKeyword */); + if (!node.catchClause || token === 82 /* FinallyKeyword */) { + parseExpected(82 /* FinallyKeyword */); node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(226 /* CatchClause */); - parseExpected(68 /* CatchKeyword */); + var result = createNode(241 /* CatchClause */); + parseExpected(69 /* CatchKeyword */); if (parseExpected(16 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); } @@ -10044,8 +10557,8 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(200 /* DebuggerStatement */); - parseExpected(72 /* DebuggerKeyword */); + var node = createNode(207 /* DebuggerStatement */); + parseExpected(73 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } @@ -10055,26 +10568,30 @@ var ts; // a colon. var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 65 /* Identifier */ && parseOptional(51 /* ColonToken */)) { - var labeledStatement = createNode(197 /* LabeledStatement */, fullStart); + if (expression.kind === 66 /* Identifier */ && parseOptional(52 /* ColonToken */)) { + var labeledStatement = createNode(204 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return finishNode(labeledStatement); } else { - var expressionStatement = createNode(185 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(192 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return finishNode(expressionStatement); } } function isIdentifierOrKeyword() { - return token >= 65 /* Identifier */; + return token >= 66 /* Identifier */; } function nextTokenIsIdentifierOrKeywordOnSameLine() { nextToken(); return isIdentifierOrKeyword() && !scanner.hasPrecedingLineBreak(); } + function nextTokenIsFunctionKeywordOnSameLine() { + nextToken(); + return token === 84 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); return (isIdentifierOrKeyword() || token === 7 /* NumericLiteral */) && !scanner.hasPrecedingLineBreak(); @@ -10082,12 +10599,12 @@ var ts; function isDeclaration() { while (true) { switch (token) { - case 98 /* VarKeyword */: - case 104 /* LetKeyword */: - case 70 /* ConstKeyword */: - case 83 /* FunctionKeyword */: - case 69 /* ClassKeyword */: - case 77 /* EnumKeyword */: + case 99 /* VarKeyword */: + case 105 /* LetKeyword */: + case 71 /* ConstKeyword */: + case 84 /* FunctionKeyword */: + case 70 /* ClassKeyword */: + case 78 /* EnumKeyword */: return true; // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; // however, an identifier cannot be followed by another identifier on the same line. This is what we @@ -10110,34 +10627,36 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 103 /* InterfaceKeyword */: - case 125 /* TypeKeyword */: + case 104 /* InterfaceKeyword */: + case 129 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 118 /* ModuleKeyword */: - case 119 /* NamespaceKeyword */: + case 122 /* ModuleKeyword */: + case 123 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 115 /* DeclareKeyword */: + case 115 /* AsyncKeyword */: + case 119 /* DeclareKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 85 /* ImportKeyword */: + case 86 /* ImportKeyword */: nextToken(); - return token === 8 /* StringLiteral */ || token === 35 /* AsteriskToken */ || + return token === 8 /* StringLiteral */ || token === 36 /* AsteriskToken */ || token === 14 /* OpenBraceToken */ || isIdentifierOrKeyword(); - case 78 /* ExportKeyword */: + case 79 /* ExportKeyword */: nextToken(); - if (token === 53 /* EqualsToken */ || token === 35 /* AsteriskToken */ || - token === 14 /* OpenBraceToken */ || token === 73 /* DefaultKeyword */) { + if (token === 54 /* EqualsToken */ || token === 36 /* AsteriskToken */ || + token === 14 /* OpenBraceToken */ || token === 74 /* DefaultKeyword */) { return true; } continue; - case 108 /* PublicKeyword */: - case 106 /* PrivateKeyword */: - case 107 /* ProtectedKeyword */: - case 109 /* StaticKeyword */: + case 109 /* PublicKeyword */: + case 107 /* PrivateKeyword */: + case 108 /* ProtectedKeyword */: + case 110 /* StaticKeyword */: + case 112 /* AbstractKeyword */: nextToken(); continue; default: @@ -10150,46 +10669,47 @@ var ts; } function isStartOfStatement() { switch (token) { - case 52 /* AtToken */: + case 53 /* AtToken */: case 22 /* SemicolonToken */: case 14 /* OpenBraceToken */: - case 98 /* VarKeyword */: - case 104 /* LetKeyword */: - case 83 /* FunctionKeyword */: - case 69 /* ClassKeyword */: - case 77 /* EnumKeyword */: - case 84 /* IfKeyword */: - case 75 /* DoKeyword */: - case 100 /* WhileKeyword */: - case 82 /* ForKeyword */: - case 71 /* ContinueKeyword */: - case 66 /* BreakKeyword */: - case 90 /* ReturnKeyword */: - case 101 /* WithKeyword */: - case 92 /* SwitchKeyword */: - case 94 /* ThrowKeyword */: - case 96 /* TryKeyword */: - case 72 /* DebuggerKeyword */: + case 99 /* VarKeyword */: + case 105 /* LetKeyword */: + case 84 /* FunctionKeyword */: + case 70 /* ClassKeyword */: + case 78 /* EnumKeyword */: + case 85 /* IfKeyword */: + case 76 /* DoKeyword */: + case 101 /* WhileKeyword */: + case 83 /* ForKeyword */: + case 72 /* ContinueKeyword */: + case 67 /* BreakKeyword */: + case 91 /* ReturnKeyword */: + case 102 /* WithKeyword */: + case 93 /* SwitchKeyword */: + case 95 /* ThrowKeyword */: + case 97 /* TryKeyword */: + case 73 /* DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. - case 68 /* CatchKeyword */: - case 81 /* FinallyKeyword */: + case 69 /* CatchKeyword */: + case 82 /* FinallyKeyword */: return true; - case 70 /* ConstKeyword */: - case 78 /* ExportKeyword */: - case 85 /* ImportKeyword */: + case 71 /* ConstKeyword */: + case 79 /* ExportKeyword */: + case 86 /* ImportKeyword */: return isStartOfDeclaration(); - case 115 /* DeclareKeyword */: - case 103 /* InterfaceKeyword */: - case 118 /* ModuleKeyword */: - case 119 /* NamespaceKeyword */: - case 125 /* TypeKeyword */: + case 115 /* AsyncKeyword */: + case 119 /* DeclareKeyword */: + case 104 /* InterfaceKeyword */: + case 122 /* ModuleKeyword */: + case 123 /* NamespaceKeyword */: + case 129 /* TypeKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 108 /* PublicKeyword */: - case 106 /* PrivateKeyword */: - case 107 /* ProtectedKeyword */: - case 109 /* StaticKeyword */: + case 109 /* PublicKeyword */: + case 107 /* PrivateKeyword */: + case 108 /* ProtectedKeyword */: + case 110 /* StaticKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); @@ -10202,7 +10722,7 @@ var ts; return isIdentifier() || token === 14 /* OpenBraceToken */ || token === 18 /* OpenBracketToken */; } function isLetDeclaration() { - // In ES6 'let' always starts a lexical declaration if followed by an identifier or { + // In ES6 'let' always starts a lexical declaration if followed by an identifier or { // or [. return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); } @@ -10212,59 +10732,61 @@ var ts; return parseEmptyStatement(); case 14 /* OpenBraceToken */: return parseBlock(false); - case 98 /* VarKeyword */: + case 99 /* VarKeyword */: return parseVariableStatement(scanner.getStartPos(), undefined, undefined); - case 104 /* LetKeyword */: + case 105 /* LetKeyword */: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), undefined, undefined); } break; - case 83 /* FunctionKeyword */: + case 84 /* FunctionKeyword */: return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); - case 69 /* ClassKeyword */: + case 70 /* ClassKeyword */: return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); - case 84 /* IfKeyword */: + case 85 /* IfKeyword */: return parseIfStatement(); - case 75 /* DoKeyword */: + case 76 /* DoKeyword */: return parseDoStatement(); - case 100 /* WhileKeyword */: + case 101 /* WhileKeyword */: return parseWhileStatement(); - case 82 /* ForKeyword */: + case 83 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 71 /* ContinueKeyword */: - return parseBreakOrContinueStatement(192 /* ContinueStatement */); - case 66 /* BreakKeyword */: - return parseBreakOrContinueStatement(193 /* BreakStatement */); - case 90 /* ReturnKeyword */: + case 72 /* ContinueKeyword */: + return parseBreakOrContinueStatement(199 /* ContinueStatement */); + case 67 /* BreakKeyword */: + return parseBreakOrContinueStatement(200 /* BreakStatement */); + case 91 /* ReturnKeyword */: return parseReturnStatement(); - case 101 /* WithKeyword */: + case 102 /* WithKeyword */: return parseWithStatement(); - case 92 /* SwitchKeyword */: + case 93 /* SwitchKeyword */: return parseSwitchStatement(); - case 94 /* ThrowKeyword */: + case 95 /* ThrowKeyword */: return parseThrowStatement(); - case 96 /* TryKeyword */: + case 97 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. - case 68 /* CatchKeyword */: - case 81 /* FinallyKeyword */: + case 69 /* CatchKeyword */: + case 82 /* FinallyKeyword */: return parseTryStatement(); - case 72 /* DebuggerKeyword */: + case 73 /* DebuggerKeyword */: return parseDebuggerStatement(); - case 52 /* AtToken */: + case 53 /* AtToken */: return parseDeclaration(); - case 103 /* InterfaceKeyword */: - case 125 /* TypeKeyword */: - case 118 /* ModuleKeyword */: - case 119 /* NamespaceKeyword */: - case 115 /* DeclareKeyword */: - case 70 /* ConstKeyword */: - case 77 /* EnumKeyword */: - case 78 /* ExportKeyword */: - case 85 /* ImportKeyword */: - case 106 /* PrivateKeyword */: - case 107 /* ProtectedKeyword */: - case 108 /* PublicKeyword */: - case 109 /* StaticKeyword */: + case 115 /* AsyncKeyword */: + case 104 /* InterfaceKeyword */: + case 129 /* TypeKeyword */: + case 122 /* ModuleKeyword */: + case 123 /* NamespaceKeyword */: + case 119 /* DeclareKeyword */: + case 71 /* ConstKeyword */: + case 78 /* EnumKeyword */: + case 79 /* ExportKeyword */: + case 86 /* ImportKeyword */: + case 107 /* PrivateKeyword */: + case 108 /* ProtectedKeyword */: + case 109 /* PublicKeyword */: + case 112 /* AbstractKeyword */: + case 110 /* StaticKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -10277,35 +10799,35 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token) { - case 98 /* VarKeyword */: - case 104 /* LetKeyword */: - case 70 /* ConstKeyword */: + case 99 /* VarKeyword */: + case 105 /* LetKeyword */: + case 71 /* ConstKeyword */: return parseVariableStatement(fullStart, decorators, modifiers); - case 83 /* FunctionKeyword */: + case 84 /* FunctionKeyword */: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 69 /* ClassKeyword */: + case 70 /* ClassKeyword */: return parseClassDeclaration(fullStart, decorators, modifiers); - case 103 /* InterfaceKeyword */: + case 104 /* InterfaceKeyword */: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 125 /* TypeKeyword */: + case 129 /* TypeKeyword */: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 77 /* EnumKeyword */: + case 78 /* EnumKeyword */: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 118 /* ModuleKeyword */: - case 119 /* NamespaceKeyword */: + case 122 /* ModuleKeyword */: + case 123 /* NamespaceKeyword */: return parseModuleDeclaration(fullStart, decorators, modifiers); - case 85 /* ImportKeyword */: + case 86 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); - case 78 /* ExportKeyword */: + case 79 /* ExportKeyword */: nextToken(); - return token === 73 /* DefaultKeyword */ || token === 53 /* EqualsToken */ ? + return token === 74 /* DefaultKeyword */ || token === 54 /* EqualsToken */ ? parseExportAssignment(fullStart, decorators, modifiers) : parseExportDeclaration(fullStart, decorators, modifiers); default: if (decorators || modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration - // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var node = createMissingNode(221 /* MissingDeclaration */, true, ts.Diagnostics.Declaration_expected); + // would follow. For recovery and error reporting purposes, return an incomplete declaration. + var node = createMissingNode(228 /* MissingDeclaration */, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; setModifiers(node, modifiers); @@ -10317,49 +10839,49 @@ var ts; nextToken(); return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token === 8 /* StringLiteral */); } - function parseFunctionBlockOrSemicolon(isGenerator, diagnosticMessage) { + function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { if (token !== 14 /* OpenBraceToken */ && canParseSemicolon()) { parseSemicolon(); return; } - return parseFunctionBlock(isGenerator, false, diagnosticMessage); + return parseFunctionBlock(isGenerator, isAsync, false, diagnosticMessage); } // DECLARATIONS function parseArrayBindingElement() { if (token === 23 /* CommaToken */) { - return createNode(178 /* OmittedExpression */); + return createNode(184 /* OmittedExpression */); } - var node = createNode(155 /* BindingElement */); + var node = createNode(160 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(21 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); - node.initializer = parseInitializer(false); + node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(155 /* BindingElement */); + var node = createNode(160 /* BindingElement */); // TODO(andersh): Handle computed properties var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token !== 51 /* ColonToken */) { + if (tokenIsIdentifier && token !== 52 /* ColonToken */) { node.name = propertyName; } else { - parseExpected(51 /* ColonToken */); + parseExpected(52 /* ColonToken */); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } - node.initializer = parseInitializer(false); + node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(153 /* ObjectBindingPattern */); + var node = createNode(158 /* ObjectBindingPattern */); parseExpected(14 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(15 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(154 /* ArrayBindingPattern */); + var node = createNode(159 /* ArrayBindingPattern */); parseExpected(18 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(19 /* CloseBracketToken */); @@ -10378,7 +10900,7 @@ var ts; return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(201 /* VariableDeclaration */); + var node = createNode(208 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token)) { @@ -10387,15 +10909,15 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(202 /* VariableDeclarationList */); + var node = createNode(209 /* VariableDeclarationList */); switch (token) { - case 98 /* VarKeyword */: + case 99 /* VarKeyword */: break; - case 104 /* LetKeyword */: - node.flags |= 4096 /* Let */; + case 105 /* LetKeyword */: + node.flags |= 16384 /* Let */; break; - case 70 /* ConstKeyword */: - node.flags |= 8192 /* Const */; + case 71 /* ConstKeyword */: + node.flags |= 32768 /* Const */; break; default: ts.Debug.fail(); @@ -10410,7 +10932,7 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token === 127 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token === 131 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -10425,7 +10947,7 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 17 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(183 /* VariableStatement */, fullStart); + var node = createNode(190 /* VariableStatement */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.declarationList = parseVariableDeclarationList(false); @@ -10433,38 +10955,42 @@ var ts; return finishNode(node); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(203 /* FunctionDeclaration */, fullStart); + var node = createNode(210 /* FunctionDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(83 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(35 /* AsteriskToken */); - node.name = node.flags & 256 /* Default */ ? parseOptionalIdentifier() : parseIdentifier(); - fillSignature(51 /* ColonToken */, !!node.asteriskToken, false, node); - node.body = parseFunctionBlockOrSemicolon(!!node.asteriskToken, ts.Diagnostics.or_expected); + parseExpected(84 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(36 /* AsteriskToken */); + node.name = node.flags & 1024 /* Default */ ? parseOptionalIdentifier() : parseIdentifier(); + var isGenerator = !!node.asteriskToken; + var isAsync = !!(node.flags & 512 /* Async */); + fillSignature(52 /* ColonToken */, isGenerator, isAsync, false, node); + node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(137 /* Constructor */, pos); + var node = createNode(141 /* Constructor */, pos); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(114 /* ConstructorKeyword */); - fillSignature(51 /* ColonToken */, false, false, node); - node.body = parseFunctionBlockOrSemicolon(false, ts.Diagnostics.or_expected); + parseExpected(118 /* ConstructorKeyword */); + fillSignature(52 /* ColonToken */, 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(136 /* MethodDeclaration */, fullStart); + var method = createNode(140 /* MethodDeclaration */, fullStart); method.decorators = decorators; setModifiers(method, modifiers); method.asteriskToken = asteriskToken; method.name = name; method.questionToken = questionToken; - fillSignature(51 /* ColonToken */, !!asteriskToken, false, method); - method.body = parseFunctionBlockOrSemicolon(!!asteriskToken, diagnosticMessage); + var isGenerator = !!asteriskToken; + var isAsync = !!(method.flags & 512 /* Async */); + fillSignature(52 /* ColonToken */, isGenerator, isAsync, false, method); + method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return finishNode(method); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(134 /* PropertyDeclaration */, fullStart); + var property = createNode(138 /* PropertyDeclaration */, fullStart); property.decorators = decorators; setModifiers(property, modifiers); property.name = name; @@ -10481,16 +11007,16 @@ var ts; // The checker may still error in the static case to explicitly disallow the yield expression. property.initializer = modifiers && modifiers.flags & 128 /* Static */ ? allowInAnd(parseNonParameterInitializer) - : doOutsideOfContext(4 /* Yield */ | 2 /* DisallowIn */, parseNonParameterInitializer); + : doOutsideOfContext(2 /* Yield */ | 1 /* DisallowIn */, parseNonParameterInitializer); parseSemicolon(); return finishNode(property); } function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(35 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(36 /* AsteriskToken */); var name = parsePropertyName(); // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. - var questionToken = parseOptionalToken(50 /* QuestionToken */); + var questionToken = parseOptionalToken(51 /* QuestionToken */); if (asteriskToken || token === 16 /* OpenParenToken */ || token === 24 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } @@ -10506,16 +11032,16 @@ var ts; node.decorators = decorators; setModifiers(node, modifiers); node.name = parsePropertyName(); - fillSignature(51 /* ColonToken */, false, false, node); - node.body = parseFunctionBlockOrSemicolon(false); + fillSignature(52 /* ColonToken */, false, false, false, node); + node.body = parseFunctionBlockOrSemicolon(false, false); return finishNode(node); } function isClassMemberModifier(idToken) { switch (idToken) { - case 108 /* PublicKeyword */: - case 106 /* PrivateKeyword */: - case 107 /* ProtectedKeyword */: - case 109 /* StaticKeyword */: + case 109 /* PublicKeyword */: + case 107 /* PrivateKeyword */: + case 108 /* ProtectedKeyword */: + case 110 /* StaticKeyword */: return true; default: return false; @@ -10523,7 +11049,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token === 52 /* AtToken */) { + if (token === 53 /* AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -10540,7 +11066,7 @@ var ts; } nextToken(); } - if (token === 35 /* AsteriskToken */) { + if (token === 36 /* AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -10556,7 +11082,7 @@ var ts; // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 122 /* SetKeyword */ || idToken === 116 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 126 /* SetKeyword */ || idToken === 120 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along @@ -10564,9 +11090,9 @@ var ts; switch (token) { case 16 /* OpenParenToken */: // Method declaration case 24 /* LessThanToken */: // Generic Method declaration - case 51 /* ColonToken */: // Type Annotation for declaration - case 53 /* EqualsToken */: // Initializer for declaration - case 50 /* QuestionToken */: + case 52 /* ColonToken */: // Type Annotation for declaration + case 54 /* EqualsToken */: // Initializer for declaration + case 51 /* QuestionToken */: return true; default: // Covers @@ -10583,14 +11109,14 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(52 /* AtToken */)) { + if (!parseOptional(53 /* AtToken */)) { break; } if (!decorators) { decorators = []; decorators.pos = scanner.getStartPos(); } - var decorator = createNode(132 /* Decorator */, decoratorStart); + var decorator = createNode(136 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); decorators.push(finishNode(decorator)); } @@ -10621,9 +11147,25 @@ var ts; } return modifiers; } + function parseModifiersForArrowFunction() { + var flags = 0; + var modifiers; + if (token === 115 /* AsyncKeyword */) { + var modifierStart = scanner.getStartPos(); + var modifierKind = token; + nextToken(); + modifiers = []; + modifiers.pos = modifierStart; + flags |= ts.modifierToFlag(modifierKind); + modifiers.push(finishNode(createNode(modifierKind, modifierStart))); + modifiers.flags = flags; + modifiers.end = scanner.getStartPos(); + } + return modifiers; + } function parseClassElement() { if (token === 22 /* SemicolonToken */) { - var result = createNode(181 /* SemicolonClassElement */); + var result = createNode(188 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -10634,7 +11176,7 @@ var ts; if (accessor) { return accessor; } - if (token === 114 /* ConstructorKeyword */) { + if (token === 118 /* ConstructorKeyword */) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -10645,14 +11187,14 @@ var ts; if (isIdentifierOrKeyword() || token === 8 /* StringLiteral */ || token === 7 /* NumericLiteral */ || - token === 35 /* AsteriskToken */ || + token === 36 /* AsteriskToken */ || token === 18 /* OpenBracketToken */) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name_6 = createMissingNode(65 /* Identifier */, true, ts.Diagnostics.Declaration_expected); - return parsePropertyDeclaration(fullStart, decorators, modifiers, name_6, undefined); + var name_7 = createMissingNode(66 /* Identifier */, true, ts.Diagnostics.Declaration_expected); + return parsePropertyDeclaration(fullStart, decorators, modifiers, name_7, undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. ts.Debug.fail("Should not have attempted to parse class member declaration."); @@ -10661,26 +11203,23 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart*/ scanner.getStartPos(), /*decorators*/ undefined, - /*modifiers*/ undefined, 177 /* ClassExpression */); + /*modifiers*/ undefined, 183 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 204 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 211 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(69 /* ClassKeyword */); + parseExpected(70 /* ClassKeyword */); node.name = parseOptionalIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(true); if (parseExpected(14 /* OpenBraceToken */)) { - // ClassTail[Yield,GeneratorParameter] : See 14.5 - // [~GeneratorParameter]ClassHeritage[?Yield]opt { ClassBody[?Yield]opt } - // [+GeneratorParameter] ClassHeritageopt { ClassBodyopt } - node.members = inGeneratorParameterContext() - ? doOutsideOfYieldContext(parseClassMembers) - : parseClassMembers(); + // ClassTail[Yield,Await] : (Modified) See 14.5 + // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } + node.members = parseClassMembers(); parseExpected(15 /* CloseBraceToken */); } else { @@ -10689,22 +11228,19 @@ var ts; return finishNode(node); } function parseHeritageClauses(isClassHeritageClause) { - // ClassTail[Yield,GeneratorParameter] : See 14.5 - // [~GeneratorParameter]ClassHeritage[?Yield]opt { ClassBody[?Yield]opt } - // [+GeneratorParameter] ClassHeritageopt { ClassBodyopt } + // ClassTail[Yield,Await] : (Modified) See 14.5 + // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } if (isHeritageClause()) { - return isClassHeritageClause && inGeneratorParameterContext() - ? doOutsideOfYieldContext(parseHeritageClausesWorker) - : parseHeritageClausesWorker(); + return parseList(20 /* HeritageClauses */, parseHeritageClause); } return undefined; } function parseHeritageClausesWorker() { - return parseList(18 /* HeritageClauses */, parseHeritageClause); + return parseList(20 /* HeritageClauses */, parseHeritageClause); } function parseHeritageClause() { - if (token === 79 /* ExtendsKeyword */ || token === 102 /* ImplementsKeyword */) { - var node = createNode(225 /* HeritageClause */); + if (token === 80 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */) { + var node = createNode(240 /* HeritageClause */); node.token = token; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); @@ -10713,24 +11249,24 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(179 /* ExpressionWithTypeArguments */); + var node = createNode(185 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); if (token === 24 /* LessThanToken */) { - node.typeArguments = parseBracketedList(16 /* TypeArguments */, parseType, 24 /* LessThanToken */, 25 /* GreaterThanToken */); + node.typeArguments = parseBracketedList(18 /* TypeArguments */, parseType, 24 /* LessThanToken */, 26 /* GreaterThanToken */); } return finishNode(node); } function isHeritageClause() { - return token === 79 /* ExtendsKeyword */ || token === 102 /* ImplementsKeyword */; + return token === 80 /* ExtendsKeyword */ || token === 103 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(205 /* InterfaceDeclaration */, fullStart); + var node = createNode(212 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(103 /* InterfaceKeyword */); + parseExpected(104 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(false); @@ -10738,13 +11274,13 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(206 /* TypeAliasDeclaration */, fullStart); + var node = createNode(213 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(125 /* TypeKeyword */); + parseExpected(129 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(53 /* EqualsToken */); + parseExpected(54 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return finishNode(node); @@ -10754,16 +11290,16 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNode(229 /* EnumMember */, scanner.getStartPos()); + var node = createNode(244 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return finishNode(node); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(207 /* EnumDeclaration */, fullStart); + var node = createNode(214 /* EnumDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - parseExpected(77 /* EnumKeyword */); + parseExpected(78 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(14 /* OpenBraceToken */)) { node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); @@ -10775,7 +11311,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(209 /* ModuleBlock */, scanner.getStartPos()); + var node = createNode(216 /* ModuleBlock */, scanner.getStartPos()); if (parseExpected(14 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(15 /* CloseBraceToken */); @@ -10786,7 +11322,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(208 /* ModuleDeclaration */, fullStart); + var node = createNode(215 /* ModuleDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.flags |= flags; @@ -10797,7 +11333,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(208 /* ModuleDeclaration */, fullStart); + var node = createNode(215 /* ModuleDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); node.name = parseLiteralNode(true); @@ -10806,11 +11342,11 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = modifiers ? modifiers.flags : 0; - if (parseOptional(119 /* NamespaceKeyword */)) { - flags |= 32768 /* Namespace */; + if (parseOptional(123 /* NamespaceKeyword */)) { + flags |= 131072 /* Namespace */; } else { - parseExpected(118 /* ModuleKeyword */); + parseExpected(122 /* ModuleKeyword */); if (token === 8 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -10818,62 +11354,65 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token === 120 /* RequireKeyword */ && + return token === 124 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { return nextToken() === 16 /* OpenParenToken */; } + function nextTokenIsSlash() { + return nextToken() === 37 /* SlashToken */; + } function nextTokenIsCommaOrFromKeyword() { nextToken(); return token === 23 /* CommaToken */ || - token === 126 /* FromKeyword */; + token === 130 /* FromKeyword */; } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(85 /* ImportKeyword */); + parseExpected(86 /* ImportKeyword */); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token !== 23 /* CommaToken */ && token !== 126 /* FromKeyword */) { + if (token !== 23 /* CommaToken */ && token !== 130 /* FromKeyword */) { // ImportEquals declaration of type: // import x = require("mod"); or // import x = M.x; - var importEqualsDeclaration = createNode(211 /* ImportEqualsDeclaration */, fullStart); + var importEqualsDeclaration = createNode(218 /* ImportEqualsDeclaration */, fullStart); importEqualsDeclaration.decorators = decorators; setModifiers(importEqualsDeclaration, modifiers); importEqualsDeclaration.name = identifier; - parseExpected(53 /* EqualsToken */); + parseExpected(54 /* EqualsToken */); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(importEqualsDeclaration); } } // Import statement - var importDeclaration = createNode(212 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(219 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; setModifiers(importDeclaration, modifiers); // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; if (identifier || - token === 35 /* AsteriskToken */ || + token === 36 /* AsteriskToken */ || token === 14 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(126 /* FromKeyword */); + parseExpected(130 /* FromKeyword */); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } function parseImportClause(identifier, fullStart) { - //ImportClause: + // ImportClause: // ImportedDefaultBinding // NameSpaceImport // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(213 /* ImportClause */, fullStart); + var importClause = createNode(220 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -10883,7 +11422,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(23 /* CommaToken */)) { - importClause.namedBindings = token === 35 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(215 /* NamedImports */); + importClause.namedBindings = token === 36 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(222 /* NamedImports */); } return finishNode(importClause); } @@ -10893,8 +11432,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(222 /* ExternalModuleReference */); - parseExpected(120 /* RequireKeyword */); + var node = createNode(229 /* ExternalModuleReference */); + parseExpected(124 /* RequireKeyword */); parseExpected(16 /* OpenParenToken */); node.expression = parseModuleSpecifier(); parseExpected(17 /* CloseParenToken */); @@ -10915,9 +11454,9 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(214 /* NamespaceImport */); - parseExpected(35 /* AsteriskToken */); - parseExpected(111 /* AsKeyword */); + var namespaceImport = createNode(221 /* NamespaceImport */); + parseExpected(36 /* AsteriskToken */); + parseExpected(113 /* AsKeyword */); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } @@ -10930,14 +11469,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(19 /* ImportOrExportSpecifiers */, kind === 215 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 14 /* OpenBraceToken */, 15 /* CloseBraceToken */); + node.elements = parseBracketedList(21 /* ImportOrExportSpecifiers */, kind === 222 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 14 /* OpenBraceToken */, 15 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(220 /* ExportSpecifier */); + return parseImportOrExportSpecifier(227 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(216 /* ImportSpecifier */); + return parseImportOrExportSpecifier(223 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -10951,9 +11490,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token === 111 /* AsKeyword */) { + if (token === 113 /* AsKeyword */) { node.propertyName = identifierName; - parseExpected(111 /* AsKeyword */); + parseExpected(113 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -10962,23 +11501,23 @@ var ts; else { node.name = identifierName; } - if (kind === 216 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 223 /* ImportSpecifier */ && checkIdentifierIsKeyword) { // Report error identifier expected parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(218 /* ExportDeclaration */, fullStart); + var node = createNode(225 /* ExportDeclaration */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(35 /* AsteriskToken */)) { - parseExpected(126 /* FromKeyword */); + if (parseOptional(36 /* AsteriskToken */)) { + parseExpected(130 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(219 /* NamedExports */); - if (parseOptional(126 /* FromKeyword */)) { + node.exportClause = parseNamedImportsOrExports(226 /* NamedExports */); + if (parseOptional(130 /* FromKeyword */)) { node.moduleSpecifier = parseModuleSpecifier(); } } @@ -10986,21 +11525,21 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(217 /* ExportAssignment */, fullStart); + var node = createNode(224 /* ExportAssignment */, fullStart); node.decorators = decorators; setModifiers(node, modifiers); - if (parseOptional(53 /* EqualsToken */)) { + if (parseOptional(54 /* EqualsToken */)) { node.isExportEquals = true; } else { - parseExpected(73 /* DefaultKeyword */); + parseExpected(74 /* DefaultKeyword */); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); return finishNode(node); } function processReferenceComments(sourceFile) { - var triviaScanner = ts.createScanner(sourceFile.languageVersion, false, sourceText); + var triviaScanner = ts.createScanner(sourceFile.languageVersion, false, 0 /* Standard */, sourceText); var referencedFiles = []; var amdDependencies = []; var amdModuleName; @@ -11059,10 +11598,10 @@ var ts; function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return node.flags & 1 /* Export */ - || node.kind === 211 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 222 /* ExternalModuleReference */ - || node.kind === 212 /* ImportDeclaration */ - || node.kind === 217 /* ExportAssignment */ - || node.kind === 218 /* ExportDeclaration */ + || node.kind === 218 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 229 /* ExternalModuleReference */ + || node.kind === 219 /* ImportDeclaration */ + || node.kind === 224 /* ExportAssignment */ + || node.kind === 225 /* ExportDeclaration */ ? node : undefined; }); @@ -11082,18 +11621,20 @@ var ts; ParsingContext[ParsingContext["ArrayBindingElements"] = 10] = "ArrayBindingElements"; ParsingContext[ParsingContext["ArgumentExpressions"] = 11] = "ArgumentExpressions"; ParsingContext[ParsingContext["ObjectLiteralMembers"] = 12] = "ObjectLiteralMembers"; - ParsingContext[ParsingContext["ArrayLiteralMembers"] = 13] = "ArrayLiteralMembers"; - ParsingContext[ParsingContext["Parameters"] = 14] = "Parameters"; - ParsingContext[ParsingContext["TypeParameters"] = 15] = "TypeParameters"; - ParsingContext[ParsingContext["TypeArguments"] = 16] = "TypeArguments"; - ParsingContext[ParsingContext["TupleElementTypes"] = 17] = "TupleElementTypes"; - ParsingContext[ParsingContext["HeritageClauses"] = 18] = "HeritageClauses"; - ParsingContext[ParsingContext["ImportOrExportSpecifiers"] = 19] = "ImportOrExportSpecifiers"; - ParsingContext[ParsingContext["JSDocFunctionParameters"] = 20] = "JSDocFunctionParameters"; - ParsingContext[ParsingContext["JSDocTypeArguments"] = 21] = "JSDocTypeArguments"; - ParsingContext[ParsingContext["JSDocRecordMembers"] = 22] = "JSDocRecordMembers"; - ParsingContext[ParsingContext["JSDocTupleTypes"] = 23] = "JSDocTupleTypes"; - ParsingContext[ParsingContext["Count"] = 24] = "Count"; // Number of parsing contexts + ParsingContext[ParsingContext["JsxAttributes"] = 13] = "JsxAttributes"; + ParsingContext[ParsingContext["JsxChildren"] = 14] = "JsxChildren"; + ParsingContext[ParsingContext["ArrayLiteralMembers"] = 15] = "ArrayLiteralMembers"; + ParsingContext[ParsingContext["Parameters"] = 16] = "Parameters"; + ParsingContext[ParsingContext["TypeParameters"] = 17] = "TypeParameters"; + ParsingContext[ParsingContext["TypeArguments"] = 18] = "TypeArguments"; + ParsingContext[ParsingContext["TupleElementTypes"] = 19] = "TupleElementTypes"; + ParsingContext[ParsingContext["HeritageClauses"] = 20] = "HeritageClauses"; + ParsingContext[ParsingContext["ImportOrExportSpecifiers"] = 21] = "ImportOrExportSpecifiers"; + ParsingContext[ParsingContext["JSDocFunctionParameters"] = 22] = "JSDocFunctionParameters"; + ParsingContext[ParsingContext["JSDocTypeArguments"] = 23] = "JSDocTypeArguments"; + ParsingContext[ParsingContext["JSDocRecordMembers"] = 24] = "JSDocRecordMembers"; + ParsingContext[ParsingContext["JSDocTupleTypes"] = 25] = "JSDocTupleTypes"; + ParsingContext[ParsingContext["Count"] = 26] = "Count"; // Number of parsing contexts })(ParsingContext || (ParsingContext = {})); var Tristate; (function (Tristate) { @@ -11105,16 +11646,16 @@ var ts; (function (JSDocParser) { function isJSDocType() { switch (token) { - case 35 /* AsteriskToken */: - case 50 /* QuestionToken */: + case 36 /* AsteriskToken */: + case 51 /* QuestionToken */: case 16 /* OpenParenToken */: case 18 /* OpenBracketToken */: - case 46 /* ExclamationToken */: + case 47 /* ExclamationToken */: case 14 /* OpenBraceToken */: - case 83 /* FunctionKeyword */: + case 84 /* FunctionKeyword */: case 21 /* DotDotDotToken */: - case 88 /* NewKeyword */: - case 93 /* ThisKeyword */: + case 89 /* NewKeyword */: + case 94 /* ThisKeyword */: return true; } return isIdentifierOrKeyword(); @@ -11135,7 +11676,7 @@ var ts; scanner.setText(sourceText, start, length); // Prime the first token for us to start processing. token = nextToken(); - var result = createNode(231 /* JSDocTypeExpression */); + var result = createNode(246 /* JSDocTypeExpression */); parseExpected(14 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); parseExpected(15 /* CloseBraceToken */); @@ -11145,13 +11686,13 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token === 44 /* BarToken */) { - var unionType = createNode(235 /* JSDocUnionType */, type.pos); + if (token === 45 /* BarToken */) { + var unionType = createNode(250 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token === 53 /* EqualsToken */) { - var optionalType = createNode(242 /* JSDocOptionalType */, type.pos); + if (token === 54 /* EqualsToken */) { + var optionalType = createNode(257 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -11162,20 +11703,20 @@ var ts; var type = parseBasicTypeExpression(); while (true) { if (token === 18 /* OpenBracketToken */) { - var arrayType = createNode(234 /* JSDocArrayType */, type.pos); + var arrayType = createNode(249 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); parseExpected(19 /* CloseBracketToken */); type = finishNode(arrayType); } - else if (token === 50 /* QuestionToken */) { - var nullableType = createNode(237 /* JSDocNullableType */, type.pos); + else if (token === 51 /* QuestionToken */) { + var nullableType = createNode(252 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token === 46 /* ExclamationToken */) { - var nonNullableType = createNode(238 /* JSDocNonNullableType */, type.pos); + else if (token === 47 /* ExclamationToken */) { + var nonNullableType = createNode(253 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -11188,82 +11729,82 @@ var ts; } function parseBasicTypeExpression() { switch (token) { - case 35 /* AsteriskToken */: + case 36 /* AsteriskToken */: return parseJSDocAllType(); - case 50 /* QuestionToken */: + case 51 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); case 16 /* OpenParenToken */: return parseJSDocUnionType(); case 18 /* OpenBracketToken */: return parseJSDocTupleType(); - case 46 /* ExclamationToken */: + case 47 /* ExclamationToken */: return parseJSDocNonNullableType(); case 14 /* OpenBraceToken */: return parseJSDocRecordType(); - case 83 /* FunctionKeyword */: + case 84 /* FunctionKeyword */: return parseJSDocFunctionType(); case 21 /* DotDotDotToken */: return parseJSDocVariadicType(); - case 88 /* NewKeyword */: + case 89 /* NewKeyword */: return parseJSDocConstructorType(); - case 93 /* ThisKeyword */: + case 94 /* ThisKeyword */: return parseJSDocThisType(); - case 112 /* AnyKeyword */: - case 123 /* StringKeyword */: - case 121 /* NumberKeyword */: - case 113 /* BooleanKeyword */: - case 124 /* SymbolKeyword */: - case 99 /* VoidKeyword */: + case 114 /* AnyKeyword */: + case 127 /* StringKeyword */: + case 125 /* NumberKeyword */: + case 117 /* BooleanKeyword */: + case 128 /* SymbolKeyword */: + case 100 /* VoidKeyword */: return parseTokenNode(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(246 /* JSDocThisType */); + var result = createNode(261 /* JSDocThisType */); nextToken(); - parseExpected(51 /* ColonToken */); + parseExpected(52 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(245 /* JSDocConstructorType */); + var result = createNode(260 /* JSDocConstructorType */); nextToken(); - parseExpected(51 /* ColonToken */); + parseExpected(52 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(244 /* JSDocVariadicType */); + var result = createNode(259 /* JSDocVariadicType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(243 /* JSDocFunctionType */); + var result = createNode(258 /* JSDocFunctionType */); nextToken(); parseExpected(16 /* OpenParenToken */); - result.parameters = parseDelimitedList(20 /* JSDocFunctionParameters */, parseJSDocParameter); + result.parameters = parseDelimitedList(22 /* JSDocFunctionParameters */, parseJSDocParameter); checkForTrailingComma(result.parameters); parseExpected(17 /* CloseParenToken */); - if (token === 51 /* ColonToken */) { + if (token === 52 /* ColonToken */) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(131 /* Parameter */); + var parameter = createNode(135 /* Parameter */); parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocOptionalType(type) { - var result = createNode(242 /* JSDocOptionalType */, type.pos); + var result = createNode(257 /* JSDocOptionalType */, type.pos); nextToken(); result.type = type; return finishNode(result); } function parseJSDocTypeReference() { - var result = createNode(241 /* JSDocTypeReference */); + var result = createNode(256 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); while (parseOptional(20 /* DotToken */)) { if (token === 24 /* LessThanToken */) { @@ -11279,10 +11820,10 @@ var ts; function parseTypeArguments() { // Move past the < nextToken(); - var typeArguments = parseDelimitedList(21 /* JSDocTypeArguments */, parseJSDocType); + var typeArguments = parseDelimitedList(23 /* JSDocTypeArguments */, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); - parseExpected(25 /* GreaterThanToken */); + parseExpected(26 /* GreaterThanToken */); return typeArguments; } function checkForEmptyTypeArgumentList(typeArguments) { @@ -11293,38 +11834,38 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(128 /* QualifiedName */, left.pos); + var result = createNode(132 /* QualifiedName */, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(239 /* JSDocRecordType */); + var result = createNode(254 /* JSDocRecordType */); nextToken(); - result.members = parseDelimitedList(22 /* JSDocRecordMembers */, parseJSDocRecordMember); + result.members = parseDelimitedList(24 /* JSDocRecordMembers */, parseJSDocRecordMember); checkForTrailingComma(result.members); parseExpected(15 /* CloseBraceToken */); return finishNode(result); } function parseJSDocRecordMember() { - var result = createNode(240 /* JSDocRecordMember */); + var result = createNode(255 /* JSDocRecordMember */); result.name = parseSimplePropertyName(); - if (token === 51 /* ColonToken */) { + if (token === 52 /* ColonToken */) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(238 /* JSDocNonNullableType */); + var result = createNode(253 /* JSDocNonNullableType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(236 /* JSDocTupleType */); + var result = createNode(251 /* JSDocTupleType */); nextToken(); - result.types = parseDelimitedList(23 /* JSDocTupleTypes */, parseJSDocType); + result.types = parseDelimitedList(25 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); parseExpected(19 /* CloseBracketToken */); return finishNode(result); @@ -11336,7 +11877,7 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(235 /* JSDocUnionType */); + var result = createNode(250 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); parseExpected(17 /* CloseParenToken */); @@ -11347,14 +11888,14 @@ var ts; var types = []; types.pos = firstType.pos; types.push(firstType); - while (parseOptional(44 /* BarToken */)) { + while (parseOptional(45 /* BarToken */)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); return types; } function parseJSDocAllType() { - var result = createNode(232 /* JSDocAllType */); + var result = createNode(247 /* JSDocAllType */); nextToken(); return finishNode(result); } @@ -11374,14 +11915,14 @@ var ts; if (token === 23 /* CommaToken */ || token === 15 /* CloseBraceToken */ || token === 17 /* CloseParenToken */ || - token === 25 /* GreaterThanToken */ || - token === 53 /* EqualsToken */ || - token === 44 /* BarToken */) { - var result = createNode(233 /* JSDocUnknownType */, pos); + token === 26 /* GreaterThanToken */ || + token === 54 /* EqualsToken */ || + token === 45 /* BarToken */) { + var result = createNode(248 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(237 /* JSDocNullableType */, pos); + var result = createNode(252 /* JSDocNullableType */, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -11413,8 +11954,8 @@ var ts; ts.Debug.assert(end <= content.length); var tags; var pos; - // NOTE(cyrusn): This is essentially a handwritten scanner for JSDocComments. I - // considered using an actual Scanner, but this would complicate things. The + // NOTE(cyrusn): This is essentially a handwritten scanner for JSDocComments. I + // considered using an actual Scanner, but this would complicate things. The // scanner would need to know it was in a Doc Comment. Otherwise, it would then // produce comments *inside* the doc comment. In the end it was just easier to // write a simple scanner rather than go that route. @@ -11469,7 +12010,7 @@ var ts; if (!tags) { return undefined; } - var result = createNode(247 /* JSDocComment */, start); + var result = createNode(262 /* JSDocComment */, start); result.tags = tags; return finishNode(result, end); } @@ -11480,9 +12021,8 @@ var ts; } function parseTag() { ts.Debug.assert(content.charCodeAt(pos - 1) === 64 /* at */); - var atToken = createNode(52 /* AtToken */, pos - 1); + var atToken = createNode(53 /* AtToken */, pos - 1); atToken.end = pos; - var startPos = pos; var tagName = scanIdentifier(); if (!tagName) { return; @@ -11507,7 +12047,7 @@ var ts; return undefined; } function handleUnknownTag(atToken, tagName) { - var result = createNode(248 /* JSDocTag */, atToken.pos); + var result = createNode(263 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result, pos); @@ -11559,7 +12099,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(249 /* JSDocParameterTag */, atToken.pos); + var result = createNode(264 /* JSDocParameterTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -11569,27 +12109,27 @@ var ts; return finishNode(result, pos); } function handleReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 250 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 265 /* JSDocReturnTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(250 /* JSDocReturnTag */, atToken.pos); + var result = createNode(265 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 251 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 266 /* JSDocTypeTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(251 /* JSDocTypeTag */, atToken.pos); + var result = createNode(266 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result, pos); } function handleTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 252 /* JSDocTemplateTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 267 /* JSDocTemplateTag */; })) { parseErrorAtPosition(tagName.pos, pos - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = []; @@ -11597,13 +12137,13 @@ var ts; while (true) { skipWhitespace(); var startPos = pos; - var name_7 = scanIdentifier(); - if (!name_7) { + var name_8 = scanIdentifier(); + if (!name_8) { parseErrorAtPosition(startPos, 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(130 /* TypeParameter */, name_7.pos); - typeParameter.name = name_7; + var typeParameter = createNode(134 /* TypeParameter */, name_8.pos); + typeParameter.name = name_8; finishNode(typeParameter, pos); typeParameters.push(typeParameter); skipWhitespace(); @@ -11613,7 +12153,7 @@ var ts; pos++; } typeParameters.end = pos; - var result = createNode(252 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(267 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -11634,7 +12174,7 @@ var ts; if (startPos === pos) { return undefined; } - var result = createNode(65 /* Identifier */, startPos); + var result = createNode(66 /* Identifier */, startPos); result.text = content.substring(startPos, pos); return finishNode(result, pos); } @@ -11723,8 +12263,9 @@ var ts; } return; function visitNode(node) { + var text = ''; if (aggressiveChecks && shouldCheckNode(node)) { - var text = oldText.substring(node.pos, node.end); + text = oldText.substring(node.pos, node.end); } // Ditch any existing LS children we may have created. This way we can avoid // moving them forward. @@ -11756,7 +12297,7 @@ var ts; switch (node.kind) { case 8 /* StringLiteral */: case 7 /* NumericLiteral */: - case 65 /* Identifier */: + case 66 /* Identifier */: return true; } return false; @@ -12135,6 +12676,16 @@ var ts; } ts.getSymbolId = getSymbolId; function createTypeChecker(host, produceDiagnostics) { + // Cancellation that controls whether or not we can cancel in the middle of type checking. + // In general cancelling is *not* safe for the type checker. We might be in the middle of + // computing something, and we will leave our internals in an inconsistent state. Callers + // who set the cancellation token should catch if a cancellation exception occurs, and + // should throw away and create a new TypeChecker. + // + // Currently we only support setting the cancellation token when getting diagnostics. This + // is because diagnostics can be quite expensive, and we want to allow hosts to bail out if + // they no longer need the information (for example, if the user started editing again). + var cancellationToken; var Symbol = ts.objectAllocator.getSymbolConstructor(); var Type = ts.objectAllocator.getTypeConstructor(); var Signature = ts.objectAllocator.getSignatureConstructor(); @@ -12180,7 +12731,9 @@ var ts; isImplementationOfOverload: isImplementationOfOverload, getAliasedSymbol: resolveAlias, getEmitResolver: getEmitResolver, - getExportsOfModule: getExportsOfModuleAsArray + getExportsOfModule: getExportsOfModuleAsArray, + getJsxElementAttributesType: getJsxElementAttributesType, + getJsxIntrinsicTagNames: getJsxIntrinsicTagNames }; var unknownSymbol = createSymbol(4 /* Property */ | 67108864 /* Transient */, "unknown"); var resolvingSymbol = createSymbol(67108864 /* Transient */, "__resolving__"); @@ -12188,10 +12741,10 @@ var ts; var stringType = createIntrinsicType(2 /* String */, "string"); var numberType = createIntrinsicType(4 /* Number */, "number"); var booleanType = createIntrinsicType(8 /* Boolean */, "boolean"); - var esSymbolType = createIntrinsicType(2097152 /* ESSymbol */, "symbol"); + var esSymbolType = createIntrinsicType(4194304 /* ESSymbol */, "symbol"); var voidType = createIntrinsicType(16 /* Void */, "void"); - var undefinedType = createIntrinsicType(32 /* Undefined */ | 524288 /* ContainsUndefinedOrNull */, "undefined"); - var nullType = createIntrinsicType(64 /* Null */ | 524288 /* ContainsUndefinedOrNull */, "null"); + var undefinedType = createIntrinsicType(32 /* Undefined */ | 1048576 /* ContainsUndefinedOrNull */, "undefined"); + var nullType = createIntrinsicType(64 /* Null */ | 1048576 /* ContainsUndefinedOrNull */, "null"); var unknownType = createIntrinsicType(1 /* Any */, "unknown"); var circularType = createIntrinsicType(1 /* Any */, "__circular__"); var emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); @@ -12203,6 +12756,7 @@ var ts; var unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, undefined, 0, false, false); var globals = {}; var globalESSymbolConstructorSymbol; + var getGlobalPromiseConstructorSymbol; var globalObjectType; var globalFunctionType; var globalArrayType; @@ -12212,23 +12766,40 @@ var ts; var globalRegExpType; var globalTemplateStringsArrayType; var globalESSymbolType; + var jsxElementType; + /** Lazily loaded, use getJsxIntrinsicElementType() */ + var jsxIntrinsicElementsType; var globalIterableType; var globalIteratorType; var globalIterableIteratorType; var anyArrayType; + var getGlobalClassDecoratorType; + var getGlobalParameterDecoratorType; + var getGlobalPropertyDecoratorType; + var getGlobalMethodDecoratorType; var getGlobalTypedPropertyDescriptorType; + var getGlobalPromiseType; + var tryGetGlobalPromiseType; + var getGlobalPromiseLikeType; + var getInstantiatedGlobalPromiseLikeType; + var getGlobalPromiseConstructorLikeType; + var getGlobalThenableType; var tupleTypes = {}; var unionTypes = {}; + var intersectionTypes = {}; var stringLiteralTypes = {}; var emitExtends = false; var emitDecorate = false; var emitParam = false; + var emitAwaiter = false; + var emitGenerator = false; var resolutionTargets = []; var resolutionResults = []; var mergedSymbols = []; var symbolLinks = []; var nodeLinks = []; var potentialThisCollisions = []; + var awaitedTypeStack = []; var diagnostics = ts.createDiagnosticCollection(); var primitiveTypeInfo = { "string": { @@ -12245,18 +12816,25 @@ var ts; }, "symbol": { type: esSymbolType, - flags: 2097152 /* ESSymbol */ + flags: 4194304 /* ESSymbol */ } }; + var JsxNames = { + JSX: "JSX", + IntrinsicElements: "IntrinsicElements", + ElementClass: "ElementClass", + ElementAttributesPropertyNameContainer: "ElementAttributesProperty", + Element: "Element" + }; var subtypeRelation = {}; var assignableRelation = {}; var identityRelation = {}; initializeTypeChecker(); return checker; - function getEmitResolver(sourceFile) { + function getEmitResolver(sourceFile, cancellationToken) { // Ensure we have all the type information in place for this file so that all the // emitter questions of this resolver will return the right information. - getDiagnostics(sourceFile); + getDiagnostics(sourceFile, cancellationToken); return emitResolver; } function error(location, message, arg0, arg1, arg2) { @@ -12281,9 +12859,9 @@ var ts; if (flags & 16 /* Function */) result |= 106927 /* FunctionExcludes */; if (flags & 32 /* Class */) - result |= 899583 /* ClassExcludes */; + result |= 899519 /* ClassExcludes */; if (flags & 64 /* Interface */) - result |= 792992 /* InterfaceExcludes */; + result |= 792960 /* InterfaceExcludes */; if (flags & 256 /* RegularEnum */) result |= 899327 /* RegularEnumExcludes */; if (flags & 128 /* ConstEnum */) @@ -12395,10 +12973,10 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 230 /* SourceFile */); + return ts.getAncestor(node, 245 /* SourceFile */); } function isGlobalSourceFile(node) { - return node.kind === 230 /* SourceFile */ && !ts.isExternalModule(node); + return node.kind === 245 /* SourceFile */ && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { @@ -12455,13 +13033,13 @@ var ts; } } switch (location.kind) { - case 230 /* SourceFile */: + case 245 /* SourceFile */: if (!ts.isExternalModule(location)) break; - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 230 /* SourceFile */ || - (location.kind === 208 /* ModuleDeclaration */ && location.name.kind === 8 /* StringLiteral */)) { + if (location.kind === 245 /* SourceFile */ || + (location.kind === 215 /* ModuleDeclaration */ && location.name.kind === 8 /* StringLiteral */)) { // It's an external module. Because of module/namespace merging, a module's exports are in scope, // yet we never want to treat an export specifier as putting a member in scope. Therefore, // if the name we find is purely an export specifier, it is not actually considered in scope. @@ -12475,7 +13053,7 @@ var ts; // which is not the desired behavior. if (ts.hasProperty(moduleExports, name) && moduleExports[name].flags === 8388608 /* Alias */ && - ts.getDeclarationOfKind(moduleExports[name], 220 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExports[name], 227 /* ExportSpecifier */)) { break; } result = moduleExports["default"]; @@ -12489,13 +13067,13 @@ var ts; break loop; } break; - case 207 /* EnumDeclaration */: + case 214 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -12512,9 +13090,9 @@ var ts; } } break; - case 204 /* ClassDeclaration */: - case 177 /* ClassExpression */: - case 205 /* InterfaceDeclaration */: + case 211 /* ClassDeclaration */: + case 183 /* ClassExpression */: + case 212 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793056 /* Type */)) { if (lastLocation && lastLocation.flags & 128 /* Static */) { // TypeScript 1.0 spec (April 2014): 3.4.1 @@ -12525,7 +13103,7 @@ var ts; } break loop; } - if (location.kind === 177 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 183 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -12541,9 +13119,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 129 /* ComputedPropertyName */: + case 133 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 205 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 212 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793056 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -12551,19 +13129,19 @@ var ts; } } break; - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 137 /* Constructor */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 203 /* FunctionDeclaration */: - case 166 /* ArrowFunction */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 141 /* Constructor */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 210 /* FunctionDeclaration */: + case 171 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 165 /* FunctionExpression */: + case 170 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -12576,8 +13154,8 @@ var ts; } } break; - case 132 /* Decorator */: - // Decorators are resolved at the class declaration. Resolving at the parameter + case 136 /* Decorator */: + // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // // function y() {} @@ -12585,7 +13163,7 @@ var ts; // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. // } // - if (location.parent && location.parent.kind === 131 /* Parameter */) { + if (location.parent && location.parent.kind === 135 /* Parameter */) { location = location.parent; } // @@ -12641,16 +13219,16 @@ var ts; // for (let x in x) // for (let x of x) // climb up to the variable declaration skipping binding patterns - var variableDeclaration = ts.getAncestor(declaration, 201 /* VariableDeclaration */); + var variableDeclaration = ts.getAncestor(declaration, 208 /* VariableDeclaration */); var container = ts.getEnclosingBlockScopeContainer(variableDeclaration); - if (variableDeclaration.parent.parent.kind === 183 /* VariableStatement */ || - variableDeclaration.parent.parent.kind === 189 /* ForStatement */) { + if (variableDeclaration.parent.parent.kind === 190 /* VariableStatement */ || + variableDeclaration.parent.parent.kind === 196 /* ForStatement */) { // variable statement/for statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, variableDeclaration, container); } - else if (variableDeclaration.parent.parent.kind === 191 /* ForOfStatement */ || - variableDeclaration.parent.parent.kind === 190 /* ForInStatement */) { + else if (variableDeclaration.parent.parent.kind === 198 /* ForOfStatement */ || + variableDeclaration.parent.parent.kind === 197 /* ForInStatement */) { // ForIn/ForOf case - use site should not be used in expression part var expression = variableDeclaration.parent.parent.expression; isUsedBeforeDeclaration = isSameScopeDescendentOf(errorLocation, expression, container); @@ -12677,10 +13255,10 @@ var ts; } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 211 /* ImportEqualsDeclaration */) { + if (node.kind === 218 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 212 /* ImportDeclaration */) { + while (node && node.kind !== 219 /* ImportDeclaration */) { node = node.parent; } return node; @@ -12690,7 +13268,7 @@ var ts; return ts.forEach(symbol.declarations, function (d) { return ts.isAliasSymbolDeclaration(d) ? d : undefined; }); } function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 222 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 229 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, node); @@ -12770,15 +13348,15 @@ var ts; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); if (targetSymbol) { - var name_8 = specifier.propertyName || specifier.name; - if (name_8.text) { - var symbolFromModule = getExportOfModule(targetSymbol, name_8.text); - var symbolFromVariable = getPropertyOfVariable(targetSymbol, name_8.text); + var name_9 = specifier.propertyName || specifier.name; + if (name_9.text) { + var symbolFromModule = getExportOfModule(targetSymbol, name_9.text); + var symbolFromVariable = getPropertyOfVariable(targetSymbol, name_9.text); var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable; if (!symbol) { - error(name_8, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_8)); + error(name_9, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_9)); } return symbol; } @@ -12797,17 +13375,17 @@ var ts; } function getTargetOfAliasDeclaration(node) { switch (node.kind) { - case 211 /* ImportEqualsDeclaration */: + case 218 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node); - case 213 /* ImportClause */: + case 220 /* ImportClause */: return getTargetOfImportClause(node); - case 214 /* NamespaceImport */: + case 221 /* NamespaceImport */: return getTargetOfNamespaceImport(node); - case 216 /* ImportSpecifier */: + case 223 /* ImportSpecifier */: return getTargetOfImportSpecifier(node); - case 220 /* ExportSpecifier */: + case 227 /* ExportSpecifier */: return getTargetOfExportSpecifier(node); - case 217 /* ExportAssignment */: + case 224 /* ExportAssignment */: return getTargetOfExportAssignment(node); } } @@ -12852,11 +13430,11 @@ var ts; if (!links.referenced) { links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); - if (node.kind === 217 /* ExportAssignment */) { + if (node.kind === 224 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 220 /* ExportSpecifier */) { + else if (node.kind === 227 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -12869,7 +13447,7 @@ var ts; // This function is only for imports with entity names function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 211 /* ImportEqualsDeclaration */); + importDeclaration = ts.getAncestor(entityName, 218 /* ImportEqualsDeclaration */); ts.Debug.assert(importDeclaration !== undefined); } // There are three things we might try to look for. In the following examples, @@ -12878,17 +13456,17 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 65 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 66 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 65 /* Identifier */ || entityName.parent.kind === 128 /* QualifiedName */) { + if (entityName.kind === 66 /* Identifier */ || entityName.parent.kind === 132 /* QualifiedName */) { return resolveEntityName(entityName, 1536 /* Namespace */); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 211 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 218 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */); } } @@ -12896,28 +13474,30 @@ var ts; return symbol.parent ? getFullyQualifiedName(symbol.parent) + "." + symbolToString(symbol) : symbolToString(symbol); } // Resolves a qualified name and any involved aliases - function resolveEntityName(name, meaning) { + function resolveEntityName(name, meaning, ignoreErrors) { if (ts.nodeIsMissing(name)) { return undefined; } var symbol; - if (name.kind === 65 /* Identifier */) { + if (name.kind === 66 /* Identifier */) { var message = meaning === 1536 /* Namespace */ ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; - symbol = resolveName(name, name.text, meaning, message, name); + symbol = resolveName(name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 128 /* QualifiedName */ || name.kind === 158 /* PropertyAccessExpression */) { - var left = name.kind === 128 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 128 /* QualifiedName */ ? name.right : name.name; - var namespace = resolveEntityName(left, 1536 /* Namespace */); + else if (name.kind === 132 /* QualifiedName */ || name.kind === 163 /* PropertyAccessExpression */) { + var left = name.kind === 132 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 132 /* QualifiedName */ ? name.right : name.name; + var namespace = resolveEntityName(left, 1536 /* Namespace */, ignoreErrors); if (!namespace || namespace === unknownSymbol || ts.nodeIsMissing(right)) { return undefined; } symbol = getSymbol(getExportsOfSymbol(namespace), right.text, meaning); if (!symbol) { - error(right, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(namespace), ts.declarationNameToString(right)); + if (!ignoreErrors) { + error(right, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(namespace), ts.declarationNameToString(right)); + } return undefined; } } @@ -13071,7 +13651,7 @@ var ts; var members = node.members; for (var _i = 0; _i < members.length; _i++) { var member = members[_i]; - if (member.kind === 137 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 141 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -13129,7 +13709,7 @@ var ts; return type; } function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexType, numberIndexType) { - return setObjectTypeMembers(createObjectType(32768 /* Anonymous */, symbol), members, callSignatures, constructSignatures, stringIndexType, numberIndexType); + return setObjectTypeMembers(createObjectType(65536 /* Anonymous */, symbol), members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; @@ -13141,17 +13721,17 @@ var ts; } } switch (location_1.kind) { - case 230 /* SourceFile */: + case 245 /* SourceFile */: if (!ts.isExternalModule(location_1)) { break; } - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location_1).exports)) { return result; } break; - case 204 /* ClassDeclaration */: - case 205 /* InterfaceDeclaration */: + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: if (result = callback(getSymbolOfNode(location_1).members)) { return result; } @@ -13190,7 +13770,9 @@ var ts; } // Check if symbol is any of the alias return ts.forEachValue(symbols, function (symbolFromSymbolTable) { - if (symbolFromSymbolTable.flags & 8388608 /* Alias */ && symbolFromSymbolTable.name !== "export=") { + if (symbolFromSymbolTable.flags & 8388608 /* Alias */ + && symbolFromSymbolTable.name !== "export=" + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 227 /* ExportSpecifier */)) { if (!useOnlyExternalAliasing || // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { @@ -13227,7 +13809,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 227 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -13300,8 +13882,8 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 208 /* ModuleDeclaration */ && declaration.name.kind === 8 /* StringLiteral */) || - (declaration.kind === 230 /* SourceFile */ && ts.isExternalModule(declaration)); + return (declaration.kind === 215 /* ModuleDeclaration */ && declaration.name.kind === 8 /* StringLiteral */) || + (declaration.kind === 245 /* SourceFile */ && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -13337,12 +13919,12 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 147 /* TypeQuery */) { + if (entityName.parent.kind === 151 /* TypeQuery */) { // Typeof value meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 128 /* QualifiedName */ || entityName.kind === 158 /* PropertyAccessExpression */ || - entityName.parent.kind === 211 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 132 /* QualifiedName */ || entityName.kind === 163 /* PropertyAccessExpression */ || + entityName.parent.kind === 218 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1536 /* Namespace */; @@ -13397,10 +13979,10 @@ var ts; function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 152 /* ParenthesizedType */) { + while (node.kind === 157 /* ParenthesizedType */) { node = node.parent; } - if (node.kind === 206 /* TypeAliasDeclaration */) { + if (node.kind === 213 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -13416,10 +13998,10 @@ var ts; return ts.declarationNameToString(declaration.name); } switch (declaration.kind) { - case 177 /* ClassExpression */: + case 183 /* ClassExpression */: return "(Anonymous class)"; - case 165 /* FunctionExpression */: - case 166 /* ArrowFunction */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: return "(Anonymous function)"; } } @@ -13505,7 +14087,7 @@ var ts; return writeType(type, globalFlags); function writeType(type, flags) { // Write undefined/null type as any - if (type.flags & 2097279 /* Intrinsic */) { + if (type.flags & 4194431 /* Intrinsic */) { // Special handling for unknown / resolving types, they should show up as any and not unknown or __resolving writer.writeKeyword(!(globalFlags & 16 /* WriteOwnNameForAnyLike */) && isTypeAny(type) ? "any" @@ -13521,10 +14103,10 @@ var ts; else if (type.flags & 8192 /* Tuple */) { writeTupleType(type); } - else if (type.flags & 16384 /* Union */) { - writeUnionType(type, flags); + else if (type.flags & 49152 /* UnionOrIntersection */) { + writeUnionOrIntersectionType(type, flags); } - else if (type.flags & 32768 /* Anonymous */) { + else if (type.flags & 65536 /* Anonymous */) { writeAnonymousType(type, flags); } else if (type.flags & 256 /* StringLiteral */) { @@ -13540,16 +14122,16 @@ var ts; writePunctuation(writer, 15 /* CloseBraceToken */); } } - function writeTypeList(types, union) { + function writeTypeList(types, delimiter) { for (var i = 0; i < types.length; i++) { if (i > 0) { - if (union) { + if (delimiter !== 23 /* CommaToken */) { writeSpace(writer); } - writePunctuation(writer, union ? 44 /* BarToken */ : 23 /* CommaToken */); + writePunctuation(writer, delimiter); writeSpace(writer); } - writeType(types[i], union ? 64 /* InElementType */ : 0 /* None */); + writeType(types[i], delimiter === 23 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */); } } function writeSymbolTypeReference(symbol, typeArguments, pos, end) { @@ -13566,7 +14148,7 @@ var ts; writeSpace(writer); writeType(typeArguments[pos++], 0 /* None */); } - writePunctuation(writer, 25 /* GreaterThanToken */); + writePunctuation(writer, 26 /* GreaterThanToken */); } } function writeTypeReference(type, flags) { @@ -13604,14 +14186,14 @@ var ts; } function writeTupleType(type) { writePunctuation(writer, 18 /* OpenBracketToken */); - writeTypeList(type.elementTypes, false); + writeTypeList(type.elementTypes, 23 /* CommaToken */); writePunctuation(writer, 19 /* CloseBracketToken */); } - function writeUnionType(type, flags) { + function writeUnionOrIntersectionType(type, flags) { if (flags & 64 /* InElementType */) { writePunctuation(writer, 16 /* OpenParenToken */); } - writeTypeList(type.types, true); + writeTypeList(type.types, type.flags & 16384 /* Union */ ? 45 /* BarToken */ : 44 /* AmpersandToken */); if (flags & 64 /* InElementType */) { writePunctuation(writer, 17 /* CloseParenToken */); } @@ -13635,7 +14217,7 @@ var ts; } else { // Recursive usage, use any - writeKeyword(writer, 112 /* AnyKeyword */); + writeKeyword(writer, 114 /* AnyKeyword */); } } else { @@ -13659,7 +14241,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 230 /* SourceFile */ || declaration.parent.kind === 209 /* ModuleBlock */; + return declaration.parent.kind === 245 /* SourceFile */ || declaration.parent.kind === 216 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -13669,7 +14251,7 @@ var ts; } } function writeTypeofSymbol(type, typeFormatFlags) { - writeKeyword(writer, 97 /* TypeOfKeyword */); + writeKeyword(writer, 98 /* TypeOfKeyword */); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */, 0 /* None */, typeFormatFlags); } @@ -13684,7 +14266,7 @@ var ts; return ts.declarationNameToString(declaration.parameters[0].name); } function writeLiteralType(type, flags) { - var resolved = resolveObjectOrUnionTypeMembers(type); + var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { writePunctuation(writer, 14 /* OpenBraceToken */); @@ -13705,7 +14287,7 @@ var ts; if (flags & 64 /* InElementType */) { writePunctuation(writer, 16 /* OpenParenToken */); } - writeKeyword(writer, 88 /* NewKeyword */); + writeKeyword(writer, 89 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, symbolStack); if (flags & 64 /* InElementType */) { @@ -13725,7 +14307,7 @@ var ts; } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - writeKeyword(writer, 88 /* NewKeyword */); + writeKeyword(writer, 89 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); writePunctuation(writer, 22 /* SemicolonToken */); @@ -13735,11 +14317,11 @@ var ts; // [x: string]: writePunctuation(writer, 18 /* OpenBracketToken */); writer.writeParameter(getIndexerParameterName(resolved, 0 /* String */, "x")); - writePunctuation(writer, 51 /* ColonToken */); + writePunctuation(writer, 52 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 123 /* StringKeyword */); + writeKeyword(writer, 127 /* StringKeyword */); writePunctuation(writer, 19 /* CloseBracketToken */); - writePunctuation(writer, 51 /* ColonToken */); + writePunctuation(writer, 52 /* ColonToken */); writeSpace(writer); writeType(resolved.stringIndexType, 0 /* None */); writePunctuation(writer, 22 /* SemicolonToken */); @@ -13749,11 +14331,11 @@ var ts; // [x: number]: writePunctuation(writer, 18 /* OpenBracketToken */); writer.writeParameter(getIndexerParameterName(resolved, 1 /* Number */, "x")); - writePunctuation(writer, 51 /* ColonToken */); + writePunctuation(writer, 52 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 121 /* NumberKeyword */); + writeKeyword(writer, 125 /* NumberKeyword */); writePunctuation(writer, 19 /* CloseBracketToken */); - writePunctuation(writer, 51 /* ColonToken */); + writePunctuation(writer, 52 /* ColonToken */); writeSpace(writer); writeType(resolved.numberIndexType, 0 /* None */); writePunctuation(writer, 22 /* SemicolonToken */); @@ -13768,7 +14350,7 @@ var ts; var signature = signatures[_f]; buildSymbolDisplay(p, writer); if (p.flags & 536870912 /* Optional */) { - writePunctuation(writer, 50 /* QuestionToken */); + writePunctuation(writer, 51 /* QuestionToken */); } buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, symbolStack); writePunctuation(writer, 22 /* SemicolonToken */); @@ -13778,9 +14360,9 @@ var ts; else { buildSymbolDisplay(p, writer); if (p.flags & 536870912 /* Optional */) { - writePunctuation(writer, 50 /* QuestionToken */); + writePunctuation(writer, 51 /* QuestionToken */); } - writePunctuation(writer, 51 /* ColonToken */); + writePunctuation(writer, 52 /* ColonToken */); writeSpace(writer); writeType(t, 0 /* None */); writePunctuation(writer, 22 /* SemicolonToken */); @@ -13802,7 +14384,7 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 79 /* ExtendsKeyword */); + writeKeyword(writer, 80 /* ExtendsKeyword */); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } @@ -13814,9 +14396,9 @@ var ts; } appendSymbolNameOnly(p, writer); if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 50 /* QuestionToken */); + writePunctuation(writer, 51 /* QuestionToken */); } - writePunctuation(writer, 51 /* ColonToken */); + writePunctuation(writer, 52 /* ColonToken */); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, symbolStack); } @@ -13830,7 +14412,7 @@ var ts; } buildTypeParameterDisplay(typeParameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 25 /* GreaterThanToken */); + writePunctuation(writer, 26 /* GreaterThanToken */); } } function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, symbolStack) { @@ -13843,7 +14425,7 @@ var ts; } buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, 0 /* None */); } - writePunctuation(writer, 25 /* GreaterThanToken */); + writePunctuation(writer, 26 /* GreaterThanToken */); } } function buildDisplayForParametersAndDelimiters(parameters, writer, enclosingDeclaration, flags, symbolStack) { @@ -13860,13 +14442,24 @@ var ts; function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { if (flags & 8 /* WriteArrowStyleSignature */) { writeSpace(writer); - writePunctuation(writer, 32 /* EqualsGreaterThanToken */); + writePunctuation(writer, 33 /* EqualsGreaterThanToken */); } else { - writePunctuation(writer, 51 /* ColonToken */); + writePunctuation(writer, 52 /* ColonToken */); } writeSpace(writer); - buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags, symbolStack); + var returnType; + if (signature.typePredicate) { + writer.writeParameter(signature.typePredicate.parameterName); + writeSpace(writer); + writeKeyword(writer, 121 /* IsKeyword */); + writeSpace(writer); + returnType = signature.typePredicate.type; + } + else { + returnType = getReturnTypeOfSignature(signature); + } + buildTypeDisplay(returnType, writer, enclosingDeclaration, flags, symbolStack); } function buildSignatureDisplay(signature, writer, enclosingDeclaration, flags, symbolStack) { if (signature.target && (flags & 32 /* WriteTypeArgumentsOfSignature */)) { @@ -13898,12 +14491,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 208 /* ModuleDeclaration */) { + if (node.kind === 215 /* ModuleDeclaration */) { if (node.name.kind === 8 /* StringLiteral */) { return node; } } - else if (node.kind === 230 /* SourceFile */) { + else if (node.kind === 245 /* SourceFile */) { return ts.isExternalModule(node) ? node : undefined; } } @@ -13952,69 +14545,70 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 155 /* BindingElement */: + case 160 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 201 /* VariableDeclaration */: + case 208 /* VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // Otherwise fall through - case 208 /* ModuleDeclaration */: - case 204 /* ClassDeclaration */: - case 205 /* InterfaceDeclaration */: - case 206 /* TypeAliasDeclaration */: - case 203 /* FunctionDeclaration */: - case 207 /* EnumDeclaration */: - case 211 /* ImportEqualsDeclaration */: + case 215 /* ModuleDeclaration */: + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: + case 213 /* TypeAliasDeclaration */: + case 210 /* FunctionDeclaration */: + case 214 /* EnumDeclaration */: + case 218 /* ImportEqualsDeclaration */: var parent_4 = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedNodeFlags(node) & 1 /* Export */) && - !(node.kind !== 211 /* ImportEqualsDeclaration */ && parent_4.kind !== 230 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { + !(node.kind !== 218 /* ImportEqualsDeclaration */ && parent_4.kind !== 245 /* SourceFile */ && ts.isInAmbientContext(parent_4))) { return isGlobalSourceFile(parent_4); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent_4); - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: if (node.flags & (32 /* Private */ | 64 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so let it fall into next case statement - case 137 /* Constructor */: - case 141 /* ConstructSignature */: - case 140 /* CallSignature */: - case 142 /* IndexSignature */: - case 131 /* Parameter */: - case 209 /* ModuleBlock */: - case 145 /* FunctionType */: - case 146 /* ConstructorType */: - case 148 /* TypeLiteral */: - case 144 /* TypeReference */: - case 149 /* ArrayType */: - case 150 /* TupleType */: - case 151 /* UnionType */: - case 152 /* ParenthesizedType */: + case 141 /* Constructor */: + case 145 /* ConstructSignature */: + case 144 /* CallSignature */: + case 146 /* IndexSignature */: + case 135 /* Parameter */: + case 216 /* ModuleBlock */: + case 149 /* FunctionType */: + case 150 /* ConstructorType */: + case 152 /* TypeLiteral */: + case 148 /* TypeReference */: + case 153 /* ArrayType */: + case 154 /* TupleType */: + case 155 /* UnionType */: + case 156 /* IntersectionType */: + case 157 /* ParenthesizedType */: return isDeclarationVisible(node.parent); - // Default binding, import specifier and namespace import is visible + // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 213 /* ImportClause */: - case 214 /* NamespaceImport */: - case 216 /* ImportSpecifier */: + case 220 /* ImportClause */: + case 221 /* NamespaceImport */: + case 223 /* ImportSpecifier */: return false; // Type parameters are always visible - case 130 /* TypeParameter */: + case 134 /* TypeParameter */: // Source file is always visible - case 230 /* SourceFile */: + case 245 /* SourceFile */: return true; // Export assignements do not create name bindings outside the module - case 217 /* ExportAssignment */: + case 224 /* ExportAssignment */: return false; default: ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); @@ -14030,10 +14624,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 217 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 224 /* ExportAssignment */) { exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 220 /* ExportSpecifier */) { + else if (node.parent.kind === 227 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent); } var result = []; @@ -14091,7 +14685,7 @@ var ts; node = ts.getRootDeclaration(node); // Parent chain: // VaribleDeclaration -> VariableDeclarationList -> VariableStatement -> 'Declaration Container' - return node.kind === 201 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; + return node.kind === 208 /* VariableDeclaration */ ? node.parent.parent.parent : node.parent; } function getTypeOfPrototypeProperty(prototype) { // TypeScript 1.0 spec (April 2014): 8.4 @@ -14127,16 +14721,16 @@ var ts; return parentType; } var type; - if (pattern.kind === 153 /* ObjectBindingPattern */) { + if (pattern.kind === 158 /* ObjectBindingPattern */) { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) - var name_9 = declaration.propertyName || declaration.name; + var name_10 = declaration.propertyName || declaration.name; // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, // or otherwise the type of the string index signature. - type = getTypeOfPropertyOfType(parentType, name_9.text) || - isNumericLiteralName(name_9.text) && getIndexTypeOfType(parentType, 1 /* Number */) || + type = getTypeOfPropertyOfType(parentType, name_10.text) || + isNumericLiteralName(name_10.text) && getIndexTypeOfType(parentType, 1 /* Number */) || getIndexTypeOfType(parentType, 0 /* String */); if (!type) { - error(name_9, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_9)); + error(name_10, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), ts.declarationNameToString(name_10)); return unknownType; } } @@ -14174,10 +14768,10 @@ var ts; // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration) { // A variable declared in a for..in statement is always of type any - if (declaration.parent.parent.kind === 190 /* ForInStatement */) { + if (declaration.parent.parent.kind === 197 /* ForInStatement */) { return anyType; } - if (declaration.parent.parent.kind === 191 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 198 /* ForOfStatement */) { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like // [Symbol.iterator] or next). This may be because we accessed properties from anyType, @@ -14191,11 +14785,11 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 131 /* Parameter */) { + if (declaration.kind === 135 /* Parameter */) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 139 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 138 /* GetAccessor */); + if (func.kind === 143 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 142 /* GetAccessor */); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -14211,7 +14805,7 @@ var ts; return checkExpressionCached(declaration.initializer); } // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 228 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 243 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } // No type specified and nothing can be inferred @@ -14246,7 +14840,7 @@ var ts; var hasSpreadElement = false; var elementTypes = []; ts.forEach(pattern.elements, function (e) { - elementTypes.push(e.kind === 178 /* OmittedExpression */ || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); + elementTypes.push(e.kind === 184 /* OmittedExpression */ || e.dotDotDotToken ? anyType : getTypeFromBindingElement(e)); if (e.dotDotDotToken) { hasSpreadElement = true; } @@ -14269,7 +14863,7 @@ var ts; // parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of // the parameter. function getTypeFromBindingPattern(pattern) { - return pattern.kind === 153 /* ObjectBindingPattern */ + return pattern.kind === 158 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern) : getTypeFromArrayBindingPattern(pattern); } @@ -14291,7 +14885,7 @@ var ts; // During a normal type check we'll never get to here with a property assignment (the check of the containing // object literal uses a different path). We exclude widening only so that language services and type verification // tools see the actual type. - return declaration.kind !== 227 /* PropertyAssignment */ ? getWidenedType(type) : type; + return declaration.kind !== 242 /* PropertyAssignment */ ? getWidenedType(type) : type; } // If no type was specified and nothing could be inferred, and if the declaration specifies a binding pattern, use // the type implied by the binding pattern @@ -14303,7 +14897,7 @@ var ts; // Report implicit any errors unless this is a private property within an ambient declaration if (reportErrors && compilerOptions.noImplicitAny) { var root = ts.getRootDeclaration(declaration); - if (!isPrivateWithinAmbient(root) && !(root.kind === 131 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { + if (!isPrivateWithinAmbient(root) && !(root.kind === 135 /* Parameter */ && isPrivateWithinAmbient(root.parent))) { reportImplicitAnyError(declaration, type); } } @@ -14318,11 +14912,11 @@ var ts; } // Handle catch clause variables var declaration = symbol.valueDeclaration; - if (declaration.parent.kind === 226 /* CatchClause */) { + if (declaration.parent.kind === 241 /* CatchClause */) { return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 217 /* ExportAssignment */) { + if (declaration.kind === 224 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } // Handle variable, parameter or property @@ -14348,16 +14942,13 @@ var ts; } return links.type; } - function getSetAccessorTypeAnnotationNode(accessor) { - return accessor && accessor.parameters.length > 0 && accessor.parameters[0].type; - } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 138 /* GetAccessor */) { + if (accessor.kind === 142 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { - var setterTypeAnnotation = getSetAccessorTypeAnnotationNode(accessor); + var setterTypeAnnotation = ts.getSetAccessorTypeAnnotationNode(accessor); return setterTypeAnnotation && getTypeFromTypeNode(setterTypeAnnotation); } } @@ -14369,8 +14960,8 @@ var ts; if (!pushTypeResolution(symbol)) { return unknownType; } - var getter = ts.getDeclarationOfKind(symbol, 138 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 139 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 142 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 143 /* SetAccessor */); var type; // First try to see if the user specified a return type on the get-accessor. var getterReturnType = getAnnotatedAccessorType(getter); @@ -14399,7 +14990,7 @@ var ts; if (!popTypeResolution()) { type = anyType; if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 138 /* GetAccessor */); + var getter_1 = ts.getDeclarationOfKind(symbol, 142 /* GetAccessor */); error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -14410,7 +15001,7 @@ var ts; function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - links.type = createObjectType(32768 /* Anonymous */, symbol); + links.type = createObjectType(65536 /* Anonymous */, symbol); } return links.type; } @@ -14499,9 +15090,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 204 /* ClassDeclaration */ || node.kind === 177 /* ClassExpression */ || - node.kind === 203 /* FunctionDeclaration */ || node.kind === 165 /* FunctionExpression */ || - node.kind === 136 /* MethodDeclaration */ || node.kind === 166 /* ArrowFunction */) { + if (node.kind === 211 /* ClassDeclaration */ || node.kind === 183 /* ClassExpression */ || + node.kind === 210 /* FunctionDeclaration */ || node.kind === 170 /* FunctionExpression */ || + node.kind === 140 /* MethodDeclaration */ || node.kind === 171 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -14511,7 +15102,7 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 205 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 212 /* InterfaceDeclaration */); return appendOuterTypeParameters(undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -14520,8 +15111,8 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 205 /* InterfaceDeclaration */ || node.kind === 204 /* ClassDeclaration */ || - node.kind === 177 /* ClassExpression */ || node.kind === 206 /* TypeAliasDeclaration */) { + if (node.kind === 212 /* InterfaceDeclaration */ || node.kind === 211 /* ClassDeclaration */ || + node.kind === 183 /* ClassExpression */ || node.kind === 213 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -14536,7 +15127,7 @@ var ts; return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol)); } function isConstructorType(type) { - return type.flags & 48128 /* ObjectType */ && getSignaturesOfType(type, 1 /* Construct */).length > 0; + return type.flags & 80896 /* ObjectType */ && getSignaturesOfType(type, 1 /* Construct */).length > 0; } function getBaseTypeNodeOfClass(type) { return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); @@ -14568,10 +15159,10 @@ var ts; return unknownType; } var baseConstructorType = checkExpression(baseTypeNode.expression); - if (baseConstructorType.flags & 48128 /* ObjectType */) { + if (baseConstructorType.flags & 80896 /* ObjectType */) { // Resolving the members of a class requires us to resolve the base class of that class. // We force resolution here such that we catch circularities now. - resolveObjectOrUnionTypeMembers(baseConstructorType); + resolveStructuredTypeMembers(baseConstructorType); } if (!popTypeResolution()) { error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); @@ -14602,7 +15193,7 @@ var ts; function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = emptyArray; var baseContructorType = getBaseConstructorTypeOfClass(type); - if (!(baseContructorType.flags & 48128 /* ObjectType */)) { + if (!(baseContructorType.flags & 80896 /* ObjectType */)) { return; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -14641,7 +15232,7 @@ var ts; type.resolvedBaseTypes = []; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 205 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 212 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -14690,7 +15281,7 @@ var ts; if (!pushTypeResolution(links)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 206 /* TypeAliasDeclaration */); + var declaration = ts.getDeclarationOfKind(symbol, 213 /* TypeAliasDeclaration */); var type = getTypeFromTypeNode(declaration.type); if (popTypeResolution()) { links.typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -14723,7 +15314,7 @@ var ts; if (!links.declaredType) { var type = createType(512 /* TypeParameter */); type.symbol = symbol; - if (!ts.getDeclarationOfKind(symbol, 130 /* TypeParameter */).constraint) { + if (!ts.getDeclarationOfKind(symbol, 134 /* TypeParameter */).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -14885,7 +15476,7 @@ var ts; return members; } function resolveTupleTypeMembers(type) { - var arrayType = resolveObjectOrUnionTypeMembers(createArrayType(getUnionType(type.elementTypes))); + var arrayType = resolveStructuredTypeMembers(createArrayType(getUnionType(type.elementTypes))); var members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexType, arrayType.numberIndexType); @@ -14948,6 +15539,25 @@ var ts; var numberIndexType = getUnionIndexType(type.types, 1 /* Number */); setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); } + function intersectTypes(type1, type2) { + return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]); + } + function resolveIntersectionTypeMembers(type) { + // The members and properties collections are empty for intersection types. To get all properties of an + // intersection type use getPropertiesOfType (only the language service uses this). + var callSignatures = emptyArray; + var constructSignatures = emptyArray; + var stringIndexType = undefined; + var numberIndexType = undefined; + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(t, 0 /* Call */)); + constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(t, 1 /* Construct */)); + stringIndexType = intersectTypes(stringIndexType, getIndexTypeOfType(t, 0 /* String */)); + numberIndexType = intersectTypes(numberIndexType, getIndexTypeOfType(t, 1 /* Number */)); + } + setObjectTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexType, numberIndexType); + } function resolveAnonymousTypeMembers(type) { var symbol = type.symbol; var members; @@ -14980,7 +15590,7 @@ var ts; constructSignatures = getDefaultConstructSignatures(classType); } var baseConstructorType = getBaseConstructorTypeOfClass(classType); - if (baseConstructorType.flags & 48128 /* ObjectType */) { + if (baseConstructorType.flags & 80896 /* ObjectType */) { members = createSymbolTable(getNamedMembers(members)); addInheritedMembers(members, getPropertiesOfObjectType(baseConstructorType)); } @@ -14990,12 +15600,12 @@ var ts; } setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } - function resolveObjectOrUnionTypeMembers(type) { + function resolveStructuredTypeMembers(type) { if (!type.members) { if (type.flags & (1024 /* Class */ | 2048 /* Interface */)) { resolveClassOrInterfaceMembers(type); } - else if (type.flags & 32768 /* Anonymous */) { + else if (type.flags & 65536 /* Anonymous */) { resolveAnonymousTypeMembers(type); } else if (type.flags & 8192 /* Tuple */) { @@ -15004,6 +15614,9 @@ var ts; else if (type.flags & 16384 /* Union */) { resolveUnionTypeMembers(type); } + else if (type.flags & 32768 /* Intersection */) { + resolveIntersectionTypeMembers(type); + } else { resolveTypeReferenceMembers(type); } @@ -15012,16 +15625,16 @@ var ts; } // Return properties of an object type or an empty array for other types function getPropertiesOfObjectType(type) { - if (type.flags & 48128 /* ObjectType */) { - return resolveObjectOrUnionTypeMembers(type).properties; + if (type.flags & 80896 /* ObjectType */) { + return resolveStructuredTypeMembers(type).properties; } return emptyArray; } - // If the given type is an object type and that type has a property by the given name, return - // the symbol for that property. Otherwise return undefined. + // If the given type is an object type and that type has a property by the given name, + // return the symbol for that property.Otherwise return undefined. function getPropertyOfObjectType(type, name) { - if (type.flags & 48128 /* ObjectType */) { - var resolved = resolveObjectOrUnionTypeMembers(type); + if (type.flags & 80896 /* ObjectType */) { + var resolved = resolveStructuredTypeMembers(type); if (ts.hasProperty(resolved.members, name)) { var symbol = resolved.members[name]; if (symbolIsValue(symbol)) { @@ -15030,23 +15643,30 @@ var ts; } } } - function getPropertiesOfUnionType(type) { - var result = []; - ts.forEach(getPropertiesOfType(type.types[0]), function (prop) { - var unionProp = getPropertyOfUnionType(type, prop.name); - if (unionProp) { - result.push(unionProp); + function getPropertiesOfUnionOrIntersectionType(type) { + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var current = _a[_i]; + for (var _b = 0, _c = getPropertiesOfType(current); _b < _c.length; _b++) { + var prop = _c[_b]; + getPropertyOfUnionOrIntersectionType(type, prop.name); } - }); - return result; + // The properties of a union type are those that are present in all constituent types, so + // we only need to check the properties of the first type + if (type.flags & 16384 /* Union */) { + break; + } + } + return type.resolvedProperties ? symbolsToArray(type.resolvedProperties) : emptyArray; } function getPropertiesOfType(type) { type = getApparentType(type); - return type.flags & 16384 /* Union */ ? getPropertiesOfUnionType(type) : getPropertiesOfObjectType(type); + return type.flags & 49152 /* UnionOrIntersection */ ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } - // For a type parameter, return the base constraint of the type parameter. For the string, number, - // boolean, and symbol primitive types, return the corresponding object types. Otherwise return the - // type itself. Note that the apparent type of a union type is the union type itself. + /** + * For a type parameter, return the base constraint of the type parameter. For the string, number, + * boolean, and symbol primitive types, return the corresponding object types. Otherwise return the + * type itself. Note that the apparent type of a union type is the union type itself. + */ function getApparentType(type) { if (type.flags & 16384 /* Union */) { type = getReducedTypeOfUnionType(type); @@ -15068,51 +15688,60 @@ var ts; else if (type.flags & 8 /* Boolean */) { type = globalBooleanType; } - else if (type.flags & 2097152 /* ESSymbol */) { + else if (type.flags & 4194304 /* ESSymbol */) { type = globalESSymbolType; } return type; } - function createUnionProperty(unionType, name) { - var types = unionType.types; + function createUnionOrIntersectionProperty(containingType, name) { + var types = containingType.types; var props; for (var _i = 0; _i < types.length; _i++) { var current = types[_i]; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); - if (!prop || getDeclarationFlagsFromSymbol(prop) & (32 /* Private */ | 64 /* Protected */)) { + if (prop && !(getDeclarationFlagsFromSymbol(prop) & (32 /* Private */ | 64 /* Protected */))) { + if (!props) { + props = [prop]; + } + else if (!ts.contains(props, prop)) { + props.push(prop); + } + } + else if (containingType.flags & 16384 /* Union */) { + // A union type requires the property to be present in all constituent types return undefined; } - if (!props) { - props = [prop]; - } - else { - props.push(prop); - } } } + if (!props) { + return undefined; + } + if (props.length === 1) { + return props[0]; + } var propTypes = []; var declarations = []; for (var _a = 0; _a < props.length; _a++) { var prop = props[_a]; if (prop.declarations) { - declarations.push.apply(declarations, prop.declarations); + ts.addRange(declarations, prop.declarations); } propTypes.push(getTypeOfSymbol(prop)); } - var result = createSymbol(4 /* Property */ | 67108864 /* Transient */ | 268435456 /* UnionProperty */, name); - result.unionType = unionType; + var result = createSymbol(4 /* Property */ | 67108864 /* Transient */ | 268435456 /* SyntheticProperty */, name); + result.containingType = containingType; result.declarations = declarations; - result.type = getUnionType(propTypes); + result.type = containingType.flags & 16384 /* Union */ ? getUnionType(propTypes) : getIntersectionType(propTypes); return result; } - function getPropertyOfUnionType(type, name) { + function getPropertyOfUnionOrIntersectionType(type, name) { var properties = type.resolvedProperties || (type.resolvedProperties = {}); if (ts.hasProperty(properties, name)) { return properties[name]; } - var property = createUnionProperty(type, name); + var property = createUnionOrIntersectionProperty(type, name); if (property) { properties[name] = property; } @@ -15123,8 +15752,8 @@ var ts; // Object and Function as appropriate. function getPropertyOfType(type, name) { type = getApparentType(type); - if (type.flags & 48128 /* ObjectType */) { - var resolved = resolveObjectOrUnionTypeMembers(type); + if (type.flags & 80896 /* ObjectType */) { + var resolved = resolveStructuredTypeMembers(type); if (ts.hasProperty(resolved.members, name)) { var symbol = resolved.members[name]; if (symbolIsValue(symbol)) { @@ -15139,14 +15768,14 @@ var ts; } return getPropertyOfObjectType(globalObjectType, name); } - if (type.flags & 16384 /* Union */) { - return getPropertyOfUnionType(type, name); + if (type.flags & 49152 /* UnionOrIntersection */) { + return getPropertyOfUnionOrIntersectionType(type, name); } return undefined; } - function getSignaturesOfObjectOrUnionType(type, kind) { - if (type.flags & (48128 /* ObjectType */ | 16384 /* Union */)) { - var resolved = resolveObjectOrUnionTypeMembers(type); + function getSignaturesOfStructuredType(type, kind) { + if (type.flags & 130048 /* StructuredType */) { + var resolved = resolveStructuredTypeMembers(type); return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures; } return emptyArray; @@ -15154,27 +15783,34 @@ var ts; // Return the signatures of the given kind in the given type. Creates synthetic union signatures when necessary and // maps primitive types and type parameters are to their apparent types. function getSignaturesOfType(type, kind) { - return getSignaturesOfObjectOrUnionType(getApparentType(type), kind); + return getSignaturesOfStructuredType(getApparentType(type), kind); } - function typeHasCallOrConstructSignatures(type) { + function typeHasConstructSignatures(type) { var apparentType = getApparentType(type); - if (apparentType.flags & (48128 /* ObjectType */ | 16384 /* Union */)) { - var resolved = resolveObjectOrUnionTypeMembers(type); - return resolved.callSignatures.length > 0 - || resolved.constructSignatures.length > 0; + if (apparentType.flags & (80896 /* ObjectType */ | 16384 /* Union */)) { + var resolved = resolveStructuredTypeMembers(type); + return resolved.constructSignatures.length > 0; } return false; } - function getIndexTypeOfObjectOrUnionType(type, kind) { - if (type.flags & (48128 /* ObjectType */ | 16384 /* Union */)) { - var resolved = resolveObjectOrUnionTypeMembers(type); + function typeHasCallOrConstructSignatures(type) { + var apparentType = getApparentType(type); + if (apparentType.flags & 130048 /* StructuredType */) { + var resolved = resolveStructuredTypeMembers(type); + return resolved.callSignatures.length > 0 || resolved.constructSignatures.length > 0; + } + return false; + } + function getIndexTypeOfStructuredType(type, kind) { + if (type.flags & 130048 /* StructuredType */) { + var resolved = resolveStructuredTypeMembers(type); return kind === 0 /* String */ ? resolved.stringIndexType : resolved.numberIndexType; } } // Return the index type of the given kind in the given type. Creates synthetic union index types when necessary and // maps primitive types and type parameters are to their apparent types. function getIndexTypeOfType(type, kind) { - return getIndexTypeOfObjectOrUnionType(getApparentType(type), kind); + return getIndexTypeOfStructuredType(getApparentType(type), kind); } // Return list of type parameters with duplicates removed (duplicate identifier errors are generated in the actual // type checking functions). @@ -15203,7 +15839,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 137 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 141 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; @@ -15231,7 +15867,7 @@ var ts; } else if (declaration.type) { returnType = getTypeFromTypeNode(declaration.type); - if (declaration.type.kind === 143 /* TypePredicate */) { + if (declaration.type.kind === 147 /* TypePredicate */) { var typePredicateNode = declaration.type; typePredicate = { parameterName: typePredicateNode.parameterName ? typePredicateNode.parameterName.text : undefined, @@ -15243,8 +15879,8 @@ var ts; else { // TypeScript 1.0 spec (April 2014): // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. - if (declaration.kind === 138 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 139 /* SetAccessor */); + if (declaration.kind === 142 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 143 /* SetAccessor */); returnType = getAnnotatedAccessorType(setter); } if (!returnType && ts.nodeIsMissing(declaration.body)) { @@ -15262,19 +15898,19 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 145 /* FunctionType */: - case 146 /* ConstructorType */: - case 203 /* FunctionDeclaration */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 137 /* Constructor */: - case 140 /* CallSignature */: - case 141 /* ConstructSignature */: - case 142 /* IndexSignature */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 165 /* FunctionExpression */: - case 166 /* ArrowFunction */: + case 149 /* FunctionType */: + case 150 /* ConstructorType */: + case 210 /* FunctionDeclaration */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 141 /* Constructor */: + case 144 /* CallSignature */: + case 145 /* ConstructSignature */: + case 146 /* IndexSignature */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: // Don't include signature if node is the implementation of an overloaded function. A node is considered // an implementation node if it has a body and the previous node is of the same kind and immediately // precedes the implementation node (i.e. has the same parent and ends where the implementation starts). @@ -15351,8 +15987,8 @@ var ts; // object type literal or interface (using the new keyword). Each way of declaring a constructor // will result in a different declaration kind. if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 137 /* Constructor */ || signature.declaration.kind === 141 /* ConstructSignature */; - var type = createObjectType(32768 /* Anonymous */ | 131072 /* FromSignature */); + var isConstructor = signature.declaration.kind === 141 /* Constructor */ || signature.declaration.kind === 145 /* ConstructSignature */; + var type = createObjectType(65536 /* Anonymous */ | 262144 /* FromSignature */); type.members = emptySymbols; type.properties = emptyArray; type.callSignatures = !isConstructor ? [signature] : emptyArray; @@ -15365,10 +16001,9 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 121 /* NumberKeyword */ : 123 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 125 /* NumberKeyword */ : 127 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { - var len = indexSymbol.declarations.length; for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; var node = decl; @@ -15395,13 +16030,13 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 130 /* TypeParameter */).constraint); + type.constraint = getTypeFromTypeNode(ts.getDeclarationOfKind(type.symbol, 134 /* TypeParameter */).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 130 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 134 /* TypeParameter */).parent); } function getTypeListId(types) { switch (types.length) { @@ -15429,7 +16064,7 @@ var ts; var type = types[_i]; result |= type.flags; } - return result & 1572864 /* RequiresWidening */; + return result & 3145728 /* RequiresWidening */; } function createTypeReference(target, typeArguments) { var id = getTypeListId(typeArguments); @@ -15454,13 +16089,13 @@ var ts; currentNode = currentNode.parent; } // if last step was made from the type parameter this means that path has started somewhere in constraint which is illegal - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 130 /* TypeParameter */; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 134 /* TypeParameter */; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 144 /* TypeReference */ && n.typeName.kind === 65 /* Identifier */) { + if (n.kind === 148 /* TypeReference */ && n.typeName.kind === 66 /* Identifier */) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { var symbol = resolveName(typeParameter, n.typeName.text, 793056 /* Type */, undefined, undefined); @@ -15547,7 +16182,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { // We only support expressions that are simple qualified names. For other expressions this produces undefined. - var typeNameOrExpression = node.kind === 144 /* TypeReference */ ? node.typeName : + var typeNameOrExpression = node.kind === 148 /* TypeReference */ ? node.typeName : ts.isSupportedExpressionWithTypeArguments(node) ? node.expression : undefined; var symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, 793056 /* Type */) || unknownSymbol; @@ -15579,9 +16214,9 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; switch (declaration.kind) { - case 204 /* ClassDeclaration */: - case 205 /* InterfaceDeclaration */: - case 207 /* EnumDeclaration */: + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: + case 214 /* EnumDeclaration */: return declaration; } } @@ -15590,7 +16225,7 @@ var ts; return arity ? emptyGenericType : emptyObjectType; } var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & 48128 /* ObjectType */)) { + if (!(type.flags & 80896 /* ObjectType */)) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name); return arity ? emptyGenericType : emptyObjectType; } @@ -15613,6 +16248,19 @@ var ts; if (arity === void 0) { arity = 0; } return getTypeOfGlobalSymbol(getGlobalTypeSymbol(name), arity); } + function tryGetGlobalType(name, arity) { + if (arity === void 0) { arity = 0; } + return getTypeOfGlobalSymbol(getGlobalSymbol(name, 793056 /* Type */, undefined), arity); + } + /** + * Returns a type that is inside a namespace at the global scope, e.g. + * getExportedTypeFromNamespace('JSX', 'Element') returns the JSX.Element type + */ + function getExportedTypeFromNamespace(namespace, name) { + var namespaceSymbol = getGlobalSymbol(namespace, 1536 /* Namespace */, undefined); + var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793056 /* Type */); + return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); + } function getGlobalESSymbolConstructorSymbol() { return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol")); } @@ -15663,25 +16311,20 @@ var ts; } return links.resolvedType; } - function addTypeToSortedSet(sortedSet, type) { - if (type.flags & 16384 /* Union */) { - addTypesToSortedSet(sortedSet, type.types); + function addTypeToSet(typeSet, type, typeSetKind) { + if (type.flags & typeSetKind) { + addTypesToSet(typeSet, type.types, typeSetKind); } - else { - var i = 0; - var id = type.id; - while (i < sortedSet.length && sortedSet[i].id < id) { - i++; - } - if (i === sortedSet.length || sortedSet[i].id !== id) { - sortedSet.splice(i, 0, type); - } + else if (!ts.contains(typeSet, type)) { + typeSet.push(type); } } - function addTypesToSortedSet(sortedTypes, types) { + // Add the given types to the given type set. Order is preserved, duplicates are removed, + // and nested types of the given kind are flattened into the set. + function addTypesToSet(typeSet, types, typeSetKind) { for (var _i = 0; _i < types.length; _i++) { var type = types[_i]; - addTypeToSortedSet(sortedTypes, type); + addTypeToSet(typeSet, type, typeSetKind); } } function isSubtypeOfAny(candidate, types) { @@ -15720,6 +16363,9 @@ var ts; } } } + function compareTypeIds(type1, type2) { + return type1.id - type2.id; + } // The noSubtypeReduction flag is there because it isn't possible to always do subtype reduction. The flag // is true when creating a union type from a type node and when instantiating a union type. In both of those // cases subtype reduction has to be deferred to properly support recursive union types. For example, a @@ -15728,26 +16374,27 @@ var ts; if (types.length === 0) { return emptyObjectType; } - var sortedTypes = []; - addTypesToSortedSet(sortedTypes, types); + var typeSet = []; + addTypesToSet(typeSet, types, 16384 /* Union */); + typeSet.sort(compareTypeIds); if (noSubtypeReduction) { - if (containsTypeAny(sortedTypes)) { + if (containsTypeAny(typeSet)) { return anyType; } - removeAllButLast(sortedTypes, undefinedType); - removeAllButLast(sortedTypes, nullType); + removeAllButLast(typeSet, undefinedType); + removeAllButLast(typeSet, nullType); } else { - removeSubtypes(sortedTypes); + removeSubtypes(typeSet); } - if (sortedTypes.length === 1) { - return sortedTypes[0]; + if (typeSet.length === 1) { + return typeSet[0]; } - var id = getTypeListId(sortedTypes); + var id = getTypeListId(typeSet); var type = unionTypes[id]; if (!type) { - type = unionTypes[id] = createObjectType(16384 /* Union */ | getWideningFlagsOfTypes(sortedTypes)); - type.types = sortedTypes; + type = unionTypes[id] = createObjectType(16384 /* Union */ | getWideningFlagsOfTypes(typeSet)); + type.types = typeSet; type.reducedType = noSubtypeReduction ? undefined : type; } return type; @@ -15776,11 +16423,43 @@ var ts; } return links.resolvedType; } + // We do not perform supertype reduction on intersection types. Intersection types are created only by the & + // type operator and we can't reduce those because we want to support recursive intersection types. For example, + // a type alias of the form "type List = T & { next: List }" cannot be reduced during its declaration. + // Also, unlike union types, the order of the constituent types is preserved in order that overload resolution + // for intersections of types with signatures can be deterministic. + function getIntersectionType(types) { + if (types.length === 0) { + return emptyObjectType; + } + var typeSet = []; + addTypesToSet(typeSet, types, 32768 /* Intersection */); + if (containsTypeAny(typeSet)) { + return anyType; + } + if (typeSet.length === 1) { + return typeSet[0]; + } + var id = getTypeListId(typeSet); + var type = intersectionTypes[id]; + if (!type) { + type = intersectionTypes[id] = createObjectType(32768 /* Intersection */ | getWideningFlagsOfTypes(typeSet)); + type.types = typeSet; + } + return type; + } + function getTypeFromIntersectionTypeNode(node) { + var links = getNodeLinks(node); + if (!links.resolvedType) { + links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode)); + } + return links.resolvedType; + } function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { // Deferred resolution of members is handled by resolveObjectTypeMembers - links.resolvedType = createObjectType(32768 /* Anonymous */, node.symbol); + links.resolvedType = createObjectType(65536 /* Anonymous */, node.symbol); } return links.resolvedType; } @@ -15801,44 +16480,46 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 112 /* AnyKeyword */: + case 114 /* AnyKeyword */: return anyType; - case 123 /* StringKeyword */: + case 127 /* StringKeyword */: return stringType; - case 121 /* NumberKeyword */: + case 125 /* NumberKeyword */: return numberType; - case 113 /* BooleanKeyword */: + case 117 /* BooleanKeyword */: return booleanType; - case 124 /* SymbolKeyword */: + case 128 /* SymbolKeyword */: return esSymbolType; - case 99 /* VoidKeyword */: + case 100 /* VoidKeyword */: return voidType; case 8 /* StringLiteral */: return getTypeFromStringLiteral(node); - case 144 /* TypeReference */: + case 148 /* TypeReference */: return getTypeFromTypeReference(node); - case 143 /* TypePredicate */: + case 147 /* TypePredicate */: return booleanType; - case 179 /* ExpressionWithTypeArguments */: + case 185 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 147 /* TypeQuery */: + case 151 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 149 /* ArrayType */: + case 153 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 150 /* TupleType */: + case 154 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 151 /* UnionType */: + case 155 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 152 /* ParenthesizedType */: + case 156 /* IntersectionType */: + return getTypeFromIntersectionTypeNode(node); + case 157 /* ParenthesizedType */: return getTypeFromTypeNode(node.type); - case 145 /* FunctionType */: - case 146 /* ConstructorType */: - case 148 /* TypeLiteral */: + case 149 /* FunctionType */: + case 150 /* ConstructorType */: + case 152 /* TypeLiteral */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode - case 65 /* Identifier */: - case 128 /* QualifiedName */: + case 66 /* Identifier */: + case 132 /* QualifiedName */: var symbol = getSymbolInfo(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -15968,7 +16649,7 @@ var ts; } function instantiateAnonymousType(type, mapper) { // Mark the anonymous type as instantiated such that our infinite instantiation detection logic can recognize it - var result = createObjectType(32768 /* Anonymous */ | 65536 /* Instantiated */, type.symbol); + var result = createObjectType(65536 /* Anonymous */ | 131072 /* Instantiated */, type.symbol); result.properties = instantiateList(getPropertiesOfObjectType(type), mapper, instantiateSymbol); result.members = createSymbolTable(result.properties); result.callSignatures = instantiateList(getSignaturesOfType(type, 0 /* Call */), mapper, instantiateSignature); @@ -15986,7 +16667,7 @@ var ts; if (type.flags & 512 /* TypeParameter */) { return mapper(type); } - if (type.flags & 32768 /* Anonymous */) { + if (type.flags & 65536 /* Anonymous */) { return type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) ? instantiateAnonymousType(type, mapper) : type; } @@ -15999,33 +16680,36 @@ var ts; if (type.flags & 16384 /* Union */) { return getUnionType(instantiateList(type.types, mapper, instantiateType), true); } + if (type.flags & 32768 /* Intersection */) { + return getIntersectionType(instantiateList(type.types, mapper, instantiateType)); + } } return type; } // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 136 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 140 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 165 /* FunctionExpression */: - case 166 /* ArrowFunction */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 157 /* ObjectLiteralExpression */: + case 162 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 156 /* ArrayLiteralExpression */: + case 161 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 173 /* ConditionalExpression */: + case 179 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 172 /* BinaryExpression */: - return node.operatorToken.kind === 49 /* BarBarToken */ && + case 178 /* BinaryExpression */: + return node.operatorToken.kind === 50 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 227 /* PropertyAssignment */: + case 242 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 164 /* ParenthesizedExpression */: + case 169 /* ParenthesizedExpression */: return isContextSensitive(node.expression); } return false; @@ -16034,10 +16718,10 @@ var ts; return !node.typeParameters && node.parameters.length && !ts.forEach(node.parameters, function (p) { return p.type; }); } function getTypeWithoutSignatures(type) { - if (type.flags & 48128 /* ObjectType */) { - var resolved = resolveObjectOrUnionTypeMembers(type); + if (type.flags & 80896 /* ObjectType */) { + var resolved = resolveStructuredTypeMembers(type); if (resolved.constructSignatures.length) { - var result = createObjectType(32768 /* Anonymous */, type.symbol); + var result = createObjectType(65536 /* Anonymous */, type.symbol); result.members = resolved.members; result.properties = resolved.properties; result.callSignatures = emptyArray; @@ -16071,6 +16755,16 @@ var ts; var targetType = getOrCreateTypeFromSignature(target); return checkTypeRelatedTo(sourceType, targetType, assignableRelation, undefined); } + /** + * Checks if 'source' is related to 'target' (e.g.: is a assignable to). + * @param source The left-hand-side of the relation. + * @param target The right-hand-side of the relation. + * @param relation The relation considered. One of 'identityRelation', 'assignableRelation', or 'subTypeRelation'. + * Used as both to determine which checks are performed and as a cache of previously computed results. + * @param errorNode The node upon which all errors will be reported, if defined. + * @param headMessage If the error chain should be prepended by a head message, then headMessage will be used. + * @param containingMessageChain A chain of errors to prepend any new errors found. + */ function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain) { var errorInfo; var sourceStack; @@ -16132,37 +16826,10 @@ var ts; } } var saveErrorInfo = errorInfo; - if (source.flags & 16384 /* Union */ || target.flags & 16384 /* Union */) { - if (relation === identityRelation) { - if (source.flags & 16384 /* Union */ && target.flags & 16384 /* Union */) { - if (result = unionTypeRelatedToUnionType(source, target)) { - if (result &= unionTypeRelatedToUnionType(target, source)) { - return result; - } - } - } - else if (source.flags & 16384 /* Union */) { - if (result = unionTypeRelatedToType(source, target, reportErrors)) { - return result; - } - } - else { - if (result = unionTypeRelatedToType(target, source, reportErrors)) { - return result; - } - } - } - else { - if (source.flags & 16384 /* Union */) { - if (result = unionTypeRelatedToType(source, target, reportErrors)) { - return result; - } - } - else { - if (result = typeRelatedToUnionType(source, target, reportErrors)) { - return result; - } - } + if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { + // We have type references to same target type, see if relationship holds for all type arguments + if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + return result; } } else if (source.flags & 512 /* TypeParameter */ && target.flags & 512 /* TypeParameter */) { @@ -16170,27 +16837,63 @@ var ts; return result; } } - else if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { - // We have type references to same target type, see if relationship holds for all type arguments - if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { - return result; + else if (relation !== identityRelation) { + // Note that the "each" checks must precede the "some" checks to produce the correct results + if (source.flags & 16384 /* Union */) { + if (result = eachTypeRelatedToType(source, target, reportErrors)) { + return result; + } + } + else if (target.flags & 32768 /* Intersection */) { + if (result = typeRelatedToEachType(source, target, reportErrors)) { + return result; + } + } + else { + // It is necessary to try "each" checks on both sides because there may be nested "some" checks + // on either side that need to be prioritized. For example, A | B = (A | B) & (C | D) or + // A & B = (A & B) | (C & D). + if (source.flags & 32768 /* Intersection */) { + // If target is a union type the following check will report errors so we suppress them here + if (result = someTypeRelatedToType(source, target, reportErrors && !(target.flags & 16384 /* Union */))) { + return result; + } + } + if (target.flags & 16384 /* Union */) { + if (result = typeRelatedToSomeType(source, target, reportErrors)) { + return result; + } + } + } + } + else { + if (source.flags & 16384 /* Union */ && target.flags & 16384 /* Union */ || + source.flags & 32768 /* Intersection */ && target.flags & 32768 /* Intersection */) { + if (result = eachTypeRelatedToSomeType(source, target)) { + if (result &= eachTypeRelatedToSomeType(target, source)) { + return result; + } + } } } // Even if relationship doesn't hold for unions, type parameters, or generic type references, // it may hold in a structural comparison. // Report structural errors only if we haven't reported any errors yet var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; - // identity relation does not use apparent type + // Identity relation does not use apparent type var sourceOrApparentType = relation === identityRelation ? source : getApparentType(source); - if (sourceOrApparentType.flags & 48128 /* ObjectType */ && target.flags & 48128 /* ObjectType */) { + // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates + // to X. Failing both of those we want to check if the aggregation of A and B's members structurally + // relates to X. Thus, we include intersection types on the source side here. + if (sourceOrApparentType.flags & (80896 /* ObjectType */ | 32768 /* Intersection */) && target.flags & 80896 /* ObjectType */) { if (result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors)) { errorInfo = saveErrorInfo; return result; } } - else if (source.flags & 512 /* TypeParameter */ && sourceOrApparentType.flags & 16384 /* Union */) { + else if (source.flags & 512 /* TypeParameter */ && sourceOrApparentType.flags & 49152 /* UnionOrIntersection */) { // We clear the errors first because the following check often gives a better error than - // the union comparison above if it is applicable. + // the union or intersection comparison above if it is applicable. errorInfo = saveErrorInfo; if (result = isRelatedTo(sourceOrApparentType, target, reportErrors)) { return result; @@ -16208,12 +16911,12 @@ var ts; } return 0 /* False */; } - function unionTypeRelatedToUnionType(source, target) { + function eachTypeRelatedToSomeType(source, target) { var result = -1 /* True */; var sourceTypes = source.types; for (var _i = 0; _i < sourceTypes.length; _i++) { var sourceType = sourceTypes[_i]; - var related = typeRelatedToUnionType(sourceType, target, false); + var related = typeRelatedToSomeType(sourceType, target, false); if (!related) { return 0 /* False */; } @@ -16221,7 +16924,7 @@ var ts; } return result; } - function typeRelatedToUnionType(source, target, reportErrors) { + function typeRelatedToSomeType(source, target, reportErrors) { var targetTypes = target.types; for (var i = 0, len = targetTypes.length; i < len; i++) { var related = isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1); @@ -16231,7 +16934,30 @@ var ts; } return 0 /* False */; } - function unionTypeRelatedToType(source, target, reportErrors) { + function typeRelatedToEachType(source, target, reportErrors) { + var result = -1 /* True */; + var targetTypes = target.types; + for (var _i = 0; _i < targetTypes.length; _i++) { + var targetType = targetTypes[_i]; + var related = isRelatedTo(source, targetType, reportErrors); + if (!related) { + return 0 /* False */; + } + result &= related; + } + return result; + } + function someTypeRelatedToType(source, target, reportErrors) { + var sourceTypes = source.types; + for (var i = 0, len = sourceTypes.length; i < len; i++) { + var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); + if (related) { + return related; + } + } + return 0 /* False */; + } + function eachTypeRelatedToType(source, target, reportErrors) { var result = -1 /* True */; var sourceTypes = source.types; for (var _i = 0; _i < sourceTypes.length; _i++) { @@ -16292,7 +17018,6 @@ var ts; } var id = relation !== identityRelation || source.id < target.id ? source.id + "," + target.id : target.id + "," + source.id; var related = relation[id]; - //let related: RelationComparisonResult = undefined; // relation[id]; if (related !== undefined) { // If we computed this relation already and it was failed and reported, or if we're not being asked to elaborate // errors, we can use the cached value. Otherwise, recompute the relation @@ -16368,7 +17093,7 @@ var ts; } var result = -1 /* True */; var properties = getPropertiesOfObjectType(target); - var requireOptionalProperties = relation === subtypeRelation && !(source.flags & 262144 /* ObjectLiteral */); + var requireOptionalProperties = relation === subtypeRelation && !(source.flags & 524288 /* ObjectLiteral */); for (var _i = 0; _i < properties.length; _i++) { var targetProp = properties[_i]; var sourceProp = getPropertyOfType(source, targetProp.name); @@ -16382,22 +17107,22 @@ var ts; } } else if (!(targetProp.flags & 134217728 /* Prototype */)) { - var sourceFlags = getDeclarationFlagsFromSymbol(sourceProp); - var targetFlags = getDeclarationFlagsFromSymbol(targetProp); - if (sourceFlags & 32 /* Private */ || targetFlags & 32 /* Private */) { + var sourcePropFlags = getDeclarationFlagsFromSymbol(sourceProp); + var targetPropFlags = getDeclarationFlagsFromSymbol(targetProp); + if (sourcePropFlags & 32 /* Private */ || targetPropFlags & 32 /* Private */) { if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { - if (sourceFlags & 32 /* Private */ && targetFlags & 32 /* Private */) { + if (sourcePropFlags & 32 /* Private */ && targetPropFlags & 32 /* Private */) { reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); } else { - reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourceFlags & 32 /* Private */ ? source : target), typeToString(sourceFlags & 32 /* Private */ ? target : source)); + reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourcePropFlags & 32 /* Private */ ? source : target), typeToString(sourcePropFlags & 32 /* Private */ ? target : source)); } } return 0 /* False */; } } - else if (targetFlags & 64 /* Protected */) { + else if (targetPropFlags & 64 /* Protected */) { var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & 32 /* Class */; var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(sourceProp.parent) : undefined; var targetClass = getDeclaredTypeOfSymbol(targetProp.parent); @@ -16408,7 +17133,7 @@ var ts; return 0 /* False */; } } - else if (sourceFlags & 64 /* Protected */) { + else if (sourcePropFlags & 64 /* Protected */) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } @@ -16441,6 +17166,9 @@ var ts; return result; } function propertiesIdenticalTo(source, target) { + if (!(source.flags & 80896 /* ObjectType */ && target.flags & 80896 /* ObjectType */)) { + return 0 /* False */; + } var sourceProperties = getPropertiesOfObjectType(source); var targetProperties = getPropertiesOfObjectType(target); if (sourceProperties.length !== targetProperties.length) { @@ -16474,11 +17202,11 @@ var ts; var saveErrorInfo = errorInfo; outer: for (var _i = 0; _i < targetSignatures.length; _i++) { var t = targetSignatures[_i]; - if (!t.hasStringLiterals || target.flags & 131072 /* FromSignature */) { + if (!t.hasStringLiterals || target.flags & 262144 /* FromSignature */) { var localErrors = reportErrors; for (var _a = 0; _a < sourceSignatures.length; _a++) { var s = sourceSignatures[_a]; - if (!s.hasStringLiterals || source.flags & 131072 /* FromSignature */) { + if (!s.hasStringLiterals || source.flags & 262144 /* FromSignature */) { var related = signatureRelatedTo(s, t, localErrors); if (related) { result &= related; @@ -16666,12 +17394,12 @@ var ts; // some level beyond that. function isDeeplyNestedGeneric(type, stack, depth) { // We track type references (created by createTypeReference) and instantiated types (created by instantiateType) - if (type.flags & (4096 /* Reference */ | 65536 /* Instantiated */) && depth >= 5) { + if (type.flags & (4096 /* Reference */ | 131072 /* Instantiated */) && depth >= 5) { var symbol = type.symbol; var count = 0; for (var i = 0; i < depth; i++) { var t = stack[i]; - if (t.flags & (4096 /* Reference */ | 65536 /* Instantiated */) && t.symbol === symbol) { + if (t.flags & (4096 /* Reference */ | 131072 /* Instantiated */) && t.symbol === symbol) { count++; if (count >= 5) return true; @@ -16838,11 +17566,11 @@ var ts; return createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexType, numberIndexType); } function getWidenedType(type) { - if (type.flags & 1572864 /* RequiresWidening */) { + if (type.flags & 3145728 /* RequiresWidening */) { if (type.flags & (32 /* Undefined */ | 64 /* Null */)) { return anyType; } - if (type.flags & 262144 /* ObjectLiteral */) { + if (type.flags & 524288 /* ObjectLiteral */) { return getWidenedTypeOfObjectLiteral(type); } if (type.flags & 16384 /* Union */) { @@ -16867,11 +17595,11 @@ var ts; if (isArrayType(type)) { return reportWideningErrorsInType(type.typeArguments[0]); } - if (type.flags & 262144 /* ObjectLiteral */) { + if (type.flags & 524288 /* ObjectLiteral */) { var errorReported = false; ts.forEach(getPropertiesOfObjectType(type), function (p) { var t = getTypeOfSymbol(p); - if (t.flags & 524288 /* ContainsUndefinedOrNull */) { + if (t.flags & 1048576 /* ContainsUndefinedOrNull */) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t))); } @@ -16886,22 +17614,22 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 131 /* Parameter */: + case 135 /* Parameter */: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 203 /* FunctionDeclaration */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 165 /* FunctionExpression */: - case 166 /* ArrowFunction */: + case 210 /* FunctionDeclaration */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -16914,7 +17642,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 524288 /* ContainsUndefinedOrNull */) { + if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 1048576 /* ContainsUndefinedOrNull */) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); @@ -17010,11 +17738,11 @@ var ts; inferFromTypes(sourceTypes[i], targetTypes[i]); } } - else if (target.flags & 16384 /* Union */) { + else if (target.flags & 49152 /* UnionOrIntersection */) { var targetTypes = target.types; var typeParameterCount = 0; var typeParameter; - // First infer to each type in union that isn't a type parameter + // First infer to each type in union or intersection that isn't a type parameter for (var _i = 0; _i < targetTypes.length; _i++) { var t = targetTypes[_i]; if (t.flags & 512 /* TypeParameter */ && ts.contains(context.typeParameters, t)) { @@ -17025,23 +17753,26 @@ var ts; inferFromTypes(source, t); } } - // If union contains a single naked type parameter, make a secondary inference to that type parameter - if (typeParameterCount === 1) { + // Next, if target is a union type containing a single naked type parameter, make a + // secondary inference to that type parameter. We don't do this for intersection types + // because in a target type like Foo & T we don't know how which parts of the source type + // should be matched by Foo and which should be inferred to T. + if (target.flags & 16384 /* Union */ && typeParameterCount === 1) { inferiority++; inferFromTypes(source, typeParameter); inferiority--; } } - else if (source.flags & 16384 /* Union */) { - // Source is a union type, infer from each consituent type + else if (source.flags & 49152 /* UnionOrIntersection */) { + // Source is a union or intersection type, infer from each consituent type var sourceTypes = source.types; for (var _a = 0; _a < sourceTypes.length; _a++) { var sourceType = sourceTypes[_a]; inferFromTypes(sourceType, target); } } - else if (source.flags & 48128 /* ObjectType */ && (target.flags & (4096 /* Reference */ | 8192 /* Tuple */) || - (target.flags & 32768 /* Anonymous */) && target.symbol && target.symbol.flags & (8192 /* Method */ | 2048 /* TypeLiteral */))) { + else if (source.flags & 80896 /* ObjectType */ && (target.flags & (4096 /* Reference */ | 8192 /* Tuple */) || + (target.flags & 65536 /* Anonymous */) && target.symbol && target.symbol.flags & (8192 /* Method */ | 2048 /* TypeLiteral */ | 32 /* Class */))) { // If source is an object type, and target is a type reference, a tuple type, the type of a method, or a type literal, infer from members if (isInProcess(source, target)) { return; @@ -17170,10 +17901,10 @@ var ts; // The expression is restricted to a single identifier or a sequence of identifiers separated by periods while (node) { switch (node.kind) { - case 147 /* TypeQuery */: + case 151 /* TypeQuery */: return true; - case 65 /* Identifier */: - case 128 /* QualifiedName */: + case 66 /* Identifier */: + case 132 /* QualifiedName */: node = node.parent; continue; default: @@ -17219,12 +17950,12 @@ var ts; } return links.assignmentChecks[symbol.id] = isAssignedIn(node); function isAssignedInBinaryExpression(node) { - if (node.operatorToken.kind >= 53 /* FirstAssignment */ && node.operatorToken.kind <= 64 /* LastAssignment */) { + if (node.operatorToken.kind >= 54 /* FirstAssignment */ && node.operatorToken.kind <= 65 /* LastAssignment */) { var n = node.left; - while (n.kind === 164 /* ParenthesizedExpression */) { + while (n.kind === 169 /* ParenthesizedExpression */) { n = n.expression; } - if (n.kind === 65 /* Identifier */ && getResolvedSymbol(n) === symbol) { + if (n.kind === 66 /* Identifier */ && getResolvedSymbol(n) === symbol) { return true; } } @@ -17238,46 +17969,55 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 172 /* BinaryExpression */: + case 178 /* BinaryExpression */: return isAssignedInBinaryExpression(node); - case 201 /* VariableDeclaration */: - case 155 /* BindingElement */: + case 208 /* VariableDeclaration */: + case 160 /* BindingElement */: return isAssignedInVariableDeclaration(node); - case 153 /* ObjectBindingPattern */: - case 154 /* ArrayBindingPattern */: - case 156 /* ArrayLiteralExpression */: - case 157 /* ObjectLiteralExpression */: - case 158 /* PropertyAccessExpression */: - case 159 /* ElementAccessExpression */: - case 160 /* CallExpression */: - case 161 /* NewExpression */: - case 163 /* TypeAssertionExpression */: - case 164 /* ParenthesizedExpression */: - case 170 /* PrefixUnaryExpression */: - case 167 /* DeleteExpression */: - case 168 /* TypeOfExpression */: - case 169 /* VoidExpression */: - case 171 /* PostfixUnaryExpression */: - case 173 /* ConditionalExpression */: - case 176 /* SpreadElementExpression */: - case 182 /* Block */: - case 183 /* VariableStatement */: - case 185 /* ExpressionStatement */: - case 186 /* IfStatement */: - case 187 /* DoStatement */: - case 188 /* WhileStatement */: - case 189 /* ForStatement */: - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: - case 194 /* ReturnStatement */: - case 195 /* WithStatement */: - case 196 /* SwitchStatement */: - case 223 /* CaseClause */: - case 224 /* DefaultClause */: - case 197 /* LabeledStatement */: - case 198 /* ThrowStatement */: - case 199 /* TryStatement */: - case 226 /* CatchClause */: + case 158 /* ObjectBindingPattern */: + case 159 /* ArrayBindingPattern */: + case 161 /* ArrayLiteralExpression */: + case 162 /* ObjectLiteralExpression */: + case 163 /* PropertyAccessExpression */: + case 164 /* ElementAccessExpression */: + case 165 /* CallExpression */: + case 166 /* NewExpression */: + case 168 /* TypeAssertionExpression */: + case 186 /* AsExpression */: + case 169 /* ParenthesizedExpression */: + case 176 /* PrefixUnaryExpression */: + case 172 /* DeleteExpression */: + case 175 /* AwaitExpression */: + case 173 /* TypeOfExpression */: + case 174 /* VoidExpression */: + case 177 /* PostfixUnaryExpression */: + case 181 /* YieldExpression */: + case 179 /* ConditionalExpression */: + case 182 /* SpreadElementExpression */: + case 189 /* Block */: + case 190 /* VariableStatement */: + case 192 /* ExpressionStatement */: + case 193 /* IfStatement */: + case 194 /* DoStatement */: + case 195 /* WhileStatement */: + case 196 /* ForStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: + case 201 /* ReturnStatement */: + case 202 /* WithStatement */: + case 203 /* SwitchStatement */: + case 238 /* CaseClause */: + case 239 /* DefaultClause */: + case 204 /* LabeledStatement */: + case 205 /* ThrowStatement */: + case 206 /* TryStatement */: + case 241 /* CatchClause */: + case 230 /* JsxElement */: + case 231 /* JsxSelfClosingElement */: + case 235 /* JsxAttribute */: + case 236 /* JsxSpreadAttribute */: + case 232 /* JsxOpeningElement */: + case 237 /* JsxExpression */: return ts.forEachChild(node, isAssignedIn); } return false; @@ -17324,43 +18064,43 @@ var ts; var type = getTypeOfSymbol(symbol); // Only narrow when symbol is variable of type any or an object, union, or type parameter type if (node && symbol.flags & 3 /* Variable */) { - if (isTypeAny(type) || type.flags & (48128 /* ObjectType */ | 16384 /* Union */ | 512 /* TypeParameter */)) { + if (isTypeAny(type) || type.flags & (80896 /* ObjectType */ | 16384 /* Union */ | 512 /* TypeParameter */)) { loop: while (node.parent) { var child = node; node = node.parent; var narrowedType = type; switch (node.kind) { - case 186 /* IfStatement */: + case 193 /* IfStatement */: // In a branch of an if statement, narrow based on controlling expression if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 173 /* ConditionalExpression */: + case 179 /* ConditionalExpression */: // In a branch of a conditional expression, narrow based on controlling condition if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 172 /* BinaryExpression */: + case 178 /* BinaryExpression */: // In the right operand of an && or ||, narrow based on left operand if (child === node.right) { - if (node.operatorToken.kind === 48 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 49 /* AmpersandAmpersandToken */) { narrowedType = narrowType(type, node.left, true); } - else if (node.operatorToken.kind === 49 /* BarBarToken */) { + else if (node.operatorToken.kind === 50 /* BarBarToken */) { narrowedType = narrowType(type, node.left, false); } } break; - case 230 /* SourceFile */: - case 208 /* ModuleDeclaration */: - case 203 /* FunctionDeclaration */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 137 /* Constructor */: + case 245 /* SourceFile */: + case 215 /* ModuleDeclaration */: + case 210 /* FunctionDeclaration */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 141 /* Constructor */: // Stop at the first containing function or module declaration break loop; } @@ -17377,22 +18117,22 @@ var ts; return type; function narrowTypeByEquality(type, expr, assumeTrue) { // Check that we have 'typeof ' on the left and string literal on the right - if (expr.left.kind !== 168 /* TypeOfExpression */ || expr.right.kind !== 8 /* StringLiteral */) { + if (expr.left.kind !== 173 /* TypeOfExpression */ || expr.right.kind !== 8 /* StringLiteral */) { return type; } var left = expr.left; var right = expr.right; - if (left.expression.kind !== 65 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) { + if (left.expression.kind !== 66 /* Identifier */ || getResolvedSymbol(left.expression) !== symbol) { return type; } var typeInfo = primitiveTypeInfo[right.text]; - if (expr.operatorToken.kind === 31 /* ExclamationEqualsEqualsToken */) { + if (expr.operatorToken.kind === 32 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } if (assumeTrue) { // Assumed result is true. If check was not for a primitive type, remove all primitive types if (!typeInfo) { - return removeTypesFromUnionType(type, 258 /* StringLike */ | 132 /* NumberLike */ | 8 /* Boolean */ | 2097152 /* ESSymbol */, + return removeTypesFromUnionType(type, 258 /* StringLike */ | 132 /* NumberLike */ | 8 /* Boolean */ | 4194304 /* ESSymbol */, /*isOfTypeKind*/ true, false); } // Check was for a primitive type, return that primitive type if it is a subtype @@ -17442,7 +18182,7 @@ var ts; } function narrowTypeByInstanceof(type, expr, assumeTrue) { // Check that type is not any, assumed result is true, and we have variable symbol on the left - if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 65 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { + if (isTypeAny(type) || !assumeTrue || expr.left.kind !== 66 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { return type; } // Check that right operand is a function type with a prototype property @@ -17465,7 +18205,7 @@ var ts; if (rightType.flags & 2048 /* Interface */) { constructSignatures = resolveDeclaredMembers(rightType).declaredConstructSignatures; } - else if (rightType.flags & 32768 /* Anonymous */) { + else if (rightType.flags & 65536 /* Anonymous */) { constructSignatures = getSignaturesOfType(rightType, 1 /* Construct */); } if (constructSignatures && constructSignatures.length) { @@ -17510,27 +18250,27 @@ var ts; // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 160 /* CallExpression */: + case 165 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 164 /* ParenthesizedExpression */: + case 169 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 172 /* BinaryExpression */: + case 178 /* BinaryExpression */: var operator = expr.operatorToken.kind; - if (operator === 30 /* EqualsEqualsEqualsToken */ || operator === 31 /* ExclamationEqualsEqualsToken */) { + if (operator === 31 /* EqualsEqualsEqualsToken */ || operator === 32 /* ExclamationEqualsEqualsToken */) { return narrowTypeByEquality(type, expr, assumeTrue); } - else if (operator === 48 /* AmpersandAmpersandToken */) { + else if (operator === 49 /* AmpersandAmpersandToken */) { return narrowTypeByAnd(type, expr, assumeTrue); } - else if (operator === 49 /* BarBarToken */) { + else if (operator === 50 /* BarBarToken */) { return narrowTypeByOr(type, expr, assumeTrue); } - else if (operator === 87 /* InstanceOfKeyword */) { + else if (operator === 88 /* InstanceOfKeyword */) { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 170 /* PrefixUnaryExpression */: - if (expr.operator === 46 /* ExclamationToken */) { + case 176 /* PrefixUnaryExpression */: + if (expr.operator === 47 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -17546,8 +18286,17 @@ var ts; // will be bound to non-arrow function that contain this arrow function. This results in inconsistent behavior. // To avoid that we will give an error to users if they use arguments objects in arrow function so that they // can explicitly bound arguments objects - if (symbol === argumentsSymbol && ts.getContainingFunction(node).kind === 166 /* ArrowFunction */ && languageVersion < 2 /* ES6 */) { - error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); + if (symbol === argumentsSymbol) { + var container = ts.getContainingFunction(node); + if (container.kind === 171 /* ArrowFunction */) { + if (languageVersion < 2 /* ES6 */) { + error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); + } + } + if (node.parserContextFlags & 8 /* Await */) { + getNodeLinks(container).flags |= 4096 /* CaptureArguments */; + getNodeLinks(node).flags |= 2048 /* LexicalArguments */; + } } if (symbol.flags & 8388608 /* Alias */ && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { markAliasSymbolAsReferenced(symbol); @@ -17570,7 +18319,7 @@ var ts; function checkBlockScopedBindingCapturedInLoop(node, symbol) { if (languageVersion >= 2 /* ES6 */ || (symbol.flags & 2 /* BlockScopedVariable */) === 0 || - symbol.valueDeclaration.parent.kind === 226 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 241 /* CatchClause */) { return; } // - check if binding is used in some function @@ -17579,12 +18328,12 @@ var ts; // nesting structure: // (variable declaration or binding element) -> variable declaration list -> container var container = symbol.valueDeclaration; - while (container.kind !== 202 /* VariableDeclarationList */) { + while (container.kind !== 209 /* VariableDeclarationList */) { container = container.parent; } // get the parent of variable declaration list container = container.parent; - if (container.kind === 183 /* VariableStatement */) { + if (container.kind === 190 /* VariableStatement */) { // if parent is variable statement - get its parent container = container.parent; } @@ -17596,7 +18345,7 @@ var ts; grammarErrorOnFirstToken(current, ts.Diagnostics.Loop_contains_block_scoped_variable_0_referenced_by_a_function_in_the_loop_This_is_only_supported_in_ECMAScript_6_or_higher, ts.declarationNameToString(node)); } // mark value declaration so during emit they can have a special handling - getNodeLinks(symbol.valueDeclaration).flags |= 256 /* BlockScopedBindingInLoop */; + getNodeLinks(symbol.valueDeclaration).flags |= 16384 /* BlockScopedBindingInLoop */; break; } current = current.parent; @@ -17604,7 +18353,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 134 /* PropertyDeclaration */ || container.kind === 137 /* Constructor */) { + if (container.kind === 138 /* PropertyDeclaration */ || container.kind === 141 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -17618,32 +18367,32 @@ var ts; var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 166 /* ArrowFunction */) { + if (container.kind === 171 /* ArrowFunction */) { container = ts.getThisContainer(container, false); // When targeting es6, arrow function lexically bind "this" so we do not need to do the work of binding "this" in emitted code needToCaptureLexicalThis = (languageVersion < 2 /* ES6 */); } switch (container.kind) { - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 207 /* EnumDeclaration */: + case 214 /* EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 137 /* Constructor */: + case 141 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: if (container.flags & 128 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 129 /* ComputedPropertyName */: + case 133 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -17658,14 +18407,14 @@ var ts; } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 131 /* Parameter */) { + if (n.kind === 135 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 160 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 165 /* CallExpression */ && node.parent.expression === node; var classDeclaration = ts.getContainingClass(node); var classType = classDeclaration && getDeclaredTypeOfSymbol(getSymbolOfNode(classDeclaration)); var baseClassType = classType && getBaseTypes(classType)[0]; @@ -17682,7 +18431,7 @@ var ts; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - canUseSuperExpression = container.kind === 137 /* Constructor */; + canUseSuperExpression = container.kind === 141 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -17691,7 +18440,7 @@ var ts; // - In a static member function or static member accessor // super property access might appear in arrow functions with arbitrary deep nesting needToCaptureLexicalThis = false; - while (container && container.kind === 166 /* ArrowFunction */) { + while (container && container.kind === 171 /* ArrowFunction */) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2 /* ES6 */; } @@ -17699,34 +18448,34 @@ var ts; if (container && ts.isClassLike(container.parent)) { if (container.flags & 128 /* Static */) { canUseSuperExpression = - container.kind === 136 /* MethodDeclaration */ || - container.kind === 135 /* MethodSignature */ || - container.kind === 138 /* GetAccessor */ || - container.kind === 139 /* SetAccessor */; + container.kind === 140 /* MethodDeclaration */ || + container.kind === 139 /* MethodSignature */ || + container.kind === 142 /* GetAccessor */ || + container.kind === 143 /* SetAccessor */; } else { canUseSuperExpression = - container.kind === 136 /* MethodDeclaration */ || - container.kind === 135 /* MethodSignature */ || - container.kind === 138 /* GetAccessor */ || - container.kind === 139 /* SetAccessor */ || - container.kind === 134 /* PropertyDeclaration */ || - container.kind === 133 /* PropertySignature */ || - container.kind === 137 /* Constructor */; + container.kind === 140 /* MethodDeclaration */ || + container.kind === 139 /* MethodSignature */ || + container.kind === 142 /* GetAccessor */ || + container.kind === 143 /* SetAccessor */ || + container.kind === 138 /* PropertyDeclaration */ || + container.kind === 137 /* PropertySignature */ || + container.kind === 141 /* Constructor */; } } } if (canUseSuperExpression) { var returnType; if ((container.flags & 128 /* Static */) || isCallExpression) { - getNodeLinks(node).flags |= 32 /* SuperStatic */; + getNodeLinks(node).flags |= 512 /* SuperStatic */; returnType = getBaseConstructorTypeOfClass(classType); } else { - getNodeLinks(node).flags |= 16 /* SuperInstance */; + getNodeLinks(node).flags |= 256 /* SuperInstance */; returnType = baseClassType; } - if (container.kind === 137 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 141 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); returnType = unknownType; @@ -17740,7 +18489,7 @@ var ts; return returnType; } } - if (container && container.kind === 129 /* ComputedPropertyName */) { + if (container && container.kind === 133 /* ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { @@ -17785,7 +18534,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 131 /* Parameter */) { + if (declaration.kind === 135 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -17816,12 +18565,21 @@ var ts; } return undefined; } + function isInParameterInitializerBeforeContainingFunction(node) { + while (node.parent && !ts.isFunctionLike(node.parent)) { + if (node.parent.kind === 135 /* Parameter */ && node.parent.initializer === node) { + return true; + } + node = node.parent; + } + return false; + } function getContextualReturnType(functionDecl) { // If the containing function has a return type annotation, is a constructor, or is a get accessor whose // corresponding set accessor has a type annotation, return statements in the function are contextually typed if (functionDecl.type || - functionDecl.kind === 137 /* Constructor */ || - functionDecl.kind === 138 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 139 /* SetAccessor */))) { + functionDecl.kind === 141 /* Constructor */ || + functionDecl.kind === 142 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 143 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature @@ -17843,7 +18601,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 162 /* TaggedTemplateExpression */) { + if (template.parent.kind === 167 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -17851,13 +18609,13 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 53 /* FirstAssignment */ && operator <= 64 /* LastAssignment */) { + if (operator >= 54 /* FirstAssignment */ && operator <= 65 /* LastAssignment */) { // In an assignment expression, the right operand is contextually typed by the type of the left operand. if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); } } - else if (operator === 49 /* BarBarToken */) { + else if (operator === 50 /* BarBarToken */) { // When an || expression has a contextual type, the operands are contextually typed by that type. When an || // expression has no contextual type, the right operand is contextually typed by the type of the left operand. var type = getContextualType(binaryExpression); @@ -17897,12 +18655,12 @@ var ts; } function getTypeOfPropertyOfContextualType(type, name) { return applyToContextualType(type, function (t) { - var prop = getPropertyOfObjectType(t, name); + var prop = t.flags & 130048 /* StructuredType */ ? getPropertyOfType(t, name) : undefined; return prop ? getTypeOfSymbol(prop) : undefined; }); } function getIndexTypeOfContextualType(type, kind) { - return applyToContextualType(type, function (t) { return getIndexTypeOfObjectOrUnionType(t, kind); }); + return applyToContextualType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }); } // Return true if the given contextual type is a tuple-like type function contextualTypeIsTupleLikeType(type) { @@ -17910,7 +18668,7 @@ var ts; } // Return true if the given contextual type provides an index signature of the given kind function contextualTypeHasIndexSignature(type, kind) { - return !!(type.flags & 16384 /* Union */ ? ts.forEach(type.types, function (t) { return getIndexTypeOfObjectOrUnionType(t, kind); }) : getIndexTypeOfObjectOrUnionType(type, kind)); + return !!(type.flags & 16384 /* Union */ ? ts.forEach(type.types, function (t) { return getIndexTypeOfStructuredType(t, kind); }) : getIndexTypeOfStructuredType(type, kind)); } // In an object literal contextually typed by a type T, the contextual type of a property assignment is the type of // the matching property in T, if one exists. Otherwise, it is the type of the numeric index signature in T, if one @@ -17962,9 +18720,30 @@ var ts; var conditional = node.parent; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } + function getContextualTypeForJsxExpression(expr) { + // Contextual type only applies to JSX expressions that are in attribute assignments (not in 'Children' positions) + if (expr.parent.kind === 235 /* JsxAttribute */) { + var attrib = expr.parent; + var attrsType = getJsxElementAttributesType(attrib.parent); + if (!attrsType || isTypeAny(attrsType)) { + return undefined; + } + else { + return getTypeOfPropertyOfType(attrsType, attrib.name.text); + } + } + if (expr.kind === 236 /* JsxSpreadAttribute */) { + return getJsxElementAttributesType(expr.parent); + } + return undefined; + } // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily // be "pushed" onto a node using the contextualType property. function getContextualType(node) { + var type = getContextualTypeWorker(node); + return type && getApparentType(type); + } + function getContextualTypeWorker(node) { if (isInsideWithStatementBody(node)) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; @@ -17974,42 +18753,46 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 201 /* VariableDeclaration */: - case 131 /* Parameter */: - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: - case 155 /* BindingElement */: + case 208 /* VariableDeclaration */: + case 135 /* Parameter */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: + case 160 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 166 /* ArrowFunction */: - case 194 /* ReturnStatement */: + case 171 /* ArrowFunction */: + case 201 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 175 /* YieldExpression */: + case 181 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 160 /* CallExpression */: - case 161 /* NewExpression */: + case 165 /* CallExpression */: + case 166 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 163 /* TypeAssertionExpression */: + case 168 /* TypeAssertionExpression */: + case 186 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 172 /* BinaryExpression */: + case 178 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 227 /* PropertyAssignment */: + case 242 /* PropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 156 /* ArrayLiteralExpression */: + case 161 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 173 /* ConditionalExpression */: + case 179 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 180 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 174 /* TemplateExpression */); + case 187 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 180 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 164 /* ParenthesizedExpression */: + case 169 /* ParenthesizedExpression */: return getContextualType(parent); + case 237 /* JsxExpression */: + case 236 /* JsxSpreadAttribute */: + return getContextualTypeForJsxExpression(parent); } return undefined; } // If the given type is an object or union type, if that type has a single signature, and if // that signature is non-generic, return the signature. Otherwise return undefined. function getNonGenericSignature(type) { - var signatures = getSignaturesOfObjectOrUnionType(type, 0 /* Call */); + var signatures = getSignaturesOfStructuredType(type, 0 /* Call */); if (signatures.length === 1) { var signature = signatures[0]; if (!signature.typeParameters) { @@ -18018,7 +18801,7 @@ var ts; } } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 165 /* FunctionExpression */ || node.kind === 166 /* ArrowFunction */; + return node.kind === 170 /* FunctionExpression */ || node.kind === 171 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -18032,7 +18815,7 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 136 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 140 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node) : getContextualType(node); @@ -18049,7 +18832,7 @@ var ts; // The signature set of all constituent type with call signatures should match // So number of signatures allowed is either 0 or 1 if (signatureList && - getSignaturesOfObjectOrUnionType(current, 0 /* Call */).length > 1) { + getSignaturesOfStructuredType(current, 0 /* Call */).length > 1) { return undefined; } var signature = getNonGenericSignature(current); @@ -18088,13 +18871,13 @@ var ts; // an assignment target. Examples include 'a = xxx', '{ p: a } = xxx', '[{ p: a}] = xxx'. function isAssignmentTarget(node) { var parent = node.parent; - if (parent.kind === 172 /* BinaryExpression */ && parent.operatorToken.kind === 53 /* EqualsToken */ && parent.left === node) { + if (parent.kind === 178 /* BinaryExpression */ && parent.operatorToken.kind === 54 /* EqualsToken */ && parent.left === node) { return true; } - if (parent.kind === 227 /* PropertyAssignment */) { + if (parent.kind === 242 /* PropertyAssignment */) { return isAssignmentTarget(parent.parent); } - if (parent.kind === 156 /* ArrayLiteralExpression */) { + if (parent.kind === 161 /* ArrayLiteralExpression */) { return isAssignmentTarget(parent); } return false; @@ -18119,7 +18902,7 @@ var ts; var inDestructuringPattern = isAssignmentTarget(node); for (var _i = 0; _i < elements.length; _i++) { var e = elements[_i]; - if (inDestructuringPattern && e.kind === 176 /* SpreadElementExpression */) { + if (inDestructuringPattern && e.kind === 182 /* SpreadElementExpression */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -18127,7 +18910,7 @@ var ts; // c is represented in the tree as a spread element in an array literal. // But c really functions as a rest element, and its purpose is to provide // a contextual type for the right hand side of the assignment. Therefore, - // instead of calling checkExpression on "...c", which will give an error + // instead of calling checkExpression on "...c", which will give an error // if c is not iterable/array-like, we need to act as if we are trying to // get the contextual element type from it. So we do something similar to // getContextualTypeForElementExpression, which will crucially not error @@ -18143,7 +18926,7 @@ var ts; var type = checkExpression(e, contextualMapper); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 176 /* SpreadElementExpression */; + hasSpreadElement = hasSpreadElement || e.kind === 182 /* SpreadElementExpression */; } if (!hasSpreadElement) { var contextualType = getContextualType(node); @@ -18154,7 +18937,7 @@ var ts; return createArrayType(getUnionType(elementTypes)); } function isNumericName(name) { - return name.kind === 129 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 133 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { // It seems odd to consider an expression of type Any to result in a numeric name, @@ -18194,7 +18977,7 @@ var ts; links.resolvedType = checkExpression(node.expression); // This will allow types number, string, symbol or any. It will also allow enums, the unknown // type, and any union of these types (like string | number). - if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 /* NumberLike */ | 258 /* StringLike */ | 2097152 /* ESSymbol */)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(links.resolvedType, 132 /* NumberLike */ | 258 /* StringLike */ | 4194304 /* ESSymbol */)) { error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any); } else { @@ -18213,18 +18996,18 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var memberDecl = _a[_i]; var member = memberDecl.symbol; - if (memberDecl.kind === 227 /* PropertyAssignment */ || - memberDecl.kind === 228 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 242 /* PropertyAssignment */ || + memberDecl.kind === 243 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 227 /* PropertyAssignment */) { + if (memberDecl.kind === 242 /* PropertyAssignment */) { type = checkPropertyAssignment(memberDecl, contextualMapper); } - else if (memberDecl.kind === 136 /* MethodDeclaration */) { + else if (memberDecl.kind === 140 /* MethodDeclaration */) { type = checkObjectLiteralMethod(memberDecl, contextualMapper); } else { - ts.Debug.assert(memberDecl.kind === 228 /* ShorthandPropertyAssignment */); + ts.Debug.assert(memberDecl.kind === 243 /* ShorthandPropertyAssignment */); type = checkExpression(memberDecl.name, contextualMapper); } typeFlags |= type.flags; @@ -18244,7 +19027,7 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 138 /* GetAccessor */ || memberDecl.kind === 139 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 142 /* GetAccessor */ || memberDecl.kind === 143 /* SetAccessor */); checkAccessorDeclaration(memberDecl); } if (!ts.hasDynamicName(memberDecl)) { @@ -18255,7 +19038,7 @@ var ts; var stringIndexType = getIndexType(0 /* String */); var numberIndexType = getIndexType(1 /* Number */); var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexType, numberIndexType); - result.flags |= 262144 /* ObjectLiteral */ | 1048576 /* ContainsObjectLiteral */ | (typeFlags & 524288 /* ContainsUndefinedOrNull */); + result.flags |= 524288 /* ObjectLiteral */ | 2097152 /* ContainsObjectLiteral */ | (typeFlags & 1048576 /* ContainsUndefinedOrNull */); return result; function getIndexType(kind) { if (contextualType && contextualTypeHasIndexSignature(contextualType, kind)) { @@ -18280,50 +19063,475 @@ var ts; return undefined; } } + function checkJsxSelfClosingElement(node) { + checkJsxOpeningLikeElement(node); + return jsxElementType || anyType; + } + function tagNamesAreEquivalent(lhs, rhs) { + if (lhs.kind !== rhs.kind) { + return false; + } + if (lhs.kind === 66 /* Identifier */) { + return lhs.text === rhs.text; + } + return lhs.right.text === rhs.right.text && + tagNamesAreEquivalent(lhs.left, rhs.left); + } + function checkJsxElement(node) { + // Check that the closing tag matches + if (!tagNamesAreEquivalent(node.openingElement.tagName, node.closingElement.tagName)) { + error(node.closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNode(node.openingElement.tagName)); + } + // Check attributes + checkJsxOpeningLikeElement(node.openingElement); + // Check children + for (var _i = 0, _a = node.children; _i < _a.length; _i++) { + var child = _a[_i]; + switch (child.kind) { + case 237 /* JsxExpression */: + checkJsxExpression(child); + break; + case 230 /* JsxElement */: + checkJsxElement(child); + break; + case 231 /* JsxSelfClosingElement */: + checkJsxSelfClosingElement(child); + break; + default: + // No checks for JSX Text + ts.Debug.assert(child.kind === 233 /* JsxText */); + } + } + return jsxElementType || anyType; + } + /** + * Returns true iff the JSX element name would be a valid JS identifier, ignoring restrictions about keywords not being identifiers + */ + function isUnhyphenatedJsxName(name) { + // - is the only character supported in JSX attribute names that isn't valid in JavaScript identifiers + return name.indexOf("-") < 0; + } + /** + * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name + */ + function isJsxIntrinsicIdentifier(tagName) { + if (tagName.kind === 132 /* QualifiedName */) { + return false; + } + else { + return ts.isIntrinsicJsxName(tagName.text); + } + } + function checkJsxAttribute(node, elementAttributesType, nameTable) { + var correspondingPropType = undefined; + // Look up the corresponding property for this attribute + if (elementAttributesType === emptyObjectType && isUnhyphenatedJsxName(node.name.text)) { + // If there is no 'props' property, you may not have non-"data-" attributes + error(node.parent, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, getJsxElementPropertiesName()); + } + else if (elementAttributesType && !isTypeAny(elementAttributesType)) { + var correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); + correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); + // If there's no corresponding property with this name, error + if (!correspondingPropType && isUnhyphenatedJsxName(node.name.text)) { + error(node.name, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); + return unknownType; + } + } + var exprType; + if (node.initializer) { + exprType = checkExpression(node.initializer); + } + else { + // is sugar for + exprType = booleanType; + } + if (correspondingPropType) { + checkTypeAssignableTo(exprType, correspondingPropType, node); + } + nameTable[node.name.text] = true; + return exprType; + } + function checkJsxSpreadAttribute(node, elementAttributesType, nameTable) { + var type = checkExpression(node.expression); + var props = getPropertiesOfType(type); + for (var _i = 0; _i < props.length; _i++) { + var prop = props[_i]; + // Is there a corresponding property in the element attributes type? Skip checking of properties + // that have already been assigned to, as these are not actually pushed into the resulting type + if (!nameTable[prop.name]) { + var targetPropSym = getPropertyOfType(elementAttributesType, prop.name); + if (targetPropSym) { + var msg = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property, prop.name); + checkTypeAssignableTo(getTypeOfSymbol(prop), getTypeOfSymbol(targetPropSym), node, undefined, msg); + } + nameTable[prop.name] = true; + } + } + return type; + } + /// Returns the type JSX.IntrinsicElements. May return `unknownType` if that type is not present. + function getJsxIntrinsicElementsType() { + if (!jsxIntrinsicElementsType) { + jsxIntrinsicElementsType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.IntrinsicElements) || unknownType; + } + return jsxIntrinsicElementsType; + } + /// Given a JSX opening element or self-closing element, return the symbol of the property that the tag name points to if + /// this is an intrinsic tag. This might be a named + /// property of the IntrinsicElements interface, or its string indexer. + /// If this is a class-based tag (otherwise returns undefined), returns the symbol of the class + /// type or factory function. + /// Otherwise, returns unknownSymbol. + function getJsxElementTagSymbol(node) { + var flags = 8 /* UnknownElement */; + var links = getNodeLinks(node); + if (!links.resolvedSymbol) { + if (isJsxIntrinsicIdentifier(node.tagName)) { + links.resolvedSymbol = lookupIntrinsicTag(node); + } + else { + links.resolvedSymbol = lookupClassTag(node); + } + } + return links.resolvedSymbol; + function lookupIntrinsicTag(node) { + var intrinsicElementsType = getJsxIntrinsicElementsType(); + if (intrinsicElementsType !== unknownType) { + // Property case + var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.text); + if (intrinsicProp) { + links.jsxFlags |= 1 /* IntrinsicNamedElement */; + return intrinsicProp; + } + // Intrinsic string indexer case + var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0 /* String */); + if (indexSignatureType) { + links.jsxFlags |= 2 /* IntrinsicIndexedElement */; + return intrinsicElementsType.symbol; + } + // Wasn't found + error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, node.tagName.text, 'JSX.' + JsxNames.IntrinsicElements); + return unknownSymbol; + } + else { + if (compilerOptions.noImplicitAny) { + error(node, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, JsxNames.IntrinsicElements); + } + } + } + function lookupClassTag(node) { + var valueSymbol; + // Look up the value in the current scope + if (node.tagName.kind === 66 /* Identifier */) { + var tag = node.tagName; + var sym = getResolvedSymbol(tag); + valueSymbol = sym.exportSymbol || sym; + } + else { + valueSymbol = checkQualifiedName(node.tagName).symbol; + } + if (valueSymbol && valueSymbol !== unknownSymbol) { + links.jsxFlags |= 4 /* ClassElement */; + getSymbolLinks(valueSymbol).referenced = true; + } + return valueSymbol || unknownSymbol; + } + } + /** + * Given a JSX element that is a class element, finds the Element Instance Type. If the + * element is not a class element, or the class element type cannot be determined, returns 'undefined'. + * For example, in the element , the element instance type is `MyClass` (not `typeof MyClass`). + */ + function getJsxElementInstanceType(node) { + if (!(getNodeLinks(node).jsxFlags & 4 /* ClassElement */)) { + // There is no such thing as an instance type for a non-class element + return undefined; + } + var classSymbol = getJsxElementTagSymbol(node); + if (classSymbol === unknownSymbol) { + // Couldn't find the class instance type. Error has already been issued + return anyType; + } + var valueType = getTypeOfSymbol(classSymbol); + if (isTypeAny(valueType)) { + // Short-circuit if the class tag is using an element type 'any' + return anyType; + } + // Resolve the signatures, preferring constructors + var signatures = getSignaturesOfType(valueType, 1 /* Construct */); + if (signatures.length === 0) { + // No construct signatures, try call signatures + signatures = getSignaturesOfType(valueType, 0 /* Call */); + if (signatures.length === 0) { + // We found no signatures at all, which is an error + error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); + return undefined; + } + } + // Check that the constructor/factory returns an object type + var returnType = getUnionType(signatures.map(function (s) { return getReturnTypeOfSignature(s); })); + if (!isTypeAny(returnType) && !(returnType.flags & 80896 /* ObjectType */)) { + error(node.tagName, ts.Diagnostics.The_return_type_of_a_JSX_element_constructor_must_return_an_object_type); + return undefined; + } + // Issue an error if this return type isn't assignable to JSX.ElementClass + var elemClassType = getJsxGlobalElementClassType(); + if (elemClassType) { + checkTypeRelatedTo(returnType, elemClassType, assignableRelation, node, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + } + return returnType; + } + /// e.g. "props" for React.d.ts, + /// or 'undefined' if ElementAttributesPropery doesn't exist (which means all + /// non-intrinsic elements' attributes type is 'any'), + /// or '' if it has 0 properties (which means every + /// non-instrinsic elements' attributes type is the element instance type) + function getJsxElementPropertiesName() { + // JSX + var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1536 /* Namespace */, undefined); + // JSX.ElementAttributesProperty [symbol] + var attribsPropTypeSym = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.ElementAttributesPropertyNameContainer, 793056 /* Type */); + // JSX.ElementAttributesProperty [type] + var attribPropType = attribsPropTypeSym && getDeclaredTypeOfSymbol(attribsPropTypeSym); + // The properites of JSX.ElementAttributesProperty + var attribProperties = attribPropType && getPropertiesOfType(attribPropType); + if (attribProperties) { + // Element Attributes has zero properties, so the element attributes type will be the class instance type + if (attribProperties.length === 0) { + return ""; + } + else if (attribProperties.length === 1) { + return attribProperties[0].name; + } + else { + error(attribsPropTypeSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, JsxNames.ElementAttributesPropertyNameContainer); + return undefined; + } + } + else { + // No interface exists, so the element attributes type will be an implicit any + return undefined; + } + } + /** + * Given an opening/self-closing element, get the 'element attributes type', i.e. the type that tells + * us which attributes are valid on a given element. + */ + function getJsxElementAttributesType(node) { + var links = getNodeLinks(node); + if (!links.resolvedJsxType) { + var sym = getJsxElementTagSymbol(node); + if (links.jsxFlags & 4 /* ClassElement */) { + var elemInstanceType = getJsxElementInstanceType(node); + if (isTypeAny(elemInstanceType)) { + return links.resolvedJsxType = anyType; + } + var propsName = getJsxElementPropertiesName(); + if (propsName === undefined) { + // There is no type ElementAttributesProperty, return 'any' + return links.resolvedJsxType = anyType; + } + else if (propsName === "") { + // If there is no e.g. 'props' member in ElementAttributesProperty, use the element class type instead + return links.resolvedJsxType = elemInstanceType; + } + else { + var attributesType = getTypeOfPropertyOfType(elemInstanceType, propsName); + if (!attributesType) { + // There is no property named 'props' on this instance type + return links.resolvedJsxType = emptyObjectType; + } + else if (isTypeAny(attributesType) || (attributesType === unknownType)) { + return links.resolvedJsxType = attributesType; + } + else if (!(attributesType.flags & 80896 /* ObjectType */)) { + error(node.tagName, ts.Diagnostics.JSX_element_attributes_type_0_must_be_an_object_type, typeToString(attributesType)); + return links.resolvedJsxType = anyType; + } + else { + return links.resolvedJsxType = attributesType; + } + } + } + else if (links.jsxFlags & 1 /* IntrinsicNamedElement */) { + return links.resolvedJsxType = getTypeOfSymbol(sym); + } + else if (links.jsxFlags & 2 /* IntrinsicIndexedElement */) { + return links.resolvedJsxType = getIndexTypeOfSymbol(sym, 0 /* String */); + } + else { + // Resolution failed, so we don't know + return links.resolvedJsxType = anyType; + } + } + return links.resolvedJsxType; + } + /** + * Given a JSX attribute, returns the symbol for the corresponds property + * of the element attributes type. Will return unknownSymbol for attributes + * that have no matching element attributes type property. + */ + function getJsxAttributePropertySymbol(attrib) { + var attributesType = getJsxElementAttributesType(attrib.parent); + var prop = getPropertyOfType(attributesType, attrib.name.text); + return prop || unknownSymbol; + } + var jsxElementClassType = undefined; + function getJsxGlobalElementClassType() { + if (!jsxElementClassType) { + jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); + } + return jsxElementClassType; + } + /// Returns all the properties of the Jsx.IntrinsicElements interface + function getJsxIntrinsicTagNames() { + var intrinsics = getJsxIntrinsicElementsType(); + return intrinsics ? getPropertiesOfType(intrinsics) : emptyArray; + } + function checkJsxPreconditions(errorNode) { + // Preconditions for using JSX + if ((compilerOptions.jsx || 0 /* None */) === 0 /* None */) { + error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided); + } + if (jsxElementType === undefined) { + if (compilerOptions.noImplicitAny) { + error(errorNode, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist); + } + } + } + function checkJsxOpeningLikeElement(node) { + checkGrammarJsxElement(node); + checkJsxPreconditions(node); + // If we're compiling under --jsx react, the symbol 'React' should + // be marked as 'used' so we don't incorrectly elide its import. And if there + // is no 'React' symbol in scope, we should issue an error. + if (compilerOptions.jsx === 2 /* React */) { + var reactSym = resolveName(node.tagName, 'React', 107455 /* Value */, ts.Diagnostics.Cannot_find_name_0, 'React'); + if (reactSym) { + getSymbolLinks(reactSym).referenced = true; + } + } + var targetAttributesType = getJsxElementAttributesType(node); + var nameTable = {}; + // Process this array in right-to-left order so we know which + // attributes (mostly from spreads) are being overwritten and + // thus should have their types ignored + var sawSpreadedAny = false; + for (var i = node.attributes.length - 1; i >= 0; i--) { + if (node.attributes[i].kind === 235 /* JsxAttribute */) { + checkJsxAttribute((node.attributes[i]), targetAttributesType, nameTable); + } + else { + ts.Debug.assert(node.attributes[i].kind === 236 /* JsxSpreadAttribute */); + var spreadType = checkJsxSpreadAttribute((node.attributes[i]), targetAttributesType, nameTable); + if (isTypeAny(spreadType)) { + sawSpreadedAny = true; + } + } + } + // Check that all required properties have been provided. If an 'any' + // was spreaded in, though, assume that it provided all required properties + if (targetAttributesType && !sawSpreadedAny) { + var targetProperties = getPropertiesOfType(targetAttributesType); + for (var i = 0; i < targetProperties.length; i++) { + if (!(targetProperties[i].flags & 536870912 /* Optional */) && + nameTable[targetProperties[i].name] === undefined) { + error(node, ts.Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType)); + } + } + } + } + function checkJsxExpression(node) { + if (node.expression) { + return checkExpression(node.expression); + } + else { + return unknownType; + } + } // If a symbol is a synthesized symbol with no value declaration, we assume it is a property. Example of this are the synthesized // '.prototype' property as well as synthesized tuple index properties. function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 134 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 138 /* PropertyDeclaration */; } function getDeclarationFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : s.flags & 134217728 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; } + /** + * Check whether the requested property access is valid. + * Returns true if node is a valid property access, and false otherwise. + * @param node The node to be checked. + * @param left The left hand side of the property access (e.g.: the super in `super.foo`). + * @param type The type of left. + * @param prop The symbol for the right hand side of the property access. + */ function checkClassPropertyAccess(node, left, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); - // Public properties are always accessible + var declaringClass = getDeclaredTypeOfSymbol(prop.parent); + if (left.kind === 92 /* SuperKeyword */) { + var errorNode = node.kind === 163 /* PropertyAccessExpression */ ? + node.name : + node.right; + // TS 1.0 spec (April 2014): 4.8.2 + // - In a constructor, instance member function, instance member accessor, or + // instance member variable initializer where this references a derived class instance, + // a super property access is permitted and must specify a public instance member function of the base class. + // - In a static member function or static member accessor + // where this references the constructor function object of a derived class, + // a super property access is permitted and must specify a public static member function of the base class. + if (getDeclarationKindFromSymbol(prop) !== 140 /* MethodDeclaration */) { + // `prop` refers to a *property* declared in the super class + // rather than a *method*, so it does not satisfy the above criteria. + error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + return false; + } + if (flags & 256 /* Abstract */) { + // A method cannot be accessed in a super property access if the method is abstract. + // This error could mask a private property access error. But, a member + // cannot simultaneously be private and abstract, so this will trigger an + // additional error elsewhere. + error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(declaringClass)); + return false; + } + } + // Public properties are otherwise accessible. if (!(flags & (32 /* Private */ | 64 /* Protected */))) { - return; + return true; } // Property is known to be private or protected at this point // Get the declaring and enclosing class instance types var enclosingClassDeclaration = ts.getContainingClass(node); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; - var declaringClass = getDeclaredTypeOfSymbol(prop.parent); // Private property is accessible if declaring and enclosing class are the same if (flags & 32 /* Private */) { if (declaringClass !== enclosingClass) { error(node, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); + return false; } - return; + return true; } // Property is known to be protected at this point // All protected properties of a supertype are accessible in a super access - if (left.kind === 91 /* SuperKeyword */) { - return; + if (left.kind === 92 /* SuperKeyword */) { + return true; } // A protected property is accessible in the declaring class and classes derived from it if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { error(node, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass)); - return; + return false; } // No further restrictions for static properties if (flags & 128 /* Static */) { - return; + return true; } // An instance property must be accessed through an instance of the enclosing class + // TODO: why is the first part of this check here? if (!(getTargetType(type).flags & (1024 /* Class */ | 2048 /* Interface */) && 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; } + return true; } function checkPropertyAccessExpression(node) { return checkPropertyAccessExpressionOrQualifiedName(node, node.expression, node.name); @@ -18350,38 +19558,19 @@ var ts; } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32 /* Class */) { - // TS 1.0 spec (April 2014): 4.8.2 - // - In a constructor, instance member function, instance member accessor, or - // instance member variable initializer where this references a derived class instance, - // a super property access is permitted and must specify a public instance member function of the base class. - // - In a static member function or static member accessor - // where this references the constructor function object of a derived class, - // a super property access is permitted and must specify a public static member function of the base class. - if (left.kind === 91 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 136 /* MethodDeclaration */) { - error(right, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); - } - else { - checkClassPropertyAccess(node, left, type, prop); - } + checkClassPropertyAccess(node, left, type, prop); } return getTypeOfSymbol(prop); } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 158 /* PropertyAccessExpression */ + var left = node.kind === 163 /* PropertyAccessExpression */ ? node.expression : node.left; var type = checkExpression(left); if (type !== unknownType && !isTypeAny(type)) { var prop = getPropertyOfType(getWidenedType(type), propertyName); if (prop && prop.parent && prop.parent.flags & 32 /* Class */) { - if (left.kind === 91 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 136 /* MethodDeclaration */) { - return false; - } - else { - var modificationCount = diagnostics.getModificationCount(); - checkClassPropertyAccess(node, left, type, prop); - return diagnostics.getModificationCount() === modificationCount; - } + return checkClassPropertyAccess(node, left, type, prop); } } return true; @@ -18390,7 +19579,7 @@ var ts; // Grammar checking if (!node.argumentExpression) { var sourceFile = getSourceFile(node); - if (node.parent.kind === 161 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 166 /* NewExpression */ && node.parent.expression === node) { var start = ts.skipTrivia(sourceFile.text, node.expression.end); var end = node.end; grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); @@ -18423,21 +19612,21 @@ var ts; // - Otherwise, if IndexExpr is of type Any, the String or Number primitive type, or an enum type, the property access is of type Any. // See if we can index as a property. if (node.argumentExpression) { - var name_10 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); - if (name_10 !== undefined) { - var prop = getPropertyOfType(objectType, name_10); + var name_11 = getPropertyNameForIndexedAccess(node.argumentExpression, indexType); + if (name_11 !== undefined) { + var prop = getPropertyOfType(objectType, name_11); if (prop) { getNodeLinks(node).resolvedSymbol = prop; return getTypeOfSymbol(prop); } else if (isConstEnum) { - error(node.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_const_enum_1, name_10, symbolToString(objectType.symbol)); + error(node.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_const_enum_1, name_11, symbolToString(objectType.symbol)); return unknownType; } } } // Check for compatible indexer types. - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 /* StringLike */ | 132 /* NumberLike */ | 2097152 /* ESSymbol */)) { + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 258 /* StringLike */ | 132 /* NumberLike */ | 4194304 /* ESSymbol */)) { // Try to use a number indexer. if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, 132 /* NumberLike */)) { var numberIndexType = getIndexTypeOfType(objectType, 1 /* Number */); @@ -18492,7 +19681,7 @@ var ts; return false; } // Make sure the property type is the primitive symbol type - if ((expressionType.flags & 2097152 /* ESSymbol */) === 0) { + if ((expressionType.flags & 4194304 /* ESSymbol */) === 0) { if (reportError) { error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression)); } @@ -18519,10 +19708,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 162 /* TaggedTemplateExpression */) { + if (node.kind === 167 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 132 /* Decorator */) { + else if (node.kind !== 136 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -18588,7 +19777,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 176 /* SpreadElementExpression */) { + if (arg && arg.kind === 182 /* SpreadElementExpression */) { return i; } } @@ -18600,13 +19789,13 @@ var ts; var callIsIncomplete; // In incomplete call we want to be lenient when we have too few arguments var isDecorator; var spreadArgIndex = -1; - if (node.kind === 162 /* TaggedTemplateExpression */) { + if (node.kind === 167 /* TaggedTemplateExpression */) { var tagExpression = node; // Even if the call is incomplete, we'll have a missing expression as our last argument, // so we can say the count is just the arg list length adjustedArgCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 174 /* TemplateExpression */) { + if (tagExpression.template.kind === 180 /* TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var templateExpression = tagExpression.template; @@ -18623,7 +19812,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 132 /* Decorator */) { + else if (node.kind === 136 /* Decorator */) { isDecorator = true; typeArguments = undefined; adjustedArgCount = getEffectiveArgumentCount(node, undefined, signature); @@ -18632,7 +19821,7 @@ var ts; var callExpression = node; if (!callExpression.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(callExpression.kind === 161 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 166 /* NewExpression */); return signature.minArgumentCount === 0; } // For IDE scenarios we may have an incomplete call, so a trailing comma is tantamount to adding another argument. @@ -18664,8 +19853,8 @@ var ts; } // If type has a single call signature and no other members, return that signature. Otherwise, return undefined. function getSingleCallSignature(type) { - if (type.flags & 48128 /* ObjectType */) { - var resolved = resolveObjectOrUnionTypeMembers(type); + if (type.flags & 80896 /* ObjectType */) { + var resolved = resolveStructuredTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && resolved.properties.length === 0 && !resolved.stringIndexType && !resolved.numberIndexType) { return resolved.callSignatures[0]; @@ -18711,10 +19900,10 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 178 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 184 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); - // If the effective argument type is 'undefined', there is no synthetic type + // If the effective argument type is 'undefined', there is no synthetic type // for the argument. In that case, we should check the argument. if (argType === undefined) { // For context sensitive arguments we pass the identityMapper, which is a signal to treat all @@ -18770,11 +19959,11 @@ var ts; for (var i = 0; i < argCount; i++) { var arg = getEffectiveArgument(node, args, i); // If the effective argument is 'undefined', then it is an argument that is present but is synthetic. - if (arg === undefined || arg.kind !== 178 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 184 /* OmittedExpression */) { // Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter) var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i, arg); - // If the effective argument type is 'undefined', there is no synthetic type + // If the effective argument type is 'undefined', there is no synthetic type // for the argument. In that case, we should check the argument. if (argType === undefined) { argType = arg.kind === 8 /* StringLiteral */ && !reportErrors @@ -18802,16 +19991,16 @@ var ts; */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 162 /* TaggedTemplateExpression */) { + if (node.kind === 167 /* TaggedTemplateExpression */) { var template = node.template; args = [undefined]; - if (template.kind === 174 /* TemplateExpression */) { + if (template.kind === 180 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 132 /* Decorator */) { + else if (node.kind === 136 /* Decorator */) { // For a decorator, we return undefined as we will determine // the number and types of arguments for a decorator using // `getEffectiveArgumentCount` and `getEffectiveArgumentType` below. @@ -18836,26 +20025,26 @@ var ts; * Otherwise, the argument count is the length of the 'args' array. */ function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 132 /* Decorator */) { + if (node.kind === 136 /* Decorator */) { switch (node.parent.kind) { - case 204 /* ClassDeclaration */: - case 177 /* ClassExpression */: + case 211 /* ClassDeclaration */: + case 183 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; - case 134 /* PropertyDeclaration */: - // A property declaration decorator will have two arguments (see + case 138 /* PropertyDeclaration */: + // A property declaration decorator will have two arguments (see // `PropertyDecorator` in core.d.ts) return 2; - case 136 /* MethodDeclaration */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: + case 140 /* MethodDeclaration */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts) - // If the method decorator signature only accepts a target and a key, we will only + // If the method decorator signature only accepts a target and a key, we will only // type check those arguments. return signature.parameters.length >= 3 ? 3 : 2; - case 131 /* Parameter */: - // A parameter declaration decorator will have three arguments (see + case 135 /* Parameter */: + // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts) return 3; } @@ -18879,28 +20068,28 @@ var ts; function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. switch (node.kind) { - case 204 /* ClassDeclaration */: - case 177 /* ClassExpression */: - // For a class decorator, the `target` is the type of the class (e.g. the + case 211 /* ClassDeclaration */: + case 183 /* ClassExpression */: + // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class) var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); - case 131 /* Parameter */: - // For a parameter decorator, the `target` is the parent type of the - // parameter's containing method. + case 135 /* Parameter */: + // For a parameter decorator, the `target` is the parent type of the + // parameter's containing method. node = node.parent; - if (node.kind === 137 /* Constructor */) { + if (node.kind === 141 /* Constructor */) { var classSymbol_1 = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol_1); } // fall-through - case 134 /* PropertyDeclaration */: - case 136 /* MethodDeclaration */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: + case 138 /* PropertyDeclaration */: + case 140 /* MethodDeclaration */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: // For a property or method decorator, the `target` is the // "static"-side type of the parent of the member if the member is - // declared "static"; otherwise, it is the "instance"-side type of the + // declared "static"; otherwise, it is the "instance"-side type of the // parent of the member. return getParentTypeOfClassElement(node); default: @@ -18926,35 +20115,35 @@ var ts; function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` switch (node.kind) { - case 204 /* ClassDeclaration */: + case 211 /* ClassDeclaration */: ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; - case 131 /* Parameter */: + case 135 /* Parameter */: node = node.parent; - if (node.kind === 137 /* Constructor */) { + if (node.kind === 141 /* Constructor */) { // For a constructor parameter decorator, the `propertyKey` will be `undefined`. return anyType; } // For a non-constructor parameter decorator, the `propertyKey` will be either // a string or a symbol, based on the name of the parameter's containing method. // fall-through - case 134 /* PropertyDeclaration */: - case 136 /* MethodDeclaration */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: + case 138 /* PropertyDeclaration */: + case 140 /* MethodDeclaration */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: // The `propertyKey` for a property or method decorator will be a - // string literal type if the member name is an identifier, number, or string; + // string literal type if the member name is an identifier, number, or string; // otherwise, if the member name is a computed property name it will // be either string or symbol. var element = node; switch (element.name.kind) { - case 65 /* Identifier */: + case 66 /* Identifier */: case 7 /* NumericLiteral */: case 8 /* StringLiteral */: return getStringLiteralType(element.name); - case 129 /* ComputedPropertyName */: + case 133 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(element.name); - if (allConstituentTypesHaveKind(nameType, 2097152 /* ESSymbol */)) { + if (allConstituentTypesHaveKind(nameType, 4194304 /* ESSymbol */)) { return nameType; } else { @@ -18980,18 +20169,18 @@ var ts; // The third argument to a decorator is either its `descriptor` for a method decorator // or its `parameterIndex` for a paramter decorator switch (node.kind) { - case 204 /* ClassDeclaration */: + case 211 /* ClassDeclaration */: ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; - case 131 /* Parameter */: + case 135 /* Parameter */: // The `parameterIndex` for a parameter decorator is always a number return numberType; - case 134 /* PropertyDeclaration */: + case 138 /* PropertyDeclaration */: ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; - case 136 /* MethodDeclaration */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: + case 140 /* MethodDeclaration */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` // for the type of the member. var propertyType = getTypeOfNode(node); @@ -19021,17 +20210,17 @@ var ts; * Gets the effective argument type for an argument in a call expression. */ function getEffectiveArgumentType(node, argIndex, arg) { - // Decorators provide special arguments, a tagged template expression provides + // Decorators provide special arguments, a tagged template expression provides // a special first argument, and string literals get string literal types // unless we're reporting errors - if (node.kind === 132 /* Decorator */) { + if (node.kind === 136 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 162 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 167 /* TaggedTemplateExpression */) { return globalTemplateStringsArrayType; } // This is not a synthetic argument, so we return 'undefined' - // to signal that the caller needs to check the argument. + // to signal that the caller needs to check the argument. return undefined; } /** @@ -19039,8 +20228,8 @@ var ts; */ function getEffectiveArgument(node, args, argIndex) { // For a decorator or the first argument of a tagged template expression we return undefined. - if (node.kind === 132 /* Decorator */ || - (argIndex === 0 && node.kind === 162 /* TaggedTemplateExpression */)) { + if (node.kind === 136 /* Decorator */ || + (argIndex === 0 && node.kind === 167 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; @@ -19049,11 +20238,11 @@ var ts; * Gets the error node to use when reporting errors for an effective argument. */ function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 132 /* Decorator */) { + if (node.kind === 136 /* Decorator */) { // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 162 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 167 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -19062,13 +20251,13 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 162 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 132 /* Decorator */; + var isTaggedTemplate = node.kind === 167 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 136 /* Decorator */; var typeArguments; if (!isTaggedTemplate && !isDecorator) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (node.expression.kind !== 91 /* SuperKeyword */) { + if (node.expression.kind !== 92 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } @@ -19092,7 +20281,7 @@ var ts; // For a tagged template, then the first argument be 'undefined' if necessary // because it represents a TemplateStringsArray. // - // For a decorator, no arguments are susceptible to contextual typing due to the fact + // For a decorator, no arguments are susceptible to contextual typing due to the fact // decorators are applied to a declaration by the emitter, and not to an expression. var excludeArgument; if (!isDecorator) { @@ -19271,7 +20460,7 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 91 /* SuperKeyword */) { + if (node.expression.kind === 92 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated @@ -19331,7 +20520,7 @@ var ts; } } var expressionType = checkExpression(node.expression); - // If ConstructExpr's apparent type(section 3.8.1) is an object type with one or + // If expressionType's apparent type(section 3.8.1) is an object type with one or // more construct signatures, the expression is processed in the same manner as a // function call, but using the construct signatures as the initial set of candidate // signatures for overload resolution. The result type of the function call becomes @@ -19341,8 +20530,17 @@ var ts; // Another error has already been reported return resolveErrorCall(node); } + // If the expression is a class of abstract type, then it cannot be instantiated. + // Note, only class declarations can be declared abstract. + // In the case of a merged class-module or class-interface declaration, + // only the class declaration node will have the Abstract flag set. + var valueDecl = expressionType.symbol && ts.getDeclarationOfKind(expressionType.symbol, 211 /* ClassDeclaration */); + if (valueDecl && valueDecl.flags & 256 /* Abstract */) { + error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(valueDecl.name)); + return resolveErrorCall(node); + } // TS 1.0 spec: 4.11 - // If ConstructExpr is of type Any, Args can be any argument + // If expressionType is of type Any, Args can be any argument // list and the result of the operation is of type Any. if (isTypeAny(expressionType)) { if (node.typeArguments) { @@ -19358,7 +20556,7 @@ var ts; if (constructSignatures.length) { return resolveCall(node, constructSignatures, candidatesOutArray); } - // If ConstructExpr's apparent type is an object type with no construct signatures but + // If expressionType's apparent type is an object type with no construct signatures but // one or more call signatures, the expression is processed as a function call. A compile-time // error occurs if the result of the function call is not Void. The type of the result of the // operation is Any. @@ -19395,16 +20593,16 @@ var ts; */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 204 /* ClassDeclaration */: - case 177 /* ClassExpression */: + case 211 /* ClassDeclaration */: + case 183 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 131 /* Parameter */: + case 135 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 134 /* PropertyDeclaration */: + case 138 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 136 /* MethodDeclaration */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: + case 140 /* MethodDeclaration */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -19441,16 +20639,16 @@ var ts; // to correctly fill the candidatesOutArray. if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - if (node.kind === 160 /* CallExpression */) { + if (node.kind === 165 /* CallExpression */) { links.resolvedSignature = resolveCallExpression(node, candidatesOutArray); } - else if (node.kind === 161 /* NewExpression */) { + else if (node.kind === 166 /* NewExpression */) { links.resolvedSignature = resolveNewExpression(node, candidatesOutArray); } - else if (node.kind === 162 /* TaggedTemplateExpression */) { + else if (node.kind === 167 /* TaggedTemplateExpression */) { links.resolvedSignature = resolveTaggedTemplateExpression(node, candidatesOutArray); } - else if (node.kind === 132 /* Decorator */) { + else if (node.kind === 136 /* Decorator */) { links.resolvedSignature = resolveDecorator(node, candidatesOutArray); } else { @@ -19459,19 +20657,24 @@ var ts; } return links.resolvedSignature; } + /** + * Syntactically and semantically checks a call or new expression. + * @param node The call/new expression to be checked. + * @returns On success, the expression's signature's return type. On failure, anyType. + */ function checkCallExpression(node) { // Grammar checking; stop grammar-checking if checkGrammarTypeArguments return true checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 91 /* SuperKeyword */) { + if (node.expression.kind === 92 /* SuperKeyword */) { return voidType; } - if (node.kind === 161 /* NewExpression */) { + if (node.kind === 166 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 137 /* Constructor */ && - declaration.kind !== 141 /* ConstructSignature */ && - declaration.kind !== 146 /* ConstructorType */) { + declaration.kind !== 141 /* Constructor */ && + declaration.kind !== 145 /* ConstructSignature */ && + declaration.kind !== 150 /* ConstructorType */) { // When resolved signature is a call signature (and not a construct signature) the result type is any if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); @@ -19484,7 +20687,7 @@ var ts; function checkTaggedTemplateExpression(node) { return getReturnTypeOfSignature(getResolvedSignature(node)); } - function checkTypeAssertion(node) { + function checkAssertion(node) { var exprType = checkExpression(node.expression); var targetType = getTypeFromTypeNode(node.type); if (produceDiagnostics && targetType !== unknownType) { @@ -19513,14 +20716,32 @@ var ts; links.type = instantiateType(getTypeOfSymbol(ts.lastOrUndefined(context.parameters)), mapper); } } + function createPromiseType(promisedType) { + // creates a `Promise` type where `T` is the promisedType argument + var globalPromiseType = getGlobalPromiseType(); + if (globalPromiseType !== emptyObjectType) { + // if the promised type is itself a promise, get the underlying type; otherwise, fallback to the promised type + promisedType = getAwaitedType(promisedType); + return createTypeReference(globalPromiseType, [promisedType]); + } + return emptyObjectType; + } function getReturnTypeFromBody(func, contextualMapper) { var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); if (!func.body) { return unknownType; } + var isAsync = ts.isAsyncFunctionLike(func); var type; - if (func.body.kind !== 182 /* Block */) { + if (func.body.kind !== 189 /* Block */) { type = checkExpressionCached(func.body, contextualMapper); + if (isAsync) { + // From within an async function you can return either a non-promise value or a promise. Any + // Promise/A+ compatible implementation will always assimilate any foreign promise, so the + // return type of the body should be unwrapped to its awaited type, which we will wrap in + // the native Promise type later in this function. + type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + } } else { var types; @@ -19536,9 +20757,20 @@ var ts; } } else { - types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper); + types = checkAndAggregateReturnExpressionTypes(func.body, contextualMapper, isAsync); if (types.length === 0) { - return voidType; + if (isAsync) { + // For an async function, the return type will not be void, but rather a Promise for void. + var promiseType = createPromiseType(voidType); + if (promiseType === emptyObjectType) { + error(func, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return unknownType; + } + return promiseType; + } + else { + return voidType; + } } } // When yield/return statements are contextually typed we allow the return type to be a union type. @@ -19561,7 +20793,21 @@ var ts; if (!contextualSignature) { reportErrorsFromWidening(func, type); } - return getWidenedType(type); + var widenedType = getWidenedType(type); + if (isAsync) { + // From within an async function you can return either a non-promise value or a promise. Any + // Promise/A+ compatible implementation will always assimilate any foreign promise, so the + // return type of the body is awaited type of the body, wrapped in a native Promise type. + var promiseType = createPromiseType(widenedType); + if (promiseType === emptyObjectType) { + error(func, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return unknownType; + } + return promiseType; + } + else { + return widenedType; + } } function checkAndAggregateYieldOperandTypes(body, contextualMapper) { var aggregatedTypes = []; @@ -19580,12 +20826,19 @@ var ts; }); return aggregatedTypes; } - function checkAndAggregateReturnExpressionTypes(body, contextualMapper) { + function checkAndAggregateReturnExpressionTypes(body, contextualMapper, isAsync) { var aggregatedTypes = []; ts.forEachReturnStatement(body, function (returnStatement) { var expr = returnStatement.expression; if (expr) { var type = checkExpressionCached(expr, contextualMapper); + if (isAsync) { + // From within an async function you can return either a non-promise value or a promise. Any + // Promise/A+ compatible implementation will always assimilate any foreign promise, so the + // return type of the body should be unwrapped to its awaited type, which should be wrapped in + // the native Promise type by the caller. + type = checkAwaitedType(type, body.parent, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + } if (!ts.contains(aggregatedTypes, type)) { aggregatedTypes.push(type); } @@ -19599,7 +20852,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 198 /* ThrowStatement */); + return (body.statements.length === 1) && (body.statements[0].kind === 205 /* ThrowStatement */); } // TypeScript Specification 1.0 (6.3) - July 2014 // An explicitly typed function whose return type isn't the Void or the Any type @@ -19614,7 +20867,7 @@ var ts; return; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. - if (ts.nodeIsMissing(func.body) || func.body.kind !== 182 /* Block */) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 189 /* Block */) { return; } var bodyBlock = func.body; @@ -19632,26 +20885,30 @@ 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 !== 136 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 140 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 165 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 170 /* FunctionExpression */) { checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards if (contextualMapper === identityMapper && isContextSensitive(node)) { return anyFunctionType; } + var isAsync = ts.isAsyncFunctionLike(node); + if (isAsync) { + emitAwaiter = true; + } var links = getNodeLinks(node); var type = getTypeOfSymbol(node.symbol); // Check if function expression is contextually typed and assign parameter types if so - if (!(links.flags & 64 /* ContextChecked */)) { + if (!(links.flags & 1024 /* ContextChecked */)) { var contextualSignature = getContextualSignature(node); // If a type check is started at a function expression that is an argument of a function call, obtaining the // contextual type may recursively get back to here during overload resolution of the call. If so, we will have // already assigned contextual types. - if (!(links.flags & 64 /* ContextChecked */)) { - links.flags |= 64 /* ContextChecked */; + if (!(links.flags & 1024 /* ContextChecked */)) { + links.flags |= 1024 /* ContextChecked */; if (contextualSignature) { var signature = getSignaturesOfType(type, 0 /* Call */)[0]; if (isContextSensitive(node)) { @@ -19667,16 +20924,25 @@ var ts; checkSignatureDeclaration(node); } } - if (produceDiagnostics && node.kind !== 136 /* MethodDeclaration */ && node.kind !== 135 /* MethodSignature */) { + if (produceDiagnostics && node.kind !== 140 /* MethodDeclaration */ && node.kind !== 139 /* MethodSignature */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); } return type; } function checkFunctionExpressionOrObjectLiteralMethodBody(node) { - ts.Debug.assert(node.kind !== 136 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); - if (node.type && !node.asteriskToken) { - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); + ts.Debug.assert(node.kind !== 140 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + var isAsync = ts.isAsyncFunctionLike(node); + if (isAsync) { + emitAwaiter = true; + } + var returnType = node.type && getTypeFromTypeNode(node.type); + var promisedType; + if (returnType && isAsync) { + promisedType = checkAsyncFunctionReturnType(node); + } + if (returnType && !node.asteriskToken) { + checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); } if (node.body) { if (!node.type) { @@ -19687,13 +20953,24 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 182 /* Block */) { + if (node.body.kind === 189 /* Block */) { checkSourceElement(node.body); } else { + // From within an async function you can return either a non-promise value or a promise. Any + // Promise/A+ compatible implementation will always assimilate any foreign promise, so we + // should not be checking assignability of a promise to the return type. Instead, we need to + // check assignability of the awaited type of the expression body against the promised type of + // its return type annotation. var exprType = checkExpression(node.body); - if (node.type) { - checkTypeAssignableTo(exprType, getTypeFromTypeNode(node.type), node.body, undefined); + if (returnType) { + if (isAsync) { + var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member); + checkTypeAssignableTo(awaitedType, promisedType, node.body); + } + else { + checkTypeAssignableTo(exprType, returnType, node.body); + } } checkFunctionAndClassExpressionBodies(node.body); } @@ -19722,24 +20999,24 @@ var ts; // and property accesses(section 4.10). // All other expression constructs described in this chapter are classified as values. switch (n.kind) { - case 65 /* Identifier */: { + case 66 /* Identifier */: { var symbol = findSymbol(n); // TypeScript 1.0 spec (April 2014): 4.3 // An identifier expression that references a variable or parameter is classified as a reference. // An identifier expression that references any other kind of entity is classified as a value(and therefore cannot be the target of an assignment). return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3 /* Variable */) !== 0; } - case 158 /* PropertyAccessExpression */: { + case 163 /* PropertyAccessExpression */: { var symbol = findSymbol(n); // TypeScript 1.0 spec (April 2014): 4.10 // A property access expression is always classified as a reference. // NOTE (not in spec): assignment to enum members should not be allowed return !symbol || symbol === unknownSymbol || (symbol.flags & ~8 /* EnumMember */) !== 0; } - case 159 /* ElementAccessExpression */: + case 164 /* ElementAccessExpression */: // old compiler doesn't check indexed assess return true; - case 164 /* ParenthesizedExpression */: + case 169 /* ParenthesizedExpression */: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -19747,22 +21024,22 @@ var ts; } function isConstVariableReference(n) { switch (n.kind) { - case 65 /* Identifier */: - case 158 /* PropertyAccessExpression */: { + case 66 /* Identifier */: + case 163 /* PropertyAccessExpression */: { var symbol = findSymbol(n); - return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 8192 /* Const */) !== 0; + return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 32768 /* Const */) !== 0; } - case 159 /* ElementAccessExpression */: { + case 164 /* ElementAccessExpression */: { var index = n.argumentExpression; var symbol = findSymbol(n.expression); if (symbol && index && index.kind === 8 /* StringLiteral */) { - var name_11 = index.text; - var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_11); - return prop && (prop.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 8192 /* Const */) !== 0; + var name_12 = index.text; + var prop = getPropertyOfType(getTypeOfSymbol(symbol), name_12); + return prop && (prop.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 32768 /* Const */) !== 0; } return false; } - case 164 /* ParenthesizedExpression */: + case 169 /* ParenthesizedExpression */: return isConstVariableReference(n.expression); default: return false; @@ -19783,27 +21060,40 @@ var ts; return booleanType; } function checkTypeOfExpression(node) { - var operandType = checkExpression(node.expression); + checkExpression(node.expression); return stringType; } function checkVoidExpression(node) { - var operandType = checkExpression(node.expression); + checkExpression(node.expression); return undefinedType; } + function checkAwaitExpression(node) { + // Grammar checking + if (produceDiagnostics) { + if (!(node.parserContextFlags & 8 /* Await */)) { + grammarErrorOnFirstToken(node, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); + } + if (isInParameterInitializerBeforeContainingFunction(node)) { + error(node, ts.Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer); + } + } + var operandType = checkExpression(node.expression); + return checkAwaitedType(operandType, node); + } function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); switch (node.operator) { - case 33 /* PlusToken */: - case 34 /* MinusToken */: - case 47 /* TildeToken */: - if (someConstituentTypeHasKind(operandType, 2097152 /* ESSymbol */)) { + case 34 /* PlusToken */: + case 35 /* MinusToken */: + case 48 /* TildeToken */: + if (someConstituentTypeHasKind(operandType, 4194304 /* ESSymbol */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 46 /* ExclamationToken */: + case 47 /* ExclamationToken */: return booleanType; - case 38 /* PlusPlusToken */: - case 39 /* MinusMinusToken */: + case 39 /* PlusPlusToken */: + case 40 /* MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors @@ -19828,7 +21118,7 @@ var ts; if (type.flags & kind) { return true; } - if (type.flags & 16384 /* Union */) { + if (type.flags & 49152 /* UnionOrIntersection */) { var types = type.types; for (var _i = 0; _i < types.length; _i++) { var current = types[_i]; @@ -19840,12 +21130,12 @@ var ts; } return false; } - // Return true if type has the given flags, or is a union type composed of types that all have those flags. + // Return true if type has the given flags, or is a union or intersection type composed of types that all have those flags. function allConstituentTypesHaveKind(type, kind) { if (type.flags & kind) { return true; } - if (type.flags & 16384 /* Union */) { + if (type.flags & 49152 /* UnionOrIntersection */) { var types = type.types; for (var _i = 0; _i < types.length; _i++) { var current = types[_i]; @@ -19858,7 +21148,7 @@ var ts; return false; } function isConstEnumObjectType(type) { - return type.flags & (48128 /* ObjectType */ | 32768 /* Anonymous */) && type.symbol && isConstEnumSymbol(type.symbol); + return type.flags & (80896 /* ObjectType */ | 65536 /* Anonymous */) && type.symbol && isConstEnumSymbol(type.symbol); } function isConstEnumSymbol(symbol) { return (symbol.flags & 128 /* ConstEnum */) !== 0; @@ -19869,7 +21159,7 @@ var ts; // and the right operand to be of type Any or a subtype of the 'Function' interface type. // The result is always of the Boolean primitive type. // NOTE: do not raise error if leftType is unknown as related error was already reported - if (allConstituentTypesHaveKind(leftType, 2097662 /* Primitive */)) { + if (allConstituentTypesHaveKind(leftType, 4194814 /* Primitive */)) { 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); } // NOTE: do not raise error if right is unknown as related error was already reported @@ -19883,10 +21173,10 @@ var ts; // The in operator requires the left operand to be of type Any, the String primitive type, or the Number primitive type, // and the right operand to be of type Any, an object type, or a type parameter type. // The result is always of the Boolean primitive type. - if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */ | 132 /* NumberLike */ | 2097152 /* ESSymbol */)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */ | 132 /* NumberLike */ | 4194304 /* ESSymbol */)) { error(node.left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 48128 /* ObjectType */ | 512 /* TypeParameter */)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 /* ObjectType */ | 512 /* TypeParameter */)) { 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); } return booleanType; @@ -19895,19 +21185,19 @@ var ts; var properties = node.properties; for (var _i = 0; _i < properties.length; _i++) { var p = properties[_i]; - if (p.kind === 227 /* PropertyAssignment */ || p.kind === 228 /* ShorthandPropertyAssignment */) { + if (p.kind === 242 /* PropertyAssignment */ || p.kind === 243 /* ShorthandPropertyAssignment */) { // TODO(andersh): Computed property support - var name_12 = p.name; + var name_13 = p.name; var type = isTypeAny(sourceType) ? sourceType - : getTypeOfPropertyOfType(sourceType, name_12.text) || - isNumericLiteralName(name_12.text) && getIndexTypeOfType(sourceType, 1 /* Number */) || + : getTypeOfPropertyOfType(sourceType, name_13.text) || + isNumericLiteralName(name_13.text) && getIndexTypeOfType(sourceType, 1 /* Number */) || getIndexTypeOfType(sourceType, 0 /* String */); if (type) { - checkDestructuringAssignment(p.initializer || name_12, type); + checkDestructuringAssignment(p.initializer || name_13, type); } else { - error(name_12, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_12)); + error(name_13, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(sourceType), ts.declarationNameToString(name_13)); } } else { @@ -19924,8 +21214,8 @@ var ts; var elements = node.elements; for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 178 /* OmittedExpression */) { - if (e.kind !== 176 /* SpreadElementExpression */) { + if (e.kind !== 184 /* OmittedExpression */) { + if (e.kind !== 182 /* SpreadElementExpression */) { var propName = "" + i; var type = isTypeAny(sourceType) ? sourceType @@ -19950,7 +21240,7 @@ var ts; } else { var restExpression = e.expression; - if (restExpression.kind === 172 /* BinaryExpression */ && restExpression.operatorToken.kind === 53 /* EqualsToken */) { + if (restExpression.kind === 178 /* BinaryExpression */ && restExpression.operatorToken.kind === 54 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -19963,14 +21253,14 @@ var ts; return sourceType; } function checkDestructuringAssignment(target, sourceType, contextualMapper) { - if (target.kind === 172 /* BinaryExpression */ && target.operatorToken.kind === 53 /* EqualsToken */) { + if (target.kind === 178 /* BinaryExpression */ && target.operatorToken.kind === 54 /* EqualsToken */) { checkBinaryExpression(target, contextualMapper); target = target.left; } - if (target.kind === 157 /* ObjectLiteralExpression */) { + if (target.kind === 162 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, contextualMapper); } - if (target.kind === 156 /* ArrayLiteralExpression */) { + if (target.kind === 161 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, contextualMapper); } return checkReferenceAssignment(target, sourceType, contextualMapper); @@ -19984,32 +21274,32 @@ var ts; } function checkBinaryExpression(node, contextualMapper) { var operator = node.operatorToken.kind; - if (operator === 53 /* EqualsToken */ && (node.left.kind === 157 /* ObjectLiteralExpression */ || node.left.kind === 156 /* ArrayLiteralExpression */)) { + if (operator === 54 /* EqualsToken */ && (node.left.kind === 162 /* ObjectLiteralExpression */ || node.left.kind === 161 /* ArrayLiteralExpression */)) { return checkDestructuringAssignment(node.left, checkExpression(node.right, contextualMapper), contextualMapper); } var leftType = checkExpression(node.left, contextualMapper); var rightType = checkExpression(node.right, contextualMapper); switch (operator) { - case 35 /* AsteriskToken */: - case 56 /* AsteriskEqualsToken */: - case 36 /* SlashToken */: - case 57 /* SlashEqualsToken */: - case 37 /* PercentToken */: - case 58 /* PercentEqualsToken */: - case 34 /* MinusToken */: - case 55 /* MinusEqualsToken */: - case 40 /* LessThanLessThanToken */: - case 59 /* LessThanLessThanEqualsToken */: - case 41 /* GreaterThanGreaterThanToken */: - case 60 /* GreaterThanGreaterThanEqualsToken */: - case 42 /* GreaterThanGreaterThanGreaterThanToken */: - case 61 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 44 /* BarToken */: - case 63 /* BarEqualsToken */: - case 45 /* CaretToken */: - case 64 /* CaretEqualsToken */: - case 43 /* AmpersandToken */: - case 62 /* AmpersandEqualsToken */: + case 36 /* AsteriskToken */: + case 57 /* AsteriskEqualsToken */: + case 37 /* SlashToken */: + case 58 /* SlashEqualsToken */: + case 38 /* PercentToken */: + case 59 /* PercentEqualsToken */: + case 35 /* MinusToken */: + case 56 /* MinusEqualsToken */: + case 41 /* LessThanLessThanToken */: + case 60 /* LessThanLessThanEqualsToken */: + case 42 /* GreaterThanGreaterThanToken */: + case 61 /* GreaterThanGreaterThanEqualsToken */: + case 43 /* GreaterThanGreaterThanGreaterThanToken */: + case 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 45 /* BarToken */: + case 64 /* BarEqualsToken */: + case 46 /* CaretToken */: + case 65 /* CaretEqualsToken */: + case 44 /* AmpersandToken */: + case 63 /* AmpersandEqualsToken */: // TypeScript 1.0 spec (April 2014): 4.15.1 // These operators require their operands to be of type Any, the Number primitive type, // or an enum type. Operands of an enum type are treated @@ -20037,8 +21327,8 @@ var ts; } } return numberType; - case 33 /* PlusToken */: - case 54 /* PlusEqualsToken */: + case 34 /* PlusToken */: + case 55 /* PlusEqualsToken */: // TypeScript 1.0 spec (April 2014): 4.15.2 // The binary + operator requires both operands to be of the Number primitive type or an enum type, // or at least one of the operands to be of type Any or the String primitive type. @@ -20072,35 +21362,35 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 54 /* PlusEqualsToken */) { + if (operator === 55 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; case 24 /* LessThanToken */: - case 25 /* GreaterThanToken */: - case 26 /* LessThanEqualsToken */: - case 27 /* GreaterThanEqualsToken */: + case 26 /* GreaterThanToken */: + case 27 /* LessThanEqualsToken */: + case 28 /* GreaterThanEqualsToken */: if (!checkForDisallowedESSymbolOperand(operator)) { return booleanType; } // Fall through - case 28 /* EqualsEqualsToken */: - case 29 /* ExclamationEqualsToken */: - case 30 /* EqualsEqualsEqualsToken */: - case 31 /* ExclamationEqualsEqualsToken */: + case 29 /* EqualsEqualsToken */: + case 30 /* ExclamationEqualsToken */: + case 31 /* EqualsEqualsEqualsToken */: + case 32 /* ExclamationEqualsEqualsToken */: if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { reportOperatorError(); } return booleanType; - case 87 /* InstanceOfKeyword */: + case 88 /* InstanceOfKeyword */: return checkInstanceOfExpression(node, leftType, rightType); - case 86 /* InKeyword */: + case 87 /* InKeyword */: return checkInExpression(node, leftType, rightType); - case 48 /* AmpersandAmpersandToken */: + case 49 /* AmpersandAmpersandToken */: return rightType; - case 49 /* BarBarToken */: + case 50 /* BarBarToken */: return getUnionType([leftType, rightType]); - case 53 /* EqualsToken */: + case 54 /* EqualsToken */: checkAssignmentOperator(rightType); return rightType; case 23 /* CommaToken */: @@ -20108,8 +21398,8 @@ var ts; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { - var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 2097152 /* ESSymbol */) ? node.left : - someConstituentTypeHasKind(rightType, 2097152 /* ESSymbol */) ? node.right : + var offendingSymbolOperand = someConstituentTypeHasKind(leftType, 4194304 /* ESSymbol */) ? node.left : + someConstituentTypeHasKind(rightType, 4194304 /* ESSymbol */) ? node.right : undefined; if (offendingSymbolOperand) { error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator)); @@ -20119,21 +21409,21 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 44 /* BarToken */: - case 63 /* BarEqualsToken */: - return 49 /* BarBarToken */; - case 45 /* CaretToken */: - case 64 /* CaretEqualsToken */: - return 31 /* ExclamationEqualsEqualsToken */; - case 43 /* AmpersandToken */: - case 62 /* AmpersandEqualsToken */: - return 48 /* AmpersandAmpersandToken */; + case 45 /* BarToken */: + case 64 /* BarEqualsToken */: + return 50 /* BarBarToken */; + case 46 /* CaretToken */: + case 65 /* CaretEqualsToken */: + return 32 /* ExclamationEqualsEqualsToken */; + case 44 /* AmpersandToken */: + case 63 /* AmpersandEqualsToken */: + return 49 /* AmpersandAmpersandToken */; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 53 /* FirstAssignment */ && operator <= 64 /* LastAssignment */) { + if (produceDiagnostics && operator >= 54 /* FirstAssignment */ && operator <= 65 /* LastAssignment */) { // TypeScript 1.0 spec (April 2014): 4.17 // An assignment of the form // VarExpr = ValueExpr @@ -20169,8 +21459,13 @@ var ts; } function checkYieldExpression(node) { // Grammar checking - if (!(node.parserContextFlags & 4 /* Yield */) || isYieldExpressionInClass(node)) { - grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); + if (produceDiagnostics) { + if (!(node.parserContextFlags & 2 /* Yield */) || isYieldExpressionInClass(node)) { + grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); + } + if (isInParameterInitializerBeforeContainingFunction(node)) { + error(node, ts.Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer); + } } if (node.expression) { var func = ts.getContainingFunction(node); @@ -20235,7 +21530,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 129 /* ComputedPropertyName */) { + if (node.name.kind === 133 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpression(node.initializer, contextualMapper); @@ -20246,7 +21541,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 129 /* ComputedPropertyName */) { + if (node.name.kind === 133 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); @@ -20276,7 +21571,7 @@ var ts; // contextually typed function and arrow expressions in the initial phase. function checkExpression(node, contextualMapper) { var type; - if (node.kind === 128 /* QualifiedName */) { + if (node.kind === 132 /* QualifiedName */) { type = checkQualifiedName(node); } else { @@ -20288,9 +21583,9 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 158 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 159 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 65 /* Identifier */ || node.kind === 128 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 163 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 164 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 66 /* Identifier */ || node.kind === 132 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); } @@ -20304,68 +21599,79 @@ var ts; } function checkExpressionWorker(node, contextualMapper) { switch (node.kind) { - case 65 /* Identifier */: + case 66 /* Identifier */: return checkIdentifier(node); - case 93 /* ThisKeyword */: + case 94 /* ThisKeyword */: return checkThisExpression(node); - case 91 /* SuperKeyword */: + case 92 /* SuperKeyword */: return checkSuperExpression(node); - case 89 /* NullKeyword */: + case 90 /* NullKeyword */: return nullType; - case 95 /* TrueKeyword */: - case 80 /* FalseKeyword */: + case 96 /* TrueKeyword */: + case 81 /* FalseKeyword */: return booleanType; case 7 /* NumericLiteral */: return checkNumericLiteral(node); - case 174 /* TemplateExpression */: + case 180 /* TemplateExpression */: return checkTemplateExpression(node); case 8 /* StringLiteral */: case 10 /* NoSubstitutionTemplateLiteral */: return stringType; case 9 /* RegularExpressionLiteral */: return globalRegExpType; - case 156 /* ArrayLiteralExpression */: + case 161 /* ArrayLiteralExpression */: return checkArrayLiteral(node, contextualMapper); - case 157 /* ObjectLiteralExpression */: + case 162 /* ObjectLiteralExpression */: return checkObjectLiteral(node, contextualMapper); - case 158 /* PropertyAccessExpression */: + case 163 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 159 /* ElementAccessExpression */: + case 164 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 160 /* CallExpression */: - case 161 /* NewExpression */: + case 165 /* CallExpression */: + case 166 /* NewExpression */: return checkCallExpression(node); - case 162 /* TaggedTemplateExpression */: + case 167 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 163 /* TypeAssertionExpression */: - return checkTypeAssertion(node); - case 164 /* ParenthesizedExpression */: + case 169 /* ParenthesizedExpression */: return checkExpression(node.expression, contextualMapper); - case 177 /* ClassExpression */: + case 183 /* ClassExpression */: return checkClassExpression(node); - case 165 /* FunctionExpression */: - case 166 /* ArrowFunction */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 168 /* TypeOfExpression */: + case 173 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 167 /* DeleteExpression */: + case 168 /* TypeAssertionExpression */: + case 186 /* AsExpression */: + return checkAssertion(node); + case 172 /* DeleteExpression */: return checkDeleteExpression(node); - case 169 /* VoidExpression */: + case 174 /* VoidExpression */: return checkVoidExpression(node); - case 170 /* PrefixUnaryExpression */: + case 175 /* AwaitExpression */: + return checkAwaitExpression(node); + case 176 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 171 /* PostfixUnaryExpression */: + case 177 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 172 /* BinaryExpression */: + case 178 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 173 /* ConditionalExpression */: + case 179 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 176 /* SpreadElementExpression */: + case 182 /* SpreadElementExpression */: return checkSpreadElementExpression(node, contextualMapper); - case 178 /* OmittedExpression */: + case 184 /* OmittedExpression */: return undefinedType; - case 175 /* YieldExpression */: + case 181 /* YieldExpression */: return checkYieldExpression(node); + case 237 /* JsxExpression */: + return checkJsxExpression(node); + case 230 /* JsxElement */: + return checkJsxElement(node); + case 231 /* JsxSelfClosingElement */: + return checkJsxSelfClosingElement(node); + case 232 /* JsxOpeningElement */: + ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; } @@ -20393,7 +21699,7 @@ var ts; var func = ts.getContainingFunction(node); if (node.flags & 112 /* AccessibilityModifier */) { func = ts.getContainingFunction(node); - if (!(func.kind === 137 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 141 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -20410,15 +21716,15 @@ var ts; if (!node.asteriskToken || !node.body) { return false; } - return node.kind === 136 /* MethodDeclaration */ || - node.kind === 203 /* FunctionDeclaration */ || - node.kind === 165 /* FunctionExpression */; + return node.kind === 140 /* MethodDeclaration */ || + node.kind === 210 /* FunctionDeclaration */ || + node.kind === 170 /* FunctionExpression */; } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 65 /* Identifier */ && + if (param.name.kind === 66 /* Identifier */ && param.name.text === parameter.text) { return i; } @@ -20428,31 +21734,31 @@ var ts; } function isInLegalTypePredicatePosition(node) { switch (node.parent.kind) { - case 166 /* ArrowFunction */: - case 140 /* CallSignature */: - case 203 /* FunctionDeclaration */: - case 165 /* FunctionExpression */: - case 145 /* FunctionType */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 171 /* ArrowFunction */: + case 144 /* CallSignature */: + case 210 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: + case 149 /* FunctionType */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: return node === node.parent.type; } return false; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 142 /* IndexSignature */) { + if (node.kind === 146 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 145 /* FunctionType */ || node.kind === 203 /* FunctionDeclaration */ || node.kind === 146 /* ConstructorType */ || - node.kind === 140 /* CallSignature */ || node.kind === 137 /* Constructor */ || - node.kind === 141 /* ConstructSignature */) { + else if (node.kind === 149 /* FunctionType */ || node.kind === 210 /* FunctionDeclaration */ || node.kind === 150 /* ConstructorType */ || + node.kind === 144 /* CallSignature */ || node.kind === 141 /* Constructor */ || + node.kind === 145 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { - if (node.type.kind === 143 /* TypePredicate */) { + if (node.type.kind === 147 /* TypePredicate */) { var typePredicate = getSignatureFromDeclaration(node).typePredicate; var typePredicateNode = node.type; if (isInLegalTypePredicatePosition(typePredicateNode)) { @@ -20471,19 +21777,19 @@ var ts; if (hasReportedError) { break; } - if (param.name.kind === 153 /* ObjectBindingPattern */ || - param.name.kind === 154 /* ArrayBindingPattern */) { + if (param.name.kind === 158 /* ObjectBindingPattern */ || + param.name.kind === 159 /* ArrayBindingPattern */) { (function checkBindingPattern(pattern) { for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.name.kind === 65 /* Identifier */ && + if (element.name.kind === 66 /* Identifier */ && element.name.text === typePredicate.parameterName) { error(typePredicateNode.parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, typePredicate.parameterName); hasReportedError = true; break; } - else if (element.name.kind === 154 /* ArrayBindingPattern */ || - element.name.kind === 153 /* ObjectBindingPattern */) { + else if (element.name.kind === 159 /* ArrayBindingPattern */ || + element.name.kind === 158 /* ObjectBindingPattern */) { checkBindingPattern(element.name); } } @@ -20507,10 +21813,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 141 /* ConstructSignature */: + case 145 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 140 /* CallSignature */: + case 144 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -20538,7 +21844,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 205 /* InterfaceDeclaration */) { + if (node.kind === 212 /* InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration // to prevent this run check only for the first declaration of a given kind @@ -20558,7 +21864,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 123 /* StringKeyword */: + case 127 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -20566,7 +21872,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 121 /* NumberKeyword */: + case 125 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -20589,6 +21895,11 @@ var ts; checkGrammarMethod(node) || checkGrammarComputedPropertyName(node.name); // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration checkFunctionLikeDeclaration(node); + // Abstract methods cannot have an implementation. + // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. + if (node.flags & 256 /* Abstract */ && node.body) { + error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); + } } function checkConstructorDeclaration(node) { // Grammar check on signature of constructor and modifier of the constructor is done in checkSignatureDeclaration function. @@ -20610,30 +21921,30 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 160 /* CallExpression */ && n.expression.kind === 91 /* SuperKeyword */; + return n.kind === 165 /* CallExpression */ && n.expression.kind === 92 /* SuperKeyword */; } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } switch (n.kind) { - case 165 /* FunctionExpression */: - case 203 /* FunctionDeclaration */: - case 166 /* ArrowFunction */: - case 157 /* ObjectLiteralExpression */: return false; + case 170 /* FunctionExpression */: + case 210 /* FunctionDeclaration */: + case 171 /* ArrowFunction */: + case 162 /* ObjectLiteralExpression */: return false; default: return ts.forEachChild(n, containsSuperCall); } } function markThisReferencesAsErrors(n) { - if (n.kind === 93 /* ThisKeyword */) { + if (n.kind === 94 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 165 /* FunctionExpression */ && n.kind !== 203 /* FunctionDeclaration */) { + else if (n.kind !== 170 /* FunctionExpression */ && n.kind !== 210 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 134 /* PropertyDeclaration */ && + return n.kind === 138 /* PropertyDeclaration */ && !(n.flags & 128 /* Static */) && !!n.initializer; } @@ -20650,7 +21961,7 @@ var ts; ts.forEach(node.parameters, function (p) { return p.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */); }); if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 185 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { + if (!statements.length || statements[0].kind !== 192 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); } else { @@ -20668,7 +21979,7 @@ var ts; if (produceDiagnostics) { // Grammar checking accessors checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); - if (node.kind === 138 /* GetAccessor */) { + if (node.kind === 142 /* GetAccessor */) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } @@ -20676,7 +21987,7 @@ var ts; if (!ts.hasDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 138 /* GetAccessor */ ? 139 /* SetAccessor */ : 138 /* GetAccessor */; + var otherKind = node.kind === 142 /* GetAccessor */ ? 143 /* SetAccessor */ : 142 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { @@ -20746,7 +22057,7 @@ var ts; } ts.forEach(node.elementTypes, checkSourceElement); } - function checkUnionType(node) { + function checkUnionOrIntersectionType(node) { ts.forEach(node.types, checkSourceElement); } function isPrivateWithinAmbient(node) { @@ -20772,9 +22083,9 @@ var ts; var signaturesToCheck; // Unnamed (call\construct) signatures in interfaces are inherited and not shadowed so examining just node symbol won't give complete answer. // Use declaring type to obtain full list of signatures. - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 205 /* InterfaceDeclaration */) { - ts.Debug.assert(signatureDeclarationNode.kind === 140 /* CallSignature */ || signatureDeclarationNode.kind === 141 /* ConstructSignature */); - var signatureKind = signatureDeclarationNode.kind === 140 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 212 /* InterfaceDeclaration */) { + ts.Debug.assert(signatureDeclarationNode.kind === 144 /* CallSignature */ || signatureDeclarationNode.kind === 145 /* ConstructSignature */); + var signatureKind = signatureDeclarationNode.kind === 144 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -20792,7 +22103,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedNodeFlags(n); - if (n.parent.kind !== 205 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 212 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported flags |= 1 /* Export */; @@ -20831,6 +22142,9 @@ var ts; else if (deviation & (32 /* Private */ | 64 /* Protected */)) { error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } + else if (deviation & 256 /* Abstract */) { + error(o.name, ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract); + } }); } } @@ -20845,7 +22159,7 @@ var ts; }); } } - var flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 32 /* Private */ | 64 /* Protected */; + var flagsToCheck = 1 /* Export */ | 2 /* Ambient */ | 32 /* Private */ | 64 /* Protected */ | 256 /* Abstract */; var someNodeFlags = 0; var allNodeFlags = flagsToCheck; var someHaveQuestionToken = false; @@ -20875,7 +22189,7 @@ var ts; // TODO(jfreeman): These are methods, so handle computed name case if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { // the only situation when this is possible (same kind\same name but different symbol) - mixed static and instance class members - ts.Debug.assert(node.kind === 136 /* MethodDeclaration */ || node.kind === 135 /* MethodSignature */); + ts.Debug.assert(node.kind === 140 /* MethodDeclaration */ || node.kind === 139 /* MethodSignature */); ts.Debug.assert((node.flags & 128 /* Static */) !== (subsequentNode.flags & 128 /* Static */)); var diagnostic = node.flags & 128 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode_1, diagnostic); @@ -20892,7 +22206,14 @@ var ts; error(errorNode, ts.Diagnostics.Constructor_implementation_is_missing); } else { - error(errorNode, ts.Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration); + // Report different errors regarding non-consecutive blocks of declarations depending on whether + // the node in question is abstract. + if (node.flags & 256 /* Abstract */) { + error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); + } + else { + error(errorNode, ts.Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration); + } } } // when checking exported function declarations across modules check only duplicate implementations @@ -20904,7 +22225,7 @@ var ts; var current = declarations[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 205 /* InterfaceDeclaration */ || node.parent.kind === 148 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 212 /* InterfaceDeclaration */ || node.parent.kind === 152 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -20915,7 +22236,7 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if (node.kind === 203 /* FunctionDeclaration */ || node.kind === 136 /* MethodDeclaration */ || node.kind === 135 /* MethodSignature */ || node.kind === 137 /* Constructor */) { + if (node.kind === 210 /* FunctionDeclaration */ || node.kind === 140 /* MethodDeclaration */ || node.kind === 139 /* MethodSignature */ || node.kind === 141 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -20956,7 +22277,9 @@ var ts; error(declaration.name, ts.Diagnostics.Duplicate_function_implementation); }); } - if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body) { + // Abstract methods can't have an implementation -- in particular, they don't need one. + if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && + !(lastSeenNonAmbientDeclaration.flags & 256 /* Abstract */)) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } if (hasOverloads) { @@ -21038,16 +22361,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 205 /* InterfaceDeclaration */: + case 212 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: return d.name.kind === 8 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 204 /* ClassDeclaration */: - case 207 /* EnumDeclaration */: + case 211 /* ClassDeclaration */: + case 214 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 211 /* ImportEqualsDeclaration */: + case 218 /* ImportEqualsDeclaration */: var result = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result |= getDeclarationSpaces(d); }); @@ -21057,6 +22380,229 @@ var ts; } } } + function checkNonThenableType(type, location, message) { + if (!(type.flags & 1 /* Any */) && isTypeAssignableTo(type, getGlobalThenableType())) { + if (location) { + if (!message) { + message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; + } + error(location, message); + } + return unknownType; + } + return type; + } + /** + * Gets the "promised type" of a promise. + * @param type The type of the promise. + * @remarks The "promised type" of a type is the type of the "value" parameter of the "onfulfilled" callback. + */ + function getPromisedType(promise) { + // + // { // promise + // then( // thenFunction + // onfulfilled: ( // onfulfilledParameterType + // value: T // valueParameterType + // ) => any + // ): any; + // } + // + if (promise.flags & 1 /* Any */) { + return undefined; + } + if ((promise.flags & 4096 /* Reference */) && promise.target === tryGetGlobalPromiseType()) { + return promise.typeArguments[0]; + } + var globalPromiseLikeType = getInstantiatedGlobalPromiseLikeType(); + if (globalPromiseLikeType === emptyObjectType || !isTypeAssignableTo(promise, globalPromiseLikeType)) { + return undefined; + } + var thenFunction = getTypeOfPropertyOfType(promise, "then"); + if (thenFunction && (thenFunction.flags & 1 /* Any */)) { + return undefined; + } + var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0 /* Call */) : emptyArray; + if (thenSignatures.length === 0) { + return undefined; + } + var onfulfilledParameterType = getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)); + if (onfulfilledParameterType.flags & 1 /* Any */) { + return undefined; + } + var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0 /* Call */); + if (onfulfilledParameterSignatures.length === 0) { + return undefined; + } + var valueParameterType = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature)); + return valueParameterType; + } + function getTypeOfFirstParameterOfSignature(signature) { + return getTypeAtPosition(signature, 0); + } + /** + * Gets the "awaited type" of a type. + * @param type The type to await. + * @remarks The "awaited type" of an expression is its "promised type" if the expression is a + * Promise-like type; otherwise, it is the type of the expression. This is used to reflect + * The runtime behavior of the `await` keyword. + */ + function getAwaitedType(type) { + return checkAwaitedType(type, undefined, undefined); + } + function checkAwaitedType(type, location, message) { + return checkAwaitedTypeWorker(type); + function checkAwaitedTypeWorker(type) { + if (type.flags & 16384 /* Union */) { + var types = []; + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var constituentType = _a[_i]; + types.push(checkAwaitedTypeWorker(constituentType)); + } + return getUnionType(types); + } + else { + var promisedType = getPromisedType(type); + if (promisedType === undefined) { + // The type was not a PromiseLike, so it could not be unwrapped any further. + // As long as the type does not have a callable "then" property, it is + // safe to return the type; otherwise, an error will have been reported in + // the call to checkNonThenableType and we will return unknownType. + // + // An example of a non-promise "thenable" might be: + // + // await { then(): void {} } + // + // The "thenable" does not match the minimal definition for a PromiseLike. When + // a Promise/A+-compatible or ES6 promise tries to adopt this value, the promise + // will never settle. We treat this as an error to help flag an early indicator + // of a runtime problem. If the user wants to return this value from an async + // function, they would need to wrap it in some other value. If they want it to + // be treated as a promise, they can cast to . + return checkNonThenableType(type, location, message); + } + else { + if (type.id === promisedType.id || awaitedTypeStack.indexOf(promisedType.id) >= 0) { + // We have a bad actor in the form of a promise whose promised type is + // the same promise type, or a mutually recursive promise. Return the + // unknown type as we cannot guess the shape. If this were the actual + // case in the JavaScript, this Promise would never resolve. + // + // An example of a bad actor with a singly-recursive promise type might + // be: + // + // interface BadPromise { + // then( + // onfulfilled: (value: BadPromise) => any, + // onrejected: (error: any) => any): BadPromise; + // } + // + // The above interface will pass the PromiseLike check, and return a + // promised type of `BadPromise`. Since this is a self reference, we + // don't want to keep recursing ad infinitum. + // + // An example of a bad actor in the form of a mutually-recursive + // promise type might be: + // + // interface BadPromiseA { + // then( + // onfulfilled: (value: BadPromiseB) => any, + // onrejected: (error: any) => any): BadPromiseB; + // } + // + // interface BadPromiseB { + // then( + // onfulfilled: (value: BadPromiseA) => any, + // onrejected: (error: any) => any): BadPromiseA; + // } + // + if (location) { + error(location, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method, symbolToString(type.symbol)); + } + return unknownType; + } + // Keep track of the type we're about to unwrap to avoid bad recursive promise types. + // See the comments above for more information. + awaitedTypeStack.push(type.id); + var awaitedType = checkAwaitedTypeWorker(promisedType); + awaitedTypeStack.pop(); + return awaitedType; + } + } + } + } + /** + * Checks the return type of an async function to ensure it is a compatible + * Promise implementation. + * @param node The signature to check + * @param returnType The return type for the function + * @remarks + * This checks that an async function has a valid Promise-compatible return type, + * and returns the *awaited type* of the promise. An async function has a valid + * Promise-compatible return type if the resolved value of the return type has a + * construct signature that takes in an `initializer` function that in turn supplies + * a `resolve` function as one of its arguments and results in an object with a + * callable `then` signature. + */ + function checkAsyncFunctionReturnType(node) { + var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); + if (globalPromiseConstructorLikeType === emptyObjectType) { + // If we couldn't resolve the global PromiseConstructorLike type we cannot verify + // compatibility with __awaiter. + return unknownType; + } + // As part of our emit for an async function, we will need to emit the entity name of + // the return type annotation as an expression. To meet the necessary runtime semantics + // for __awaiter, we must also check that the type of the declaration (e.g. the static + // side or "constructor" of the promise type) is compatible `PromiseConstructorLike`. + // + // An example might be (from lib.es6.d.ts): + // + // interface Promise { ... } + // interface PromiseConstructor { + // new (...): Promise; + // } + // declare var Promise: PromiseConstructor; + // + // When an async function declares a return type annotation of `Promise`, we + // need to get the type of the `Promise` variable declaration above, which would + // be `PromiseConstructor`. + // + // The same case applies to a class: + // + // declare class Promise { + // constructor(...); + // then(...): Promise; + // } + // + // When we get the type of the `Promise` symbol here, we get the type of the static + // side of the `Promise` class, which would be `{ new (...): Promise }`. + var promiseType = getTypeFromTypeNode(node.type); + if (promiseType === unknownType && compilerOptions.isolatedModules) { + // If we are compiling with isolatedModules, we may not be able to resolve the + // type as a value. As such, we will just return unknownType; + return unknownType; + } + var promiseConstructor = getMergedSymbol(promiseType.symbol); + if (!promiseConstructor || !symbolIsValue(promiseConstructor)) { + error(node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type, typeToString(promiseType)); + return unknownType; + } + // Validate the promise constructor type. + var promiseConstructorType = getTypeOfSymbol(promiseConstructor); + if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, node, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type)) { + return unknownType; + } + // Verify there is no local declaration that could collide with the promise constructor. + var promiseName = ts.getEntityNameFromTypeNode(node.type); + var root = getFirstIdentifier(promiseName); + var rootSymbol = getSymbol(node.locals, root.text, 107455 /* Value */); + if (rootSymbol) { + error(rootSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, root.text, getFullyQualifiedName(promiseConstructor)); + return unknownType; + } + // Get and return the awaited type of the return type. + return checkAwaitedType(promiseType, node, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + } /** Check a decorator */ function checkDecorator(node) { var signature = getResolvedSignature(node); @@ -21068,22 +22614,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 204 /* ClassDeclaration */: + case 211 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 131 /* Parameter */: + case 135 /* Parameter */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 134 /* PropertyDeclaration */: + case 138 /* PropertyDeclaration */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 136 /* MethodDeclaration */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: + case 140 /* MethodDeclaration */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -21094,16 +22640,13 @@ var ts; /** Checks a type reference node as an expression. */ function checkTypeNodeAsExpression(node) { // When we are emitting type metadata for decorators, we need to try to check the type - // as if it were an expression so that we can emit the type in a value position when we + // as if it were an expression so that we can emit the type in a value position when we // serialize the type metadata. - if (node && node.kind === 144 /* TypeReference */) { - var type = getTypeFromTypeNode(node); - var shouldCheckIfUnknownType = type === unknownType && compilerOptions.isolatedModules; - if (!type || (!shouldCheckIfUnknownType && type.flags & (2097279 /* Intrinsic */ | 132 /* NumberLike */ | 258 /* StringLike */))) { - return; - } - if (shouldCheckIfUnknownType || type.symbol.valueDeclaration) { - checkExpression(node.typeName); + if (node && node.kind === 148 /* TypeReference */) { + var root = getFirstIdentifier(node.typeName); + var rootSymbol = resolveName(root, root.text, 107455 /* Value */, undefined, undefined); + if (rootSymbol && rootSymbol.flags & 8388608 /* Alias */ && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { + markAliasSymbolAsReferenced(rootSymbol); } } } @@ -21113,20 +22656,20 @@ var ts; */ function checkTypeAnnotationAsExpression(node) { switch (node.kind) { - case 134 /* PropertyDeclaration */: + case 138 /* PropertyDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 131 /* Parameter */: + case 135 /* Parameter */: checkTypeNodeAsExpression(node.type); break; - case 136 /* MethodDeclaration */: + case 140 /* MethodDeclaration */: checkTypeNodeAsExpression(node.type); break; - case 138 /* GetAccessor */: + case 142 /* GetAccessor */: checkTypeNodeAsExpression(node.type); break; - case 139 /* SetAccessor */: - checkTypeNodeAsExpression(getSetAccessorTypeAnnotationNode(node)); + case 143 /* SetAccessor */: + checkTypeNodeAsExpression(ts.getSetAccessorTypeAnnotationNode(node)); break; } } @@ -21154,25 +22697,25 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 204 /* ClassDeclaration */: + case 211 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { checkParameterTypeAnnotationsAsExpressions(constructor); } break; - case 136 /* MethodDeclaration */: + case 140 /* MethodDeclaration */: checkParameterTypeAnnotationsAsExpressions(node); // fall-through - case 139 /* SetAccessor */: - case 138 /* GetAccessor */: - case 134 /* PropertyDeclaration */: - case 131 /* Parameter */: + case 143 /* SetAccessor */: + case 142 /* GetAccessor */: + case 138 /* PropertyDeclaration */: + case 135 /* Parameter */: checkTypeAnnotationAsExpression(node); break; } } emitDecorate = true; - if (node.kind === 131 /* Parameter */) { + if (node.kind === 135 /* Parameter */) { emitParam = true; } ts.forEach(node.decorators, checkDecorator); @@ -21188,10 +22731,17 @@ var ts; function checkFunctionLikeDeclaration(node) { checkDecorators(node); 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; + } // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 129 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 133 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -21217,7 +22767,12 @@ var ts; } checkSourceElement(node.body); if (node.type && !isAccessor(node.kind) && !node.asteriskToken) { - checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); + var returnType = getTypeFromTypeNode(node.type); + var promisedType; + if (isAsync) { + promisedType = checkAsyncFunctionReturnType(node); + } + checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, isAsync ? promisedType : returnType); } if (produceDiagnostics && !node.type) { // Report an implicit any error if there is no body, no explicit return type, and node is not a private method @@ -21235,11 +22790,11 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 182 /* Block */) { + if (node.kind === 189 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); - if (ts.isFunctionBlock(node) || node.kind === 209 /* ModuleBlock */) { + if (ts.isFunctionBlock(node) || node.kind === 216 /* ModuleBlock */) { checkFunctionAndClassExpressionBodies(node); } } @@ -21258,12 +22813,12 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 134 /* PropertyDeclaration */ || - node.kind === 133 /* PropertySignature */ || - node.kind === 136 /* MethodDeclaration */ || - node.kind === 135 /* MethodSignature */ || - node.kind === 138 /* GetAccessor */ || - node.kind === 139 /* SetAccessor */) { + if (node.kind === 138 /* PropertyDeclaration */ || + node.kind === 137 /* PropertySignature */ || + node.kind === 140 /* MethodDeclaration */ || + node.kind === 139 /* MethodSignature */ || + node.kind === 142 /* GetAccessor */ || + node.kind === 143 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -21272,7 +22827,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 131 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 135 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -21288,7 +22843,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 65 /* Identifier */; + var isDeclaration_1 = node.kind !== 66 /* Identifier */; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -21311,7 +22866,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_2 = node.kind !== 65 /* Identifier */; + var isDeclaration_2 = node.kind !== 66 /* Identifier */; if (isDeclaration_2) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -21325,12 +22880,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 208 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 215 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 230 /* SourceFile */ && ts.isExternalModule(parent)) { + if (parent.kind === 245 /* SourceFile */ && ts.isExternalModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -21359,13 +22914,13 @@ var ts; // let x = 0; // symbol for this declaration will be 'symbol' // } // skip block-scoped variables and parameters - if ((ts.getCombinedNodeFlags(node) & 12288 /* BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { + if ((ts.getCombinedNodeFlags(node) & 49152 /* BlockScoped */) !== 0 || ts.isParameterDeclaration(node)) { return; } // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 201 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 208 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -21374,25 +22929,25 @@ var ts; if (localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { - if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 12288 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 202 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 183 /* VariableStatement */ && varDeclList.parent.parent + if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 49152 /* BlockScoped */) { + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 209 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 190 /* VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; // names of block-scoped and function scoped variables can collide only // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) var namesShareScope = container && - (container.kind === 182 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 209 /* ModuleBlock */ || - container.kind === 208 /* ModuleDeclaration */ || - container.kind === 230 /* SourceFile */); + (container.kind === 189 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 216 /* ModuleBlock */ || + container.kind === 215 /* ModuleDeclaration */ || + container.kind === 245 /* SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail // since LHS will be block scoped name instead of function scoped if (!namesShareScope) { - var name_13 = symbolToString(localDeclarationSymbol); - error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name_13, name_13); + 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); } } } @@ -21400,18 +22955,18 @@ var ts; } // Check that a parameter initializer contains no references to parameters declared to the right of itself function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 131 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 135 /* Parameter */) { return; } var func = ts.getContainingFunction(node); visit(node.initializer); function visit(n) { - if (n.kind === 65 /* Identifier */) { + if (n.kind === 66 /* Identifier */) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; // check FunctionLikeDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name and if this entry matches the resolved symbol if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(func.locals, referencedSymbol.name, 107455 /* Value */) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 131 /* Parameter */) { + if (referencedSymbol.valueDeclaration.kind === 135 /* Parameter */) { if (referencedSymbol.valueDeclaration === node) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(node.name)); return; @@ -21437,7 +22992,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 129 /* ComputedPropertyName */) { + if (node.name.kind === 133 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); @@ -21448,7 +23003,7 @@ var ts; ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 131 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 135 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } @@ -21480,10 +23035,10 @@ var ts; checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, undefined); } } - if (node.kind !== 134 /* PropertyDeclaration */ && node.kind !== 133 /* PropertySignature */) { + if (node.kind !== 138 /* PropertyDeclaration */ && node.kind !== 137 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 201 /* VariableDeclaration */ || node.kind === 155 /* BindingElement */) { + if (node.kind === 208 /* VariableDeclaration */ || node.kind === 160 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -21504,21 +23059,19 @@ var ts; checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarVariableDeclarationList(node.declarationList) || checkGrammarForDisallowedLetOrConstStatement(node); ts.forEach(node.declarationList.declarations, checkSourceElement); } - function checkGrammarDisallowedModifiersInBlockOrObjectLiteralExpression(node) { - if (node.modifiers) { - if (inBlockOrObjectLiteralExpression(node)) { + function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { + // We only disallow modifier on a method declaration if it is a property of object-literal-expression + if (node.modifiers && node.parent.kind === 162 /* ObjectLiteralExpression */) { + if (ts.isAsyncFunctionLike(node)) { + if (node.modifiers.length > 1) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + } + else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } } } - function inBlockOrObjectLiteralExpression(node) { - while (node) { - if (node.kind === 182 /* Block */ || node.kind === 157 /* ObjectLiteralExpression */) { - return true; - } - node = node.parent; - } - } function checkExpressionStatement(node) { // Grammar checking checkGrammarStatementInAmbientContext(node); @@ -21546,12 +23099,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 202 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 209 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 202 /* VariableDeclarationList */) { + if (node.initializer.kind === 209 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -21571,14 +23124,14 @@ var ts; // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 202 /* VariableDeclarationList */) { + if (node.initializer.kind === 209 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression); // There may be a destructuring assignment on the left side - if (varExpr.kind === 156 /* ArrayLiteralExpression */ || varExpr.kind === 157 /* ObjectLiteralExpression */) { + if (varExpr.kind === 161 /* ArrayLiteralExpression */ || varExpr.kind === 162 /* ObjectLiteralExpression */) { // iteratedType may be undefined. In this case, we still want to check the structure of // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like // to short circuit the type relation checking as much as possible, so we pass the unknownType. @@ -21607,7 +23160,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 202 /* VariableDeclarationList */) { + if (node.initializer.kind === 209 /* VariableDeclarationList */) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -21621,7 +23174,7 @@ var ts; // and Expr must be an expression of type Any, an object type, or a type parameter type. var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 156 /* ArrayLiteralExpression */ || varExpr.kind === 157 /* ObjectLiteralExpression */) { + if (varExpr.kind === 161 /* ArrayLiteralExpression */ || varExpr.kind === 162 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAnyOrAllConstituentTypesHaveKind(leftType, 258 /* StringLike */)) { @@ -21635,7 +23188,7 @@ var ts; var rightType = checkExpression(node.expression); // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved // in this case error about missing name is already reported - do not report extra one - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 48128 /* ObjectType */ | 512 /* TypeParameter */)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 80896 /* ObjectType */ | 512 /* TypeParameter */)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); } checkSourceElement(node.statement); @@ -21860,7 +23413,7 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatatedSetAccessor(node) { - return !!(node.kind === 138 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 139 /* SetAccessor */))); + return !!(node.kind === 142 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 143 /* SetAccessor */))); } function checkReturnStatement(node) { // Grammar checking @@ -21883,22 +23436,34 @@ var ts; // for generators. return; } - if (func.kind === 139 /* SetAccessor */) { + if (func.kind === 143 /* SetAccessor */) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } - else if (func.kind === 137 /* Constructor */) { + else if (func.kind === 141 /* Constructor */) { if (!isTypeAssignableTo(exprType, returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } else if (func.type || isGetAccessorWithAnnotatatedSetAccessor(func) || signature.typePredicate) { - checkTypeAssignableTo(exprType, returnType, node.expression, undefined); + 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); + } + else { + checkTypeAssignableTo(exprType, returnType, node.expression); + } } } } } function checkWithStatement(node) { - checkGrammarStatementInAmbientContext(node); + // Grammar checking for withStatement + if (!checkGrammarStatementInAmbientContext(node)) { + if (node.parserContextFlags & 8 /* Await */) { + grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); + } + } checkExpression(node.expression); error(node.expression, ts.Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any); } @@ -21910,7 +23475,7 @@ var ts; var expressionType = checkExpression(node.expression); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 224 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 239 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -21922,7 +23487,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 223 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 238 /* CaseClause */) { var caseClause = clause; // TypeScript 1.0 spec (April 2014):5.9 // In a 'switch' statement, each 'case' expression must be of a type that is assignable to or from the type of the 'switch' expression. @@ -21943,7 +23508,7 @@ var ts; if (ts.isFunctionLike(current)) { break; } - if (current.kind === 197 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 204 /* LabeledStatement */ && current.label.text === node.label.text) { var sourceFile = ts.getSourceFileOfNode(node); grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNodeFromSourceText(sourceFile.text, node.label)); break; @@ -21973,7 +23538,7 @@ var ts; if (catchClause) { // Grammar checking if (catchClause.variableDeclaration) { - if (catchClause.variableDeclaration.name.kind !== 65 /* Identifier */) { + if (catchClause.variableDeclaration.name.kind !== 66 /* Identifier */) { grammarErrorOnFirstToken(catchClause.variableDeclaration.name, ts.Diagnostics.Catch_clause_variable_name_must_be_an_identifier); } else if (catchClause.variableDeclaration.type) { @@ -22048,7 +23613,7 @@ var ts; // perform property check if property or indexer is declared in 'type' // this allows to rule out cases when both property and indexer are inherited from the base class var errorNode; - if (prop.valueDeclaration.name.kind === 129 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { + if (prop.valueDeclaration.name.kind === 133 /* ComputedPropertyName */ || prop.parent === containingType.symbol) { errorNode = prop.valueDeclaration; } else if (indexDeclaration) { @@ -22103,10 +23668,14 @@ var ts; return getTypeOfSymbol(getSymbolOfNode(node)); } function checkClassDeclaration(node) { - if (!node.name && !(node.flags & 256 /* Default */)) { + if (!node.name && !(node.flags & 1024 /* Default */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); } checkClassLikeDeclaration(node); + // Interfaces cannot be merged with non-ambient classes. + if (getSymbolOfNode(node).flags & 64 /* Interface */ && !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) { @@ -22207,46 +23776,63 @@ var ts; continue; } var derived = getTargetSymbol(getPropertyOfObjectType(type, base.name)); + var baseDeclarationFlags = getDeclarationFlagsFromSymbol(base); + ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); if (derived) { - var baseDeclarationFlags = getDeclarationFlagsFromSymbol(base); - var derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); - if ((baseDeclarationFlags & 32 /* Private */) || (derivedDeclarationFlags & 32 /* Private */)) { - // either base or derived property is private - not override, skip it - continue; - } - if ((baseDeclarationFlags & 128 /* Static */) !== (derivedDeclarationFlags & 128 /* Static */)) { - // value of 'static' is not the same for properties - not override, skip it - continue; - } - if ((base.flags & derived.flags & 8192 /* Method */) || ((base.flags & 98308 /* PropertyOrAccessor */) && (derived.flags & 98308 /* PropertyOrAccessor */))) { - // method is overridden with method or property/accessor is overridden with property/accessor - correct case - continue; - } - var errorMessage = void 0; - if (base.flags & 8192 /* Method */) { - if (derived.flags & 98304 /* Accessor */) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; + // In order to resolve whether the inherited method was overriden in the base class or not, + // we compare the Symbols obtained. Since getTargetSymbol returns the symbol on the *uninstantiated* + // type declaration, derived and base resolve to the same symbol even in the case of generic classes. + if (derived === base) { + // derived class inherits base without override/redeclaration + var derivedClassDecl = ts.getDeclarationOfKind(type.symbol, 211 /* ClassDeclaration */); + // It is an error to inherit an abstract member without implementing it or being declared abstract. + // If there is no declaration for the derived class (as in the case of class expressions), + // then the class cannot be declared abstract. + if (baseDeclarationFlags & 256 /* Abstract */ && (!derivedClassDecl || !(derivedClassDecl.flags & 256 /* Abstract */))) { + 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 { - ts.Debug.assert((derived.flags & 4 /* Property */) !== 0); - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; - } - } - else if (base.flags & 4 /* Property */) { - ts.Debug.assert((derived.flags & 8192 /* Method */) !== 0); - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; } else { - ts.Debug.assert((base.flags & 98304 /* Accessor */) !== 0); - ts.Debug.assert((derived.flags & 8192 /* Method */) !== 0); - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + // derived overrides base. + var derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); + if ((baseDeclarationFlags & 32 /* Private */) || (derivedDeclarationFlags & 32 /* Private */)) { + // either base or derived property is private - not override, skip it + continue; + } + if ((baseDeclarationFlags & 128 /* Static */) !== (derivedDeclarationFlags & 128 /* Static */)) { + // value of 'static' is not the same for properties - not override, skip it + continue; + } + if ((base.flags & derived.flags & 8192 /* Method */) || ((base.flags & 98308 /* PropertyOrAccessor */) && (derived.flags & 98308 /* PropertyOrAccessor */))) { + // method is overridden with method or property/accessor is overridden with property/accessor - correct case + continue; + } + var errorMessage = void 0; + if (base.flags & 8192 /* Method */) { + if (derived.flags & 98304 /* Accessor */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; + } + else { + ts.Debug.assert((derived.flags & 4 /* Property */) !== 0); + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; + } + } + else if (base.flags & 4 /* Property */) { + ts.Debug.assert((derived.flags & 8192 /* Method */) !== 0); + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; + } + else { + ts.Debug.assert((base.flags & 98304 /* Accessor */) !== 0); + ts.Debug.assert((derived.flags & 8192 /* Method */) !== 0); + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; + } + error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } - error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } } } function isAccessor(kind) { - return kind === 138 /* GetAccessor */ || kind === 139 /* SetAccessor */; + return kind === 142 /* GetAccessor */ || kind === 143 /* SetAccessor */; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -22316,7 +23902,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 205 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 212 /* InterfaceDeclaration */); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -22333,6 +23919,16 @@ var ts; checkIndexConstraints(type); } } + // Interfaces cannot merge with non-ambient classes. + if (symbol && symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (declaration.kind === 211 /* ClassDeclaration */ && !ts.isInAmbientContext(declaration)) { + error(node, ts.Diagnostics.Only_an_ambient_class_can_be_merged_with_an_interface); + break; + } + } + } } ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) { if (!ts.isSupportedExpressionWithTypeArguments(heritageElement)) { @@ -22353,14 +23949,14 @@ var ts; } function computeEnumMemberValues(node) { var nodeLinks = getNodeLinks(node); - if (!(nodeLinks.flags & 128 /* EnumValuesComputed */)) { + if (!(nodeLinks.flags & 8192 /* EnumValuesComputed */)) { var enumSymbol = getSymbolOfNode(node); var enumType = getDeclaredTypeOfSymbol(enumSymbol); var autoValue = 0; var ambient = ts.isInAmbientContext(node); var enumIsConst = ts.isConst(node); ts.forEach(node.members, function (member) { - if (member.name.kind !== 129 /* ComputedPropertyName */ && isNumericLiteralName(member.name.text)) { + if (member.name.kind !== 133 /* ComputedPropertyName */ && isNumericLiteralName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } var initializer = member.initializer; @@ -22394,24 +23990,24 @@ var ts; getNodeLinks(member).enumMemberValue = autoValue++; } }); - nodeLinks.flags |= 128 /* EnumValuesComputed */; + nodeLinks.flags |= 8192 /* EnumValuesComputed */; } function getConstantValueForEnumMemberInitializer(initializer) { return evalConstant(initializer); function evalConstant(e) { switch (e.kind) { - case 170 /* PrefixUnaryExpression */: + case 176 /* PrefixUnaryExpression */: var value = evalConstant(e.operand); if (value === undefined) { return undefined; } switch (e.operator) { - case 33 /* PlusToken */: return value; - case 34 /* MinusToken */: return -value; - case 47 /* TildeToken */: return ~value; + case 34 /* PlusToken */: return value; + case 35 /* MinusToken */: return -value; + case 48 /* TildeToken */: return ~value; } return undefined; - case 172 /* BinaryExpression */: + case 178 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -22421,31 +24017,31 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 44 /* BarToken */: return left | right; - case 43 /* AmpersandToken */: return left & right; - case 41 /* GreaterThanGreaterThanToken */: return left >> right; - case 42 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 40 /* LessThanLessThanToken */: return left << right; - case 45 /* CaretToken */: return left ^ right; - case 35 /* AsteriskToken */: return left * right; - case 36 /* SlashToken */: return left / right; - case 33 /* PlusToken */: return left + right; - case 34 /* MinusToken */: return left - right; - case 37 /* PercentToken */: return left % right; + case 45 /* BarToken */: return left | right; + case 44 /* AmpersandToken */: return left & right; + case 42 /* GreaterThanGreaterThanToken */: return left >> right; + case 43 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 41 /* LessThanLessThanToken */: return left << right; + case 46 /* CaretToken */: return left ^ right; + case 36 /* AsteriskToken */: return left * right; + case 37 /* SlashToken */: return left / right; + case 34 /* PlusToken */: return left + right; + case 35 /* MinusToken */: return left - right; + case 38 /* PercentToken */: return left % right; } return undefined; case 7 /* NumericLiteral */: return +e.text; - case 164 /* ParenthesizedExpression */: + case 169 /* ParenthesizedExpression */: return evalConstant(e.expression); - case 65 /* Identifier */: - case 159 /* ElementAccessExpression */: - case 158 /* PropertyAccessExpression */: + case 66 /* Identifier */: + case 164 /* ElementAccessExpression */: + case 163 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType; var propertyName; - if (e.kind === 65 /* Identifier */) { + if (e.kind === 66 /* Identifier */) { // unqualified names can refer to member that reside in different declaration of the enum so just doing name resolution won't work. // instead pick current enum type and later try to fetch member from the type enumType = currentType; @@ -22453,7 +24049,7 @@ var ts; } else { var expression; - if (e.kind === 159 /* ElementAccessExpression */) { + if (e.kind === 164 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 8 /* StringLiteral */) { return undefined; @@ -22468,10 +24064,10 @@ var ts; // expression part in ElementAccess\PropertyAccess should be either identifier or dottedName var current = expression; while (current) { - if (current.kind === 65 /* Identifier */) { + if (current.kind === 66 /* Identifier */) { break; } - else if (current.kind === 158 /* PropertyAccessExpression */) { + else if (current.kind === 163 /* PropertyAccessExpression */) { current = current.expression; } else { @@ -22540,7 +24136,7 @@ var ts; var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 207 /* EnumDeclaration */) { + if (declaration.kind !== 214 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -22563,8 +24159,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0; _i < declarations.length; _i++) { var declaration = declarations[_i]; - if ((declaration.kind === 204 /* ClassDeclaration */ || - (declaration.kind === 203 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 211 /* ClassDeclaration */ || + (declaration.kind === 210 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -22618,12 +24214,12 @@ var ts; error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); } } - // if the module merges with a class declaration in the same lexical scope, + // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 204 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 211 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { - getNodeLinks(node).flags |= 2048 /* LexicalModuleMergesWithClass */; + getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; } } // Checks for ambient external modules. @@ -22640,17 +24236,17 @@ var ts; } function getFirstIdentifier(node) { while (true) { - if (node.kind === 128 /* QualifiedName */) { + if (node.kind === 132 /* QualifiedName */) { node = node.left; } - else if (node.kind === 158 /* PropertyAccessExpression */) { + else if (node.kind === 163 /* PropertyAccessExpression */) { node = node.expression; } else { break; } } - ts.Debug.assert(node.kind === 65 /* Identifier */); + ts.Debug.assert(node.kind === 66 /* Identifier */); return node; } function checkExternalImportOrExportDeclaration(node) { @@ -22659,9 +24255,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 209 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; - if (node.parent.kind !== 230 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 218 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 216 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; + if (node.parent.kind !== 245 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 225 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -22684,7 +24280,7 @@ var ts; (symbol.flags & 793056 /* Type */ ? 793056 /* Type */ : 0) | (symbol.flags & 1536 /* Namespace */ ? 1536 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 220 /* ExportSpecifier */ ? + var message = node.kind === 227 /* ExportSpecifier */ ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); @@ -22701,7 +24297,7 @@ var ts; // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors. return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499 /* Modifier */)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers); } if (checkExternalImportOrExportDeclaration(node)) { @@ -22711,7 +24307,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 214 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 221 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -22760,7 +24356,7 @@ var ts; // If we hit an export in an illegal context, just bail out to avoid cascading errors. return; } - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499 /* Modifier */)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { @@ -22768,8 +24364,8 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 209 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; - if (node.parent.kind !== 230 /* SourceFile */ && !inAmbientExternalModule) { + var inAmbientExternalModule = node.parent.kind === 216 /* ModuleBlock */ && node.parent.parent.name.kind === 8 /* StringLiteral */; + if (node.parent.kind !== 245 /* SourceFile */ && !inAmbientExternalModule) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -22783,7 +24379,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - if (node.parent.kind !== 230 /* SourceFile */ && node.parent.kind !== 209 /* ModuleBlock */ && node.parent.kind !== 208 /* ModuleDeclaration */) { + if (node.parent.kind !== 245 /* SourceFile */ && node.parent.kind !== 216 /* ModuleBlock */ && node.parent.kind !== 215 /* ModuleDeclaration */) { return grammarErrorOnFirstToken(node, errorMessage); } } @@ -22798,16 +24394,16 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 230 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 208 /* ModuleDeclaration */ && container.name.kind === 65 /* Identifier */) { + var container = node.parent.kind === 245 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 215 /* ModuleDeclaration */ && container.name.kind === 66 /* Identifier */) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); return; } // Grammar checking - if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 499 /* Modifier */)) { + if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & 2035 /* Modifier */)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 65 /* Identifier */) { + if (node.expression.kind === 66 /* Identifier */) { markExportAsReferenced(node); } else { @@ -22826,10 +24422,10 @@ var ts; } } function getModuleStatements(node) { - if (node.kind === 230 /* SourceFile */) { + if (node.kind === 245 /* SourceFile */) { return node.statements; } - if (node.kind === 208 /* ModuleDeclaration */ && node.body.kind === 209 /* ModuleBlock */) { + if (node.kind === 215 /* ModuleDeclaration */ && node.body.kind === 216 /* ModuleBlock */) { return node.body.statements; } return emptyArray; @@ -22860,112 +24456,126 @@ var ts; } } function checkSourceElement(node) { - if (!node) + if (!node) { return; - switch (node.kind) { - case 130 /* TypeParameter */: + } + var kind = node.kind; + if (cancellationToken) { + // Only bother checking on a few construct kinds. We don't want to be excessivly + // hitting the cancellation token on every node we check. + switch (kind) { + case 215 /* ModuleDeclaration */: + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: + case 210 /* FunctionDeclaration */: + cancellationToken.throwIfCancellationRequested(); + } + } + switch (kind) { + case 134 /* TypeParameter */: return checkTypeParameter(node); - case 131 /* Parameter */: + case 135 /* Parameter */: return checkParameter(node); - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: return checkPropertyDeclaration(node); - case 145 /* FunctionType */: - case 146 /* ConstructorType */: - case 140 /* CallSignature */: - case 141 /* ConstructSignature */: + case 149 /* FunctionType */: + case 150 /* ConstructorType */: + case 144 /* CallSignature */: + case 145 /* ConstructSignature */: return checkSignatureDeclaration(node); - case 142 /* IndexSignature */: + case 146 /* IndexSignature */: return checkSignatureDeclaration(node); - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: return checkMethodDeclaration(node); - case 137 /* Constructor */: + case 141 /* Constructor */: return checkConstructorDeclaration(node); - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: return checkAccessorDeclaration(node); - case 144 /* TypeReference */: + case 148 /* TypeReference */: return checkTypeReferenceNode(node); - case 143 /* TypePredicate */: + case 147 /* TypePredicate */: return checkTypePredicate(node); - case 147 /* TypeQuery */: + case 151 /* TypeQuery */: return checkTypeQuery(node); - case 148 /* TypeLiteral */: + case 152 /* TypeLiteral */: return checkTypeLiteral(node); - case 149 /* ArrayType */: + case 153 /* ArrayType */: return checkArrayType(node); - case 150 /* TupleType */: + case 154 /* TupleType */: return checkTupleType(node); - case 151 /* UnionType */: - return checkUnionType(node); - case 152 /* ParenthesizedType */: + case 155 /* UnionType */: + case 156 /* IntersectionType */: + return checkUnionOrIntersectionType(node); + case 157 /* ParenthesizedType */: return checkSourceElement(node.type); - case 203 /* FunctionDeclaration */: + case 210 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 182 /* Block */: - case 209 /* ModuleBlock */: + case 189 /* Block */: + case 216 /* ModuleBlock */: return checkBlock(node); - case 183 /* VariableStatement */: + case 190 /* VariableStatement */: return checkVariableStatement(node); - case 185 /* ExpressionStatement */: + case 192 /* ExpressionStatement */: return checkExpressionStatement(node); - case 186 /* IfStatement */: + case 193 /* IfStatement */: return checkIfStatement(node); - case 187 /* DoStatement */: + case 194 /* DoStatement */: return checkDoStatement(node); - case 188 /* WhileStatement */: + case 195 /* WhileStatement */: return checkWhileStatement(node); - case 189 /* ForStatement */: + case 196 /* ForStatement */: return checkForStatement(node); - case 190 /* ForInStatement */: + case 197 /* ForInStatement */: return checkForInStatement(node); - case 191 /* ForOfStatement */: + case 198 /* ForOfStatement */: return checkForOfStatement(node); - case 192 /* ContinueStatement */: - case 193 /* BreakStatement */: + case 199 /* ContinueStatement */: + case 200 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 194 /* ReturnStatement */: + case 201 /* ReturnStatement */: return checkReturnStatement(node); - case 195 /* WithStatement */: + case 202 /* WithStatement */: return checkWithStatement(node); - case 196 /* SwitchStatement */: + case 203 /* SwitchStatement */: return checkSwitchStatement(node); - case 197 /* LabeledStatement */: + case 204 /* LabeledStatement */: return checkLabeledStatement(node); - case 198 /* ThrowStatement */: + case 205 /* ThrowStatement */: return checkThrowStatement(node); - case 199 /* TryStatement */: + case 206 /* TryStatement */: return checkTryStatement(node); - case 201 /* VariableDeclaration */: + case 208 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 155 /* BindingElement */: + case 160 /* BindingElement */: return checkBindingElement(node); - case 204 /* ClassDeclaration */: + case 211 /* ClassDeclaration */: return checkClassDeclaration(node); - case 205 /* InterfaceDeclaration */: + case 212 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 206 /* TypeAliasDeclaration */: + case 213 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 207 /* EnumDeclaration */: + case 214 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 212 /* ImportDeclaration */: + case 219 /* ImportDeclaration */: return checkImportDeclaration(node); - case 211 /* ImportEqualsDeclaration */: + case 218 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 218 /* ExportDeclaration */: + case 225 /* ExportDeclaration */: return checkExportDeclaration(node); - case 217 /* ExportAssignment */: + case 224 /* ExportAssignment */: return checkExportAssignment(node); - case 184 /* EmptyStatement */: + case 191 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 200 /* DebuggerStatement */: + case 207 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 221 /* MissingDeclaration */: + case 228 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -22980,86 +24590,95 @@ var ts; // Delaying the type check of the body ensures foo has been assigned a type. function checkFunctionAndClassExpressionBodies(node) { switch (node.kind) { - case 165 /* FunctionExpression */: - case 166 /* ArrowFunction */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); checkFunctionExpressionOrObjectLiteralMethodBody(node); break; - case 177 /* ClassExpression */: + case 183 /* ClassExpression */: ts.forEach(node.members, checkSourceElement); break; - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: ts.forEach(node.decorators, checkFunctionAndClassExpressionBodies); ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); if (ts.isObjectLiteralMethod(node)) { checkFunctionExpressionOrObjectLiteralMethodBody(node); } break; - case 137 /* Constructor */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 203 /* FunctionDeclaration */: + case 141 /* Constructor */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 210 /* FunctionDeclaration */: ts.forEach(node.parameters, checkFunctionAndClassExpressionBodies); break; - case 195 /* WithStatement */: + case 202 /* WithStatement */: checkFunctionAndClassExpressionBodies(node.expression); break; - case 132 /* Decorator */: - case 131 /* Parameter */: - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: - case 153 /* ObjectBindingPattern */: - case 154 /* ArrayBindingPattern */: - case 155 /* BindingElement */: - case 156 /* ArrayLiteralExpression */: - case 157 /* ObjectLiteralExpression */: - case 227 /* PropertyAssignment */: - case 158 /* PropertyAccessExpression */: - case 159 /* ElementAccessExpression */: - case 160 /* CallExpression */: - case 161 /* NewExpression */: - case 162 /* TaggedTemplateExpression */: - case 174 /* TemplateExpression */: - case 180 /* TemplateSpan */: - case 163 /* TypeAssertionExpression */: - case 164 /* ParenthesizedExpression */: - case 168 /* TypeOfExpression */: - case 169 /* VoidExpression */: - case 167 /* DeleteExpression */: - case 170 /* PrefixUnaryExpression */: - case 171 /* PostfixUnaryExpression */: - case 172 /* BinaryExpression */: - case 173 /* ConditionalExpression */: - case 176 /* SpreadElementExpression */: - case 182 /* Block */: - case 209 /* ModuleBlock */: - case 183 /* VariableStatement */: - case 185 /* ExpressionStatement */: - case 186 /* IfStatement */: - case 187 /* DoStatement */: - case 188 /* WhileStatement */: - case 189 /* ForStatement */: - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: - case 192 /* ContinueStatement */: - case 193 /* BreakStatement */: - case 194 /* ReturnStatement */: - case 196 /* SwitchStatement */: - case 210 /* CaseBlock */: - case 223 /* CaseClause */: - case 224 /* DefaultClause */: - case 197 /* LabeledStatement */: - case 198 /* ThrowStatement */: - case 199 /* TryStatement */: - case 226 /* CatchClause */: - case 201 /* VariableDeclaration */: - case 202 /* VariableDeclarationList */: - case 204 /* ClassDeclaration */: - case 207 /* EnumDeclaration */: - case 229 /* EnumMember */: - case 217 /* ExportAssignment */: - case 230 /* SourceFile */: + case 136 /* Decorator */: + case 135 /* Parameter */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: + case 158 /* ObjectBindingPattern */: + case 159 /* ArrayBindingPattern */: + case 160 /* BindingElement */: + case 161 /* ArrayLiteralExpression */: + case 162 /* ObjectLiteralExpression */: + case 242 /* PropertyAssignment */: + case 163 /* PropertyAccessExpression */: + case 164 /* ElementAccessExpression */: + case 165 /* CallExpression */: + case 166 /* NewExpression */: + case 167 /* TaggedTemplateExpression */: + case 180 /* TemplateExpression */: + case 187 /* TemplateSpan */: + case 168 /* TypeAssertionExpression */: + case 186 /* AsExpression */: + case 169 /* ParenthesizedExpression */: + case 173 /* TypeOfExpression */: + case 174 /* VoidExpression */: + case 175 /* AwaitExpression */: + case 172 /* DeleteExpression */: + case 176 /* PrefixUnaryExpression */: + case 177 /* PostfixUnaryExpression */: + case 178 /* BinaryExpression */: + case 179 /* ConditionalExpression */: + case 182 /* SpreadElementExpression */: + case 181 /* YieldExpression */: + case 189 /* Block */: + case 216 /* ModuleBlock */: + case 190 /* VariableStatement */: + case 192 /* ExpressionStatement */: + case 193 /* IfStatement */: + case 194 /* DoStatement */: + case 195 /* WhileStatement */: + case 196 /* ForStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: + case 199 /* ContinueStatement */: + case 200 /* BreakStatement */: + case 201 /* ReturnStatement */: + case 203 /* SwitchStatement */: + case 217 /* CaseBlock */: + case 238 /* CaseClause */: + case 239 /* DefaultClause */: + case 204 /* LabeledStatement */: + case 205 /* ThrowStatement */: + case 206 /* TryStatement */: + case 241 /* CatchClause */: + case 208 /* VariableDeclaration */: + case 209 /* VariableDeclarationList */: + case 211 /* ClassDeclaration */: + case 214 /* EnumDeclaration */: + case 244 /* EnumMember */: + case 224 /* ExportAssignment */: + case 245 /* SourceFile */: + case 237 /* JsxExpression */: + case 230 /* JsxElement */: + case 231 /* JsxSelfClosingElement */: + case 235 /* JsxAttribute */: + case 236 /* JsxSpreadAttribute */: + case 232 /* JsxOpeningElement */: ts.forEachChild(node, checkFunctionAndClassExpressionBodies); break; } @@ -23097,15 +24716,33 @@ var ts; links.flags |= 8 /* EmitExtends */; } if (emitDecorate) { - links.flags |= 512 /* EmitDecorate */; + links.flags |= 16 /* EmitDecorate */; } if (emitParam) { - links.flags |= 1024 /* EmitParam */; + links.flags |= 32 /* EmitParam */; + } + if (emitAwaiter) { + links.flags |= 64 /* EmitAwaiter */; + } + if (emitGenerator || (emitAwaiter && languageVersion < 2 /* ES6 */)) { + links.flags |= 128 /* EmitGenerator */; } links.flags |= 1 /* TypeChecked */; } } - function getDiagnostics(sourceFile) { + function getDiagnostics(sourceFile, ct) { + try { + // Record the cancellation token so it can be checked later on during checkSourceElement. + // Do this in a finally block so we can ensure that it gets reset back to nothing after + // this call is done. + cancellationToken = ct; + return getDiagnosticsWorker(sourceFile); + } + finally { + cancellationToken = undefined; + } + } + function getDiagnosticsWorker(sourceFile) { throwIfNonDiagnosticsProducing(); if (sourceFile) { checkSourceFile(sourceFile); @@ -23127,7 +24764,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 195 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 202 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -23150,29 +24787,36 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 230 /* SourceFile */: + case 245 /* SourceFile */: if (!ts.isExternalModule(location)) { break; } - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 207 /* EnumDeclaration */: + case 214 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 177 /* ClassExpression */: - if (location.name) { + case 183 /* ClassExpression */: + var className = location.name; + if (className) { copySymbol(location.symbol, meaning); } - // Fall through - case 204 /* ClassDeclaration */: - case 205 /* InterfaceDeclaration */: + // fall through; this fall-through is necessary because we would like to handle + // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: + // If we didn't come from static member of class or interface, + // add the type parameters into the symbol table + // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. + // Note: that the memberFlags come from previous iteration. if (!(memberFlags & 128 /* Static */)) { copySymbols(getSymbolOfNode(location).members, meaning & 793056 /* Type */); } break; - case 165 /* FunctionExpression */: - if (location.name) { + case 170 /* FunctionExpression */: + var funcName = location.name; + if (funcName) { copySymbol(location.symbol, meaning); } break; @@ -23182,11 +24826,20 @@ var ts; } copySymbols(globals, meaning); } - // Returns 'true' if we should stop processing symbols. + /** + * Copy the given symbol into symbol tables if the symbol has the given meaning + * and it doesn't already existed in the symbol table + * @param key a key for storing in symbol table; if undefined, use symbol.name + * @param symbol the symbol to be added into symbol table + * @param meaning meaning of symbol to filter by before adding to symbol table + */ function copySymbol(symbol, meaning) { if (symbol.flags & meaning) { var id = symbol.name; - if (!isReservedMemberName(id) && !ts.hasProperty(symbols, id)) { + // We will copy all symbol regardless of its reserved name because + // symbolsToArray will check whether the key is a reserved name and + // it will not copy symbol with reserved name to the array + if (!ts.hasProperty(symbols, id)) { symbols[id] = symbol; } } @@ -23194,51 +24847,50 @@ var ts; function copySymbols(source, meaning) { if (meaning) { for (var id in source) { - if (ts.hasProperty(source, id)) { - copySymbol(source[id], meaning); - } + var symbol = source[id]; + copySymbol(symbol, meaning); } } } } function isTypeDeclarationName(name) { - return name.kind === 65 /* Identifier */ && + return name.kind === 66 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 130 /* TypeParameter */: - case 204 /* ClassDeclaration */: - case 205 /* InterfaceDeclaration */: - case 206 /* TypeAliasDeclaration */: - case 207 /* EnumDeclaration */: + case 134 /* TypeParameter */: + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: + case 213 /* TypeAliasDeclaration */: + case 214 /* EnumDeclaration */: return true; } } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 128 /* QualifiedName */) { + while (node.parent && node.parent.kind === 132 /* QualifiedName */) { node = node.parent; } - return node.parent && node.parent.kind === 144 /* TypeReference */; + return node.parent && node.parent.kind === 148 /* TypeReference */; } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 158 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 163 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 179 /* ExpressionWithTypeArguments */; + return node.parent && node.parent.kind === 185 /* ExpressionWithTypeArguments */; } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 128 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 132 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 211 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 218 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 217 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 224 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -23250,11 +24902,11 @@ var ts; if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 217 /* ExportAssignment */) { + if (entityName.parent.kind === 224 /* ExportAssignment */) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793056 /* Type */ | 1536 /* Namespace */ | 8388608 /* Alias */); } - if (entityName.kind !== 158 /* PropertyAccessExpression */) { + if (entityName.kind !== 163 /* PropertyAccessExpression */) { if (isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import return getSymbolOfPartOfRightHandSideOfImportEquals(entityName); @@ -23264,29 +24916,32 @@ var ts; entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { - var meaning = entityName.parent.kind === 179 /* ExpressionWithTypeArguments */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 185 /* ExpressionWithTypeArguments */ ? 793056 /* Type */ : 1536 /* Namespace */; meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } + else if ((entityName.parent.kind === 232 /* JsxOpeningElement */) || (entityName.parent.kind === 231 /* JsxSelfClosingElement */)) { + return getJsxElementTagSymbol(entityName.parent); + } else if (ts.isExpression(entityName)) { if (ts.nodeIsMissing(entityName)) { // Missing entity name. return undefined; } - if (entityName.kind === 65 /* Identifier */) { + if (entityName.kind === 66 /* Identifier */) { // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead // return the alias symbol. var meaning = 107455 /* Value */ | 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - else if (entityName.kind === 158 /* PropertyAccessExpression */) { + else if (entityName.kind === 163 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 128 /* QualifiedName */) { + else if (entityName.kind === 132 /* QualifiedName */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -23295,13 +24950,16 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 144 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; + var meaning = entityName.parent.kind === 148 /* TypeReference */ ? 793056 /* Type */ : 1536 /* Namespace */; // Include aliases in the meaning, this ensures that we do not follow aliases to where they point and instead // return the alias symbol. meaning |= 8388608 /* Alias */; return resolveEntityName(entityName, meaning); } - if (entityName.parent.kind === 143 /* TypePredicate */) { + else if (entityName.parent.kind === 235 /* JsxAttribute */) { + return getJsxAttributePropertySymbol(entityName.parent); + } + if (entityName.parent.kind === 147 /* TypePredicate */) { return resolveEntityName(entityName, 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? @@ -23316,40 +24974,39 @@ var ts; // This is a declaration, call getSymbolOfNode return getSymbolOfNode(node.parent); } - if (node.kind === 65 /* Identifier */ && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 217 /* ExportAssignment */ + if (node.kind === 66 /* Identifier */ && isInRightSideOfImportOrExportAssignment(node)) { + return node.parent.kind === 224 /* ExportAssignment */ ? getSymbolOfEntityNameOrPropertyAccessExpression(node) : getSymbolOfPartOfRightHandSideOfImportEquals(node); } switch (node.kind) { - case 65 /* Identifier */: - case 158 /* PropertyAccessExpression */: - case 128 /* QualifiedName */: + case 66 /* Identifier */: + case 163 /* PropertyAccessExpression */: + case 132 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 93 /* ThisKeyword */: - case 91 /* SuperKeyword */: + case 94 /* ThisKeyword */: + case 92 /* SuperKeyword */: var type = checkExpression(node); return type.symbol; - case 114 /* ConstructorKeyword */: + case 118 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 137 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 141 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; case 8 /* StringLiteral */: // External module name in an import declaration - var moduleName; if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 212 /* ImportDeclaration */ || node.parent.kind === 218 /* ExportDeclaration */) && + ((node.parent.kind === 219 /* ImportDeclaration */ || node.parent.kind === 225 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } - // Intentional fall-through + // Fall through case 7 /* NumericLiteral */: // index access - if (node.parent.kind === 159 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind === 164 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = checkExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -23366,7 +25023,7 @@ var ts; // The function returns a value symbol of an identifier in the short-hand property assignment. // This is necessary as an identifier in short-hand property assignment can contains two meaning: // property name and property value. - if (location && location.kind === 228 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 243 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 107455 /* Value */); } return undefined; @@ -23405,6 +25062,9 @@ var ts; var symbol = getSymbolInfo(node); return symbol && getTypeOfSymbol(symbol); } + if (ts.isBindingPattern(node)) { + return getTypeForVariableLikeDeclaration(node.parent); + } if (isInRightSideOfImportOrExportAssignment(node)) { var symbol = getSymbolInfo(node); var declaredType = symbol && getDeclaredTypeOfSymbol(symbol); @@ -23443,11 +25103,11 @@ var ts; return getNamedMembers(propsByName); } function getRootSymbols(symbol) { - if (symbol.flags & 268435456 /* UnionProperty */) { + if (symbol.flags & 268435456 /* SyntheticProperty */) { var symbols = []; - var name_14 = symbol.name; - ts.forEach(getSymbolLinks(symbol).unionType.types, function (t) { - symbols.push(getPropertyOfType(t, name_14)); + var name_15 = symbol.name; + ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { + symbols.push(getPropertyOfType(t, name_15)); }); return symbols; } @@ -23477,11 +25137,11 @@ var ts; } var parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { - if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 230 /* SourceFile */) { + if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 245 /* SourceFile */) { return parentSymbol.valueDeclaration; } for (var n = node.parent; n; n = n.parent) { - if ((n.kind === 208 /* ModuleDeclaration */ || n.kind === 207 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { + if ((n.kind === 215 /* ModuleDeclaration */ || n.kind === 214 /* EnumDeclaration */) && getSymbolOfNode(n) === parentSymbol) { return n; } } @@ -23496,11 +25156,11 @@ var ts; } function isStatementWithLocals(node) { switch (node.kind) { - case 182 /* Block */: - case 210 /* CaseBlock */: - case 189 /* ForStatement */: - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: + case 189 /* Block */: + case 217 /* CaseBlock */: + case 196 /* ForStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: return true; } return false; @@ -23530,22 +25190,22 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 211 /* ImportEqualsDeclaration */: - case 213 /* ImportClause */: - case 214 /* NamespaceImport */: - case 216 /* ImportSpecifier */: - case 220 /* ExportSpecifier */: + case 218 /* ImportEqualsDeclaration */: + case 220 /* ImportClause */: + case 221 /* NamespaceImport */: + case 223 /* ImportSpecifier */: + case 227 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node)); - case 218 /* ExportDeclaration */: + case 225 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 217 /* ExportAssignment */: - return node.expression && node.expression.kind === 65 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; + case 224 /* ExportAssignment */: + return node.expression && node.expression.kind === 66 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node)) : true; } return false; } function isTopLevelValueImportEqualsWithEntityName(node) { - if (node.parent.kind !== 230 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node.parent.kind !== 245 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -23603,7 +25263,7 @@ var ts; return getNodeLinks(node).enumMemberValue; } function getConstantValue(node) { - if (node.kind === 229 /* EnumMember */) { + if (node.kind === 244 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -23615,196 +25275,51 @@ var ts; } return undefined; } - /** Serializes an EntityName (with substitutions) to an appropriate JS constructor value. Used by the __metadata decorator. */ - function serializeEntityName(node, fallbackPath) { - if (node.kind === 65 /* Identifier */) { - // TODO(ron.buckton): The getExpressionNameSubstitution function has been removed, but calling it - // here has no effect anyway as an identifier in a type name is not an expression. - // var substitution = getExpressionNameSubstitution(node, getGeneratedNameForNode); - // var text = substitution || (node).text; - var text = node.text; - if (fallbackPath) { - fallbackPath.push(text); - } - else { - return text; - } + function isFunctionType(type) { + return type.flags & 80896 /* ObjectType */ && getSignaturesOfType(type, 0 /* Call */).length > 0; + } + function getTypeReferenceSerializationKind(node) { + // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. + var symbol = resolveEntityName(node.typeName, 107455 /* Value */, true); + var constructorType = symbol ? getTypeOfSymbol(symbol) : undefined; + if (constructorType && isConstructorType(constructorType)) { + return ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; + } + var type = getTypeFromTypeNode(node); + if (type === unknownType) { + return ts.TypeReferenceSerializationKind.Unknown; + } + else if (type.flags & 1 /* Any */) { + return ts.TypeReferenceSerializationKind.ObjectType; + } + else if (allConstituentTypesHaveKind(type, 16 /* Void */)) { + return ts.TypeReferenceSerializationKind.VoidType; + } + else if (allConstituentTypesHaveKind(type, 8 /* Boolean */)) { + return ts.TypeReferenceSerializationKind.BooleanType; + } + else if (allConstituentTypesHaveKind(type, 132 /* NumberLike */)) { + return ts.TypeReferenceSerializationKind.NumberLikeType; + } + else if (allConstituentTypesHaveKind(type, 258 /* StringLike */)) { + return ts.TypeReferenceSerializationKind.StringLikeType; + } + else if (allConstituentTypesHaveKind(type, 8192 /* Tuple */)) { + return ts.TypeReferenceSerializationKind.ArrayLikeType; + } + else if (allConstituentTypesHaveKind(type, 4194304 /* ESSymbol */)) { + return ts.TypeReferenceSerializationKind.ESSymbolType; + } + else if (isFunctionType(type)) { + return ts.TypeReferenceSerializationKind.TypeWithCallSignature; + } + else if (isArrayType(type)) { + return ts.TypeReferenceSerializationKind.ArrayLikeType; } else { - var left = serializeEntityName(node.left, fallbackPath); - var right = serializeEntityName(node.right, fallbackPath); - if (!fallbackPath) { - return left + "." + right; - } + return ts.TypeReferenceSerializationKind.ObjectType; } } - /** Serializes a TypeReferenceNode to an appropriate JS constructor value. Used by the __metadata decorator. */ - function serializeTypeReferenceNode(node) { - // serialization of a TypeReferenceNode uses the following rules: - // - // * The serialized type of a TypeReference that is `void` is "void 0". - // * The serialized type of a TypeReference that is a `boolean` is "Boolean". - // * The serialized type of a TypeReference that is an enum or `number` is "Number". - // * The serialized type of a TypeReference that is a string literal or `string` is "String". - // * The serialized type of a TypeReference that is a tuple is "Array". - // * The serialized type of a TypeReference that is a `symbol` is "Symbol". - // * The serialized type of a TypeReference with a value declaration is its entity name. - // * The serialized type of a TypeReference with a call or construct signature is "Function". - // * The serialized type of any other type is "Object". - var type = getTypeFromTypeNode(node); - if (type.flags & 16 /* Void */) { - return "void 0"; - } - else if (type.flags & 8 /* Boolean */) { - return "Boolean"; - } - else if (type.flags & 132 /* NumberLike */) { - return "Number"; - } - else if (type.flags & 258 /* StringLike */) { - return "String"; - } - else if (type.flags & 8192 /* Tuple */) { - return "Array"; - } - else if (type.flags & 2097152 /* ESSymbol */) { - return "Symbol"; - } - else if (type === unknownType) { - var fallbackPath = []; - serializeEntityName(node.typeName, fallbackPath); - return fallbackPath; - } - else if (type.symbol && type.symbol.valueDeclaration) { - return serializeEntityName(node.typeName); - } - else if (typeHasCallOrConstructSignatures(type)) { - return "Function"; - } - return "Object"; - } - /** Serializes a TypeNode to an appropriate JS constructor value. Used by the __metadata decorator. */ - function serializeTypeNode(node) { - // serialization of a TypeNode uses the following rules: - // - // * The serialized type of `void` is "void 0" (undefined). - // * The serialized type of a parenthesized type is the serialized type of its nested type. - // * The serialized type of a Function or Constructor type is "Function". - // * The serialized type of an Array or Tuple type is "Array". - // * The serialized type of `boolean` is "Boolean". - // * The serialized type of `string` or a string-literal type is "String". - // * The serialized type of a type reference is handled by `serializeTypeReferenceNode`. - // * The serialized type of any other type node is "Object". - if (node) { - switch (node.kind) { - case 99 /* VoidKeyword */: - return "void 0"; - case 152 /* ParenthesizedType */: - return serializeTypeNode(node.type); - case 145 /* FunctionType */: - case 146 /* ConstructorType */: - return "Function"; - case 149 /* ArrayType */: - case 150 /* TupleType */: - return "Array"; - case 113 /* BooleanKeyword */: - return "Boolean"; - case 123 /* StringKeyword */: - case 8 /* StringLiteral */: - return "String"; - case 121 /* NumberKeyword */: - return "Number"; - case 144 /* TypeReference */: - return serializeTypeReferenceNode(node); - case 147 /* TypeQuery */: - case 148 /* TypeLiteral */: - case 151 /* UnionType */: - case 112 /* AnyKeyword */: - break; - default: - ts.Debug.fail("Cannot serialize unexpected type node."); - break; - } - } - return "Object"; - } - /** Serializes the type of a declaration to an appropriate JS constructor value. Used by the __metadata decorator for a class member. */ - function serializeTypeOfNode(node) { - // serialization of the type of a declaration uses the following rules: - // - // * The serialized type of a ClassDeclaration is "Function" - // * The serialized type of a ParameterDeclaration is the serialized type of its type annotation. - // * The serialized type of a PropertyDeclaration is the serialized type of its type annotation. - // * The serialized type of an AccessorDeclaration is the serialized type of the return type annotation of its getter or parameter type annotation of its setter. - // * The serialized type of any other FunctionLikeDeclaration is "Function". - // * The serialized type of any other node is "void 0". - // - // For rules on serializing type annotations, see `serializeTypeNode`. - switch (node.kind) { - case 204 /* ClassDeclaration */: return "Function"; - case 134 /* PropertyDeclaration */: return serializeTypeNode(node.type); - case 131 /* Parameter */: return serializeTypeNode(node.type); - case 138 /* GetAccessor */: return serializeTypeNode(node.type); - case 139 /* SetAccessor */: return serializeTypeNode(getSetAccessorTypeAnnotationNode(node)); - } - if (ts.isFunctionLike(node)) { - return "Function"; - } - return "void 0"; - } - /** Serializes the parameter types of a function or the constructor of a class. Used by the __metadata decorator for a method or set accessor. */ - function serializeParameterTypesOfNode(node) { - // serialization of parameter types uses the following rules: - // - // * If the declaration is a class, the parameters of the first constructor with a body are used. - // * If the declaration is function-like and has a body, the parameters of the function are used. - // - // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. - if (node) { - var valueDeclaration; - if (node.kind === 204 /* ClassDeclaration */) { - valueDeclaration = ts.getFirstConstructorWithBody(node); - } - else if (ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)) { - valueDeclaration = node; - } - if (valueDeclaration) { - var result; - var parameters = valueDeclaration.parameters; - var parameterCount = parameters.length; - if (parameterCount > 0) { - result = new Array(parameterCount); - for (var i = 0; i < parameterCount; i++) { - if (parameters[i].dotDotDotToken) { - var parameterType = parameters[i].type; - if (parameterType.kind === 149 /* ArrayType */) { - parameterType = parameterType.elementType; - } - else if (parameterType.kind === 144 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { - parameterType = parameterType.typeArguments[0]; - } - else { - parameterType = undefined; - } - result[i] = serializeTypeNode(parameterType); - } - else { - result[i] = serializeTypeOfNode(parameters[i]); - } - } - return result; - } - } - } - return emptyArray; - } - /** Serializes the return type of function. Used by the __metadata decorator for a method. */ - function serializeReturnTypeOfNode(node) { - if (node && ts.isFunctionLike(node)) { - return serializeTypeNode(node.type); - } - return "void 0"; - } function writeTypeOfDeclaration(declaration, enclosingDeclaration, flags, writer) { // Get type of the symbol if this is the valid symbol otherwise get type at location var symbol = getSymbolOfNode(declaration); @@ -23836,13 +25351,13 @@ var ts; } function getBlockScopedVariableId(n) { ts.Debug.assert(!ts.nodeIsSynthesized(n)); - var isVariableDeclarationOrBindingElement = n.parent.kind === 155 /* BindingElement */ || (n.parent.kind === 201 /* VariableDeclaration */ && n.parent.name === n); + var isVariableDeclarationOrBindingElement = n.parent.kind === 160 /* BindingElement */ || (n.parent.kind === 208 /* VariableDeclaration */ && n.parent.name === n); var symbol = (isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) || getNodeLinks(n).resolvedSymbol || resolveName(n, n.text, 107455 /* Value */ | 8388608 /* Alias */, undefined, undefined); var isLetOrConst = symbol && (symbol.flags & 2 /* BlockScopedVariable */) && - symbol.valueDeclaration.parent.kind !== 226 /* CatchClause */; + symbol.valueDeclaration.parent.kind !== 241 /* CatchClause */; if (isLetOrConst) { // side-effect of calling this method: // assign id to symbol if it was not yet set @@ -23884,9 +25399,7 @@ var ts; collectLinkedAliases: collectLinkedAliases, getBlockScopedVariableId: getBlockScopedVariableId, getReferencedValueDeclaration: getReferencedValueDeclaration, - serializeTypeOfNode: serializeTypeOfNode, - serializeParameterTypesOfNode: serializeParameterTypesOfNode, - serializeReturnTypeOfNode: serializeReturnTypeOfNode + getTypeReferenceSerializationKind: getTypeReferenceSerializationKind }; } function initializeTypeChecker() { @@ -23913,7 +25426,19 @@ var ts; globalNumberType = getGlobalType("Number"); globalBooleanType = getGlobalType("Boolean"); globalRegExpType = getGlobalType("RegExp"); + jsxElementType = getExportedTypeFromNamespace("JSX", JsxNames.Element); + getGlobalClassDecoratorType = ts.memoize(function () { return getGlobalType("ClassDecorator"); }); + getGlobalPropertyDecoratorType = ts.memoize(function () { return getGlobalType("PropertyDecorator"); }); + getGlobalMethodDecoratorType = ts.memoize(function () { return getGlobalType("MethodDecorator"); }); + getGlobalParameterDecoratorType = ts.memoize(function () { return getGlobalType("ParameterDecorator"); }); getGlobalTypedPropertyDescriptorType = ts.memoize(function () { return getGlobalType("TypedPropertyDescriptor", 1); }); + getGlobalPromiseType = ts.memoize(function () { return getGlobalType("Promise", 1); }); + tryGetGlobalPromiseType = ts.memoize(function () { return getGlobalSymbol("Promise", 793056 /* Type */, undefined) && getGlobalPromiseType(); }); + getGlobalPromiseLikeType = ts.memoize(function () { return getGlobalType("PromiseLike", 1); }); + getInstantiatedGlobalPromiseLikeType = ts.memoize(createInstantiatedPromiseLikeType); + getGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Promise"); }); + getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); + getGlobalThenableType = ts.memoize(createThenableType); // If we're in ES6 mode, load the TemplateStringsArray. // Otherwise, default to 'unknown' for the purposes of type checking in LS scenarios. if (languageVersion >= 2 /* ES6 */) { @@ -23937,6 +25462,24 @@ var ts; } anyArrayType = createArrayType(anyType); } + function createInstantiatedPromiseLikeType() { + var promiseLikeType = getGlobalPromiseLikeType(); + if (promiseLikeType !== emptyObjectType) { + return createTypeReference(promiseLikeType, [anyType]); + } + return emptyObjectType; + } + function createThenableType() { + // build the thenable type that is used to verify against a non-promise "thenable" operand to `await`. + var thenPropertySymbol = createSymbol(67108864 /* Transient */ | 4 /* Property */, "then"); + getSymbolLinks(thenPropertySymbol).type = globalFunctionType; + var thenableType = createObjectType(65536 /* Anonymous */); + thenableType.properties = [thenPropertySymbol]; + thenableType.members = createSymbolTable(thenableType.properties); + thenableType.callSignatures = []; + thenableType.constructSignatures = []; + return thenableType; + } // GRAMMAR CHECKING function checkGrammarDecorators(node) { if (!node.decorators) { @@ -23948,7 +25491,7 @@ var ts; else if (languageVersion < 1 /* ES5 */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher); } - else if (node.kind === 138 /* GetAccessor */ || node.kind === 139 /* SetAccessor */) { + else if (node.kind === 142 /* GetAccessor */ || node.kind === 143 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -23958,33 +25501,38 @@ var ts; } function checkGrammarModifiers(node) { switch (node.kind) { - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 137 /* Constructor */: - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 142 /* IndexSignature */: - case 208 /* ModuleDeclaration */: - case 212 /* ImportDeclaration */: - case 211 /* ImportEqualsDeclaration */: - case 218 /* ExportDeclaration */: - case 217 /* ExportAssignment */: - case 131 /* Parameter */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 141 /* Constructor */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 146 /* IndexSignature */: + case 215 /* ModuleDeclaration */: + case 219 /* ImportDeclaration */: + case 218 /* ImportEqualsDeclaration */: + case 225 /* ExportDeclaration */: + case 224 /* ExportAssignment */: + case 135 /* Parameter */: break; - case 204 /* ClassDeclaration */: - case 205 /* InterfaceDeclaration */: - case 183 /* VariableStatement */: - case 203 /* FunctionDeclaration */: - case 206 /* TypeAliasDeclaration */: - if (node.modifiers && node.parent.kind !== 209 /* ModuleBlock */ && node.parent.kind !== 230 /* SourceFile */) { + case 210 /* FunctionDeclaration */: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 115 /* AsyncKeyword */) && + node.parent.kind !== 216 /* ModuleBlock */ && node.parent.kind !== 245 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; - case 207 /* EnumDeclaration */: - if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 70 /* ConstKeyword */) && - node.parent.kind !== 209 /* ModuleBlock */ && node.parent.kind !== 230 /* SourceFile */) { + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: + case 190 /* VariableStatement */: + case 213 /* TypeAliasDeclaration */: + if (node.modifiers && node.parent.kind !== 216 /* ModuleBlock */ && node.parent.kind !== 245 /* SourceFile */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); + } + break; + case 214 /* EnumDeclaration */: + if (node.modifiers && (node.modifiers.length > 1 || node.modifiers[0].kind !== 71 /* ConstKeyword */) && + node.parent.kind !== 216 /* ModuleBlock */ && node.parent.kind !== 245 /* SourceFile */) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } break; @@ -23994,19 +25542,19 @@ var ts; if (!node.modifiers) { return; } - var lastStatic, lastPrivate, lastProtected, lastDeclare; + var lastStatic, lastPrivate, lastProtected, lastDeclare, lastAsync; var flags = 0; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; switch (modifier.kind) { - case 108 /* PublicKeyword */: - case 107 /* ProtectedKeyword */: - case 106 /* PrivateKeyword */: + case 109 /* PublicKeyword */: + case 108 /* ProtectedKeyword */: + case 107 /* PrivateKeyword */: var text = void 0; - if (modifier.kind === 108 /* PublicKeyword */) { + if (modifier.kind === 109 /* PublicKeyword */) { text = "public"; } - else if (modifier.kind === 107 /* ProtectedKeyword */) { + else if (modifier.kind === 108 /* ProtectedKeyword */) { text = "protected"; lastProtected = modifier; } @@ -24020,74 +25568,159 @@ var ts; else if (flags & 128 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static"); } - else if (node.parent.kind === 209 /* ModuleBlock */ || node.parent.kind === 230 /* SourceFile */) { + else if (flags & 512 /* Async */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); + } + else if (node.parent.kind === 216 /* ModuleBlock */ || node.parent.kind === 245 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } + else if (flags & 256 /* Abstract */) { + if (modifier.kind === 107 /* PrivateKeyword */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); + } + else { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract"); + } + } flags |= ts.modifierToFlag(modifier.kind); break; - case 109 /* StaticKeyword */: + case 110 /* StaticKeyword */: if (flags & 128 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } - else if (node.parent.kind === 209 /* ModuleBlock */ || node.parent.kind === 230 /* SourceFile */) { + else if (flags & 512 /* Async */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); + } + else if (node.parent.kind === 216 /* ModuleBlock */ || node.parent.kind === 245 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_element, "static"); } - else if (node.kind === 131 /* Parameter */) { + else if (node.kind === 135 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } + else if (flags & 256 /* Abstract */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); + } flags |= 128 /* Static */; lastStatic = modifier; break; - case 78 /* ExportKeyword */: + case 79 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } else if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } - else if (node.parent.kind === 204 /* ClassDeclaration */) { + else if (flags & 256 /* Abstract */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); + } + else if (flags & 512 /* Async */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); + } + else if (node.parent.kind === 211 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 131 /* Parameter */) { + else if (node.kind === 135 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 115 /* DeclareKeyword */: + case 119 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } - else if (node.parent.kind === 204 /* ClassDeclaration */) { + else if (flags & 512 /* Async */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); + } + else if (node.parent.kind === 211 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 131 /* Parameter */) { + else if (node.kind === 135 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 209 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 216 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; + case 112 /* AbstractKeyword */: + if (flags & 256 /* Abstract */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); + } + if (node.kind !== 211 /* ClassDeclaration */) { + if (node.kind !== 140 /* MethodDeclaration */) { + return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); + } + if (!(node.parent.kind === 211 /* ClassDeclaration */ && node.parent.flags & 256 /* Abstract */)) { + return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); + } + if (flags & 128 /* Static */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); + } + if (flags & 32 /* Private */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); + } + } + flags |= 256 /* Abstract */; + break; + case 115 /* AsyncKeyword */: + if (flags & 512 /* Async */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); + } + else if (flags & 2 /* Ambient */ || ts.isInAmbientContext(node.parent)) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); + } + else if (node.kind === 135 /* Parameter */) { + return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); + } + flags |= 512 /* Async */; + lastAsync = modifier; + break; } } - if (node.kind === 137 /* Constructor */) { + if (node.kind === 141 /* Constructor */) { if (flags & 128 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } + if (flags & 256 /* Abstract */) { + return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); + } else if (flags & 64 /* Protected */) { return grammarErrorOnNode(lastProtected, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected"); } else if (flags & 32 /* Private */) { return grammarErrorOnNode(lastPrivate, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } + else if (flags & 512 /* Async */) { + return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async"); + } + return; } - else if ((node.kind === 212 /* ImportDeclaration */ || node.kind === 211 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { - return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare"); + else if ((node.kind === 219 /* ImportDeclaration */ || node.kind === 218 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 131 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 135 /* Parameter */ && (flags & 112 /* AccessibilityModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_a_binding_pattern); } + if (flags & 512 /* Async */) { + return checkGrammarAsyncModifier(node, lastAsync); + } + } + function checkGrammarAsyncModifier(node, asyncModifier) { + if (languageVersion < 2 /* ES6 */) { + return grammarErrorOnNode(asyncModifier, ts.Diagnostics.Async_functions_are_only_available_when_targeting_ECMAScript_6_and_higher); + } + switch (node.kind) { + case 140 /* MethodDeclaration */: + case 210 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: + if (!node.asteriskToken) { + return false; + } + break; + } + return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); } function checkGrammarForDisallowedTrailingComma(list) { if (list && list.hasTrailingComma) { @@ -24149,7 +25782,7 @@ var ts; checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } function checkGrammarArrowFunction(node, file) { - if (node.kind === 166 /* ArrowFunction */) { + if (node.kind === 171 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -24172,7 +25805,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); } - if (parameter.flags & 499 /* Modifier */) { + if (parameter.flags & 2035 /* Modifier */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); } if (parameter.questionToken) { @@ -24184,7 +25817,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 !== 123 /* StringKeyword */ && parameter.type.kind !== 121 /* NumberKeyword */) { + if (parameter.type.kind !== 127 /* StringKeyword */ && parameter.type.kind !== 125 /* NumberKeyword */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -24192,7 +25825,7 @@ var ts; } } function checkGrammarForIndexSignatureModifier(node) { - if (node.flags & 499 /* Modifier */) { + if (node.flags & 2035 /* Modifier */) { grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_not_permitted_on_index_signature_members); } } @@ -24212,20 +25845,20 @@ var ts; return checkGrammarForDisallowedTrailingComma(typeArguments) || checkGrammarForAtLeastOneTypeArgument(node, typeArguments); } - function checkGrammarForOmittedArgument(node, arguments) { - if (arguments) { + function checkGrammarForOmittedArgument(node, args) { + if (args) { var sourceFile = ts.getSourceFileOfNode(node); - for (var _i = 0; _i < arguments.length; _i++) { - var arg = arguments[_i]; - if (arg.kind === 178 /* OmittedExpression */) { + for (var _i = 0; _i < args.length; _i++) { + var arg = args[_i]; + if (arg.kind === 184 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } } } - function checkGrammarArguments(node, arguments) { - return checkGrammarForDisallowedTrailingComma(arguments) || - checkGrammarForOmittedArgument(node, arguments); + function checkGrammarArguments(node, args) { + return checkGrammarForDisallowedTrailingComma(args) || + checkGrammarForOmittedArgument(node, args); } function checkGrammarHeritageClause(node) { var types = node.types; @@ -24244,7 +25877,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 === 79 /* ExtendsKeyword */) { + if (heritageClause.token === 80 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -24257,7 +25890,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 102 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 103 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -24273,14 +25906,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 79 /* ExtendsKeyword */) { + if (heritageClause.token === 80 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 102 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 103 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -24291,19 +25924,19 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 129 /* ComputedPropertyName */) { + if (node.kind !== 133 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 172 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 23 /* CommaToken */) { + if (computedPropertyName.expression.kind === 178 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 23 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 203 /* FunctionDeclaration */ || - node.kind === 165 /* FunctionExpression */ || - node.kind === 136 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 210 /* FunctionDeclaration */ || + node.kind === 170 /* FunctionExpression */ || + node.kind === 140 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } @@ -24328,11 +25961,11 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccesor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - var name_15 = prop.name; - if (prop.kind === 178 /* OmittedExpression */ || - name_15.kind === 129 /* ComputedPropertyName */) { + var name_16 = prop.name; + if (prop.kind === 184 /* OmittedExpression */ || + name_16.kind === 133 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it - checkGrammarComputedPropertyName(name_15); + checkGrammarComputedPropertyName(name_16); continue; } // ECMA-262 11.1.5 Object Initialiser @@ -24344,70 +25977,91 @@ var ts; // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; - if (prop.kind === 227 /* PropertyAssignment */ || prop.kind === 228 /* ShorthandPropertyAssignment */) { + if (prop.kind === 242 /* PropertyAssignment */ || prop.kind === 243 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop, prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); - if (name_15.kind === 7 /* NumericLiteral */) { - checkGrammarNumericLiteral(name_15); + if (name_16.kind === 7 /* NumericLiteral */) { + checkGrammarNumericLiteral(name_16); } currentKind = Property; } - else if (prop.kind === 136 /* MethodDeclaration */) { + else if (prop.kind === 140 /* MethodDeclaration */) { currentKind = Property; } - else if (prop.kind === 138 /* GetAccessor */) { + else if (prop.kind === 142 /* GetAccessor */) { currentKind = GetAccessor; } - else if (prop.kind === 139 /* SetAccessor */) { + else if (prop.kind === 143 /* SetAccessor */) { currentKind = SetAccesor; } else { ts.Debug.fail("Unexpected syntax kind:" + prop.kind); } - if (!ts.hasProperty(seen, name_15.text)) { - seen[name_15.text] = currentKind; + if (!ts.hasProperty(seen, name_16.text)) { + seen[name_16.text] = currentKind; } else { - var existingKind = seen[name_15.text]; + var existingKind = seen[name_16.text]; if (currentKind === Property && existingKind === Property) { continue; } else if ((currentKind & GetOrSetAccessor) && (existingKind & GetOrSetAccessor)) { if (existingKind !== GetOrSetAccessor && currentKind !== existingKind) { - seen[name_15.text] = currentKind | existingKind; + seen[name_16.text] = currentKind | existingKind; } else { - return grammarErrorOnNode(name_15, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); + return grammarErrorOnNode(name_16, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name); } } else { - return grammarErrorOnNode(name_15, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); + return grammarErrorOnNode(name_16, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name); } } } } + function checkGrammarJsxElement(node) { + var seen = {}; + for (var _i = 0, _a = node.attributes; _i < _a.length; _i++) { + var attr = _a[_i]; + if (attr.kind === 236 /* JsxSpreadAttribute */) { + continue; + } + var jsxAttr = attr; + var name_17 = jsxAttr.name; + if (!ts.hasProperty(seen, name_17.text)) { + seen[name_17.text] = true; + } + else { + return grammarErrorOnNode(name_17, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); + } + var initializer = jsxAttr.initializer; + if (initializer && initializer.kind === 237 /* JsxExpression */ && !initializer.expression) { + return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); + } + } + } function checkGrammarForInOrForOfStatement(forInOrOfStatement) { if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 202 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 209 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { if (variableList.declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 190 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 197 /* ForInStatement */ ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = variableList.declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 190 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 197 /* ForInStatement */ ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 190 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 197 /* ForInStatement */ ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -24430,10 +26084,10 @@ var ts; else if (accessor.typeParameters) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 138 /* GetAccessor */ && accessor.parameters.length) { + else if (kind === 142 /* GetAccessor */ && accessor.parameters.length) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 139 /* SetAccessor */) { + else if (kind === 143 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -24445,7 +26099,7 @@ var ts; if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); } - else if (parameter.flags & 499 /* Modifier */) { + else if (parameter.flags & 2035 /* Modifier */) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } else if (parameter.questionToken) { @@ -24458,17 +26112,17 @@ var ts; } } function checkGrammarForNonSymbolComputedProperty(node, message) { - if (node.kind === 129 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { + if (node.kind === 133 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(node.expression)) { return grammarErrorOnNode(node, message); } } function checkGrammarMethod(node) { - if (checkGrammarDisallowedModifiersInBlockOrObjectLiteralExpression(node) || + if (checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) || checkGrammarFunctionLikeDeclaration(node) || checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 157 /* ObjectLiteralExpression */) { + if (node.parent.kind === 162 /* ObjectLiteralExpression */) { if (checkGrammarForInvalidQuestionMark(node, node.questionToken, ts.Diagnostics.A_class_member_cannot_be_declared_optional)) { return true; } @@ -24492,22 +26146,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 === 205 /* InterfaceDeclaration */) { + else if (node.parent.kind === 212 /* InterfaceDeclaration */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol); } - else if (node.parent.kind === 148 /* TypeLiteral */) { + else if (node.parent.kind === 152 /* TypeLiteral */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 189 /* ForStatement */: - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: - case 187 /* DoStatement */: - case 188 /* WhileStatement */: + case 196 /* ForStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: + case 194 /* DoStatement */: + case 195 /* WhileStatement */: return true; - case 197 /* LabeledStatement */: + case 204 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; @@ -24519,11 +26173,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 197 /* LabeledStatement */: + case 204 /* LabeledStatement */: if (node.label && current.label.text === node.label.text) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 192 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 199 /* ContinueStatement */ && !isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -24531,8 +26185,8 @@ var ts; return false; } break; - case 196 /* SwitchStatement */: - if (node.kind === 193 /* BreakStatement */ && !node.label) { + case 203 /* SwitchStatement */: + if (node.kind === 200 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -24547,13 +26201,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 193 /* BreakStatement */ + var message = node.kind === 200 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 193 /* BreakStatement */ + var message = node.kind === 200 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -24565,7 +26219,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 === 154 /* ArrayBindingPattern */ || node.name.kind === 153 /* ObjectBindingPattern */) { + if (node.name.kind === 159 /* ArrayBindingPattern */ || node.name.kind === 158 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -24575,7 +26229,7 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 190 /* ForInStatement */ && node.parent.parent.kind !== 191 /* ForOfStatement */) { + if (node.parent.parent.kind !== 197 /* ForInStatement */ && node.parent.parent.kind !== 198 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { // Error on equals token which immediate precedes the initializer @@ -24602,7 +26256,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 65 /* Identifier */) { + if (name.kind === 66 /* Identifier */) { if (name.text === "let") { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } @@ -24611,7 +26265,7 @@ var ts; var elements = name.elements; for (var _i = 0; _i < elements.length; _i++) { var element = elements[_i]; - if (element.kind !== 178 /* OmittedExpression */) { + if (element.kind !== 184 /* OmittedExpression */) { checkGrammarNameInLetOrConstDeclarations(element.name); } } @@ -24628,15 +26282,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 186 /* IfStatement */: - case 187 /* DoStatement */: - case 188 /* WhileStatement */: - case 195 /* WithStatement */: - case 189 /* ForStatement */: - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: + case 193 /* IfStatement */: + case 194 /* DoStatement */: + case 195 /* WhileStatement */: + case 202 /* WithStatement */: + case 196 /* ForStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: return false; - case 197 /* LabeledStatement */: + case 204 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -24652,9 +26306,9 @@ var ts; } } function isIntegerLiteral(expression) { - if (expression.kind === 170 /* PrefixUnaryExpression */) { + if (expression.kind === 176 /* PrefixUnaryExpression */) { var unaryExpression = expression; - if (unaryExpression.operator === 33 /* PlusToken */ || unaryExpression.operator === 34 /* MinusToken */) { + if (unaryExpression.operator === 34 /* PlusToken */ || unaryExpression.operator === 35 /* MinusToken */) { expression = unaryExpression.operand; } } @@ -24669,7 +26323,7 @@ var ts; return false; } function checkGrammarEnumDeclaration(enumDecl) { - var enumIsConst = (enumDecl.flags & 8192 /* Const */) !== 0; + var enumIsConst = (enumDecl.flags & 32768 /* Const */) !== 0; var hasError = false; // skip checks below for const enums - they allow arbitrary initializers as long as they can be evaluated to constant expressions. // since all values are known in compile time - it is not necessary to check that constant enum section precedes computed enum members. @@ -24681,7 +26335,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 129 /* ComputedPropertyName */) { + if (node.name.kind === 133 /* ComputedPropertyName */) { hasError = grammarErrorOnNode(node.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else if (inAmbientContext) { @@ -24723,6 +26377,10 @@ var ts; return true; } } + function isEvalOrArgumentsIdentifier(node) { + return node.kind === 66 /* Identifier */ && + (node.text === "eval" || node.text === "arguments"); + } function checkGrammarConstructorTypeParameters(node) { if (node.typeParameters) { return grammarErrorAtPos(ts.getSourceFileOfNode(node), node.typeParameters.pos, node.typeParameters.end - node.typeParameters.pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); @@ -24740,12 +26398,12 @@ var ts; return true; } } - else if (node.parent.kind === 205 /* InterfaceDeclaration */) { + else if (node.parent.kind === 212 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } } - else if (node.parent.kind === 148 /* TypeLiteral */) { + else if (node.parent.kind === 152 /* TypeLiteral */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -24765,13 +26423,13 @@ var ts; // export_opt ExternalImportDeclaration // export_opt AmbientDeclaration // - if (node.kind === 205 /* InterfaceDeclaration */ || - node.kind === 212 /* ImportDeclaration */ || - node.kind === 211 /* ImportEqualsDeclaration */ || - node.kind === 218 /* ExportDeclaration */ || - node.kind === 217 /* ExportAssignment */ || + if (node.kind === 212 /* InterfaceDeclaration */ || + node.kind === 219 /* ImportDeclaration */ || + node.kind === 218 /* ImportEqualsDeclaration */ || + node.kind === 225 /* ExportDeclaration */ || + node.kind === 224 /* ExportAssignment */ || (node.flags & 2 /* Ambient */) || - (node.flags & (1 /* Export */ | 256 /* Default */))) { + (node.flags & (1 /* Export */ | 1024 /* Default */))) { return false; } return grammarErrorOnFirstToken(node, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); @@ -24779,7 +26437,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 === 183 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 190 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -24805,7 +26463,7 @@ var ts; // to prevent noisyness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 182 /* Block */ || node.parent.kind === 209 /* ModuleBlock */ || node.parent.kind === 230 /* SourceFile */) { + if (node.parent.kind === 189 /* Block */ || node.parent.kind === 216 /* ModuleBlock */ || node.parent.kind === 245 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -24818,7 +26476,7 @@ var ts; } function checkGrammarNumericLiteral(node) { // Grammar checking - if (node.flags & 16384 /* OctalLiteral */ && languageVersion >= 1 /* ES5 */) { + if (node.flags & 65536 /* OctalLiteral */ && languageVersion >= 1 /* ES5 */) { return grammarErrorOnNode(node, ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher); } } @@ -24847,7 +26505,6 @@ var ts; function emitDeclarations(host, resolver, diagnostics, jsFilePath, root) { var newLine = host.getNewLine(); var compilerOptions = host.getCompilerOptions(); - var languageVersion = compilerOptions.target || 0 /* ES3 */; var write; var writeLine; var increaseIndent; @@ -24872,7 +26529,7 @@ var ts; ts.forEach(root.referencedFiles, function (fileReference) { var referencedFile = ts.tryResolveScriptReference(host, root, fileReference); // All the references that are not going to be part of same file - if (referencedFile && ((referencedFile.flags & 2048 /* DeclarationFile */) || + if (referencedFile && ((referencedFile.flags & 8192 /* DeclarationFile */) || ts.shouldEmitToOwnFile(referencedFile, compilerOptions) || !addedGlobalFileReference)) { writeReferencePath(referencedFile); @@ -24888,7 +26545,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible) { - ts.Debug.assert(aliasEmitInfo.node.kind === 212 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 219 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0); writeImportDeclaration(aliasEmitInfo.node); @@ -24964,10 +26621,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 201 /* VariableDeclaration */) { + if (declaration.kind === 208 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 215 /* NamedImports */ || declaration.kind === 216 /* ImportSpecifier */ || declaration.kind === 213 /* ImportClause */) { + else if (declaration.kind === 222 /* NamedImports */ || declaration.kind === 223 /* ImportSpecifier */ || declaration.kind === 220 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -24985,8 +26642,8 @@ var ts; // Writing of function bar would mark alias declaration foo as visible but we haven't yet visited that declaration so do nothing, // we would write alias foo declaration when we visit it since it would now be marked as visible if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 212 /* ImportDeclaration */) { - // we have to create asynchronous output only after we have collected complete information + if (moduleElementEmitInfo.node.kind === 219 /* ImportDeclaration */) { + // we have to create asynchronous output only after we have collected complete information // because it is possible to enable multiple bindings as asynchronously visible moduleElementEmitInfo.isVisible = true; } @@ -24995,12 +26652,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 208 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 215 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 208 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 215 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -25092,60 +26749,64 @@ var ts; } function emitType(type) { switch (type.kind) { - case 112 /* AnyKeyword */: - case 123 /* StringKeyword */: - case 121 /* NumberKeyword */: - case 113 /* BooleanKeyword */: - case 124 /* SymbolKeyword */: - case 99 /* VoidKeyword */: + case 114 /* AnyKeyword */: + case 127 /* StringKeyword */: + case 125 /* NumberKeyword */: + case 117 /* BooleanKeyword */: + case 128 /* SymbolKeyword */: + case 100 /* VoidKeyword */: case 8 /* StringLiteral */: return writeTextOfNode(currentSourceFile, type); - case 179 /* ExpressionWithTypeArguments */: + case 185 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(type); - case 144 /* TypeReference */: + case 148 /* TypeReference */: return emitTypeReference(type); - case 147 /* TypeQuery */: + case 151 /* TypeQuery */: return emitTypeQuery(type); - case 149 /* ArrayType */: + case 153 /* ArrayType */: return emitArrayType(type); - case 150 /* TupleType */: + case 154 /* TupleType */: return emitTupleType(type); - case 151 /* UnionType */: + case 155 /* UnionType */: return emitUnionType(type); - case 152 /* ParenthesizedType */: + case 156 /* IntersectionType */: + return emitIntersectionType(type); + case 157 /* ParenthesizedType */: return emitParenType(type); - case 145 /* FunctionType */: - case 146 /* ConstructorType */: + case 149 /* FunctionType */: + case 150 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 148 /* TypeLiteral */: + case 152 /* TypeLiteral */: return emitTypeLiteral(type); - case 65 /* Identifier */: + case 66 /* Identifier */: return emitEntityName(type); - case 128 /* QualifiedName */: + case 132 /* QualifiedName */: return emitEntityName(type); + case 147 /* TypePredicate */: + return emitTypePredicate(type); + } + function writeEntityName(entityName) { + if (entityName.kind === 66 /* Identifier */) { + writeTextOfNode(currentSourceFile, entityName); + } + else { + var left = entityName.kind === 132 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 132 /* QualifiedName */ ? entityName.right : entityName.name; + writeEntityName(left); + write("."); + writeTextOfNode(currentSourceFile, right); + } } function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 211 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 218 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); writeEntityName(entityName); - function writeEntityName(entityName) { - if (entityName.kind === 65 /* Identifier */) { - writeTextOfNode(currentSourceFile, entityName); - } - else { - var left = entityName.kind === 128 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 128 /* QualifiedName */ ? entityName.right : entityName.name; - writeEntityName(left); - write("."); - writeTextOfNode(currentSourceFile, right); - } - } } function emitExpressionWithTypeArguments(node) { if (ts.isSupportedExpressionWithTypeArguments(node)) { - ts.Debug.assert(node.expression.kind === 65 /* Identifier */ || node.expression.kind === 158 /* PropertyAccessExpression */); + ts.Debug.assert(node.expression.kind === 66 /* Identifier */ || node.expression.kind === 163 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -25162,6 +26823,11 @@ var ts; write(">"); } } + function emitTypePredicate(type) { + writeTextOfNode(currentSourceFile, type.parameterName); + write(" is "); + emitType(type.type); + } function emitTypeQuery(type) { write("typeof "); emitEntityName(type.exprName); @@ -25178,6 +26844,9 @@ var ts; function emitUnionType(type) { emitSeparatedList(type.types, " | ", emitType); } + function emitIntersectionType(type) { + emitSeparatedList(type.types, " & ", emitType); + } function emitParenType(type) { write("("); emitType(type.type); @@ -25211,14 +26880,14 @@ var ts; } var count = 0; while (true) { - var name_16 = baseName + "_" + (++count); - if (!ts.hasProperty(currentSourceFile.identifiers, name_16)) { - return name_16; + var name_18 = baseName + "_" + (++count); + if (!ts.hasProperty(currentSourceFile.identifiers, name_18)) { + return name_18; } } } function emitExportAssignment(node) { - if (node.expression.kind === 65 /* Identifier */) { + if (node.expression.kind === 66 /* Identifier */) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentSourceFile, node.expression); } @@ -25238,7 +26907,7 @@ var ts; write(";"); writeLine(); // Make all the declarations visible for the export name - if (node.expression.kind === 65 /* Identifier */) { + if (node.expression.kind === 66 /* Identifier */) { var nodes = resolver.collectLinkedAliases(node.expression); // write each of these declarations asynchronously writeAsynchronousModuleElements(nodes); @@ -25257,10 +26926,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 211 /* ImportEqualsDeclaration */ || - (node.parent.kind === 230 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { + else if (node.kind === 218 /* ImportEqualsDeclaration */ || + (node.parent.kind === 245 /* SourceFile */ && ts.isExternalModule(currentSourceFile))) { var isVisible; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 230 /* SourceFile */) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 245 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -25270,7 +26939,7 @@ var ts; }); } else { - if (node.kind === 212 /* ImportDeclaration */) { + if (node.kind === 219 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -25288,23 +26957,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 203 /* FunctionDeclaration */: + case 210 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 183 /* VariableStatement */: + case 190 /* VariableStatement */: return writeVariableStatement(node); - case 205 /* InterfaceDeclaration */: + case 212 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 204 /* ClassDeclaration */: + case 211 /* ClassDeclaration */: return writeClassDeclaration(node); - case 206 /* TypeAliasDeclaration */: + case 213 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 207 /* EnumDeclaration */: + case 214 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 211 /* ImportEqualsDeclaration */: + case 218 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 212 /* ImportDeclaration */: + case 219 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -25317,10 +26986,10 @@ var ts; if (node.flags & 1 /* Export */) { write("export "); } - if (node.flags & 256 /* Default */) { + if (node.flags & 1024 /* Default */) { write("default "); } - else if (node.kind !== 205 /* InterfaceDeclaration */) { + else if (node.kind !== 212 /* InterfaceDeclaration */) { write("declare "); } } @@ -25335,9 +27004,12 @@ var ts; if (node.flags & 128 /* Static */) { write("static "); } + if (node.flags & 256 /* Abstract */) { + write("abstract "); + } } function writeImportEqualsDeclaration(node) { - // note usage of writer. methods instead of aliases created, just to make sure we are using + // note usage of writer. methods instead of aliases created, just to make sure we are using // correct writer especially to handle asynchronous alias writing emitJsDocComments(node); if (node.flags & 1 /* Export */) { @@ -25366,7 +27038,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 214 /* NamespaceImport */) { + if (namedBindings.kind === 221 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -25376,7 +27048,7 @@ var ts; } function writeImportDeclaration(node) { if (!node.importClause && !(node.flags & 1 /* Export */)) { - // do not write non-exported import declarations that don't have import clauses + // do not write non-exported import declarations that don't have import clauses return; } emitJsDocComments(node); @@ -25394,7 +27066,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 214 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 221 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentSourceFile, node.importClause.namedBindings.name); } @@ -25445,14 +27117,14 @@ var ts; function writeModuleDeclaration(node) { emitJsDocComments(node); emitModuleElementDeclarationFlags(node); - if (node.flags & 32768 /* Namespace */) { + if (node.flags & 131072 /* Namespace */) { write("namespace "); } else { write("module "); } writeTextOfNode(currentSourceFile, node.name); - while (node.body.kind !== 209 /* ModuleBlock */) { + while (node.body.kind !== 216 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentSourceFile, node.name); @@ -25513,7 +27185,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 136 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); + return node.parent.kind === 140 /* MethodDeclaration */ && (node.parent.flags & 32 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -25524,15 +27196,15 @@ var ts; // If there is constraint present and this is not a type parameter of the private method emit the constraint if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 145 /* FunctionType */ || - node.parent.kind === 146 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 148 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 136 /* MethodDeclaration */ || - node.parent.kind === 135 /* MethodSignature */ || - node.parent.kind === 145 /* FunctionType */ || - node.parent.kind === 146 /* ConstructorType */ || - node.parent.kind === 140 /* CallSignature */ || - node.parent.kind === 141 /* ConstructSignature */); + if (node.parent.kind === 149 /* FunctionType */ || + node.parent.kind === 150 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 152 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 140 /* MethodDeclaration */ || + node.parent.kind === 139 /* MethodSignature */ || + node.parent.kind === 149 /* FunctionType */ || + node.parent.kind === 150 /* ConstructorType */ || + node.parent.kind === 144 /* CallSignature */ || + node.parent.kind === 145 /* ConstructSignature */); emitType(node.constraint); } else { @@ -25543,31 +27215,31 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 204 /* ClassDeclaration */: + case 211 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 205 /* InterfaceDeclaration */: + case 212 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 141 /* ConstructSignature */: + case 145 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 140 /* CallSignature */: + case 144 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 204 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 211 /* ClassDeclaration */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 203 /* FunctionDeclaration */: + case 210 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: @@ -25598,7 +27270,7 @@ var ts; function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 204 /* ClassDeclaration */) { + if (node.parent.parent.kind === 211 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : @@ -25628,6 +27300,9 @@ var ts; } emitJsDocComments(node); emitModuleElementDeclarationFlags(node); + if (node.flags & 256 /* Abstract */) { + write("abstract "); + } write("class "); writeTextOfNode(currentSourceFile, node.name); var prevEnclosingDeclaration = enclosingDeclaration; @@ -25679,7 +27354,7 @@ var ts; function emitVariableDeclaration(node) { // If we are emitting property it isn't moduleElement and hence we already know it needs to be emitted // so there is no check needed to see if declaration is visible - if (node.kind !== 201 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 208 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -25689,10 +27364,10 @@ var ts; // what we want, namely the name expression enclosed in brackets. writeTextOfNode(currentSourceFile, node.name); // If optional property emit ? - if ((node.kind === 134 /* PropertyDeclaration */ || node.kind === 133 /* PropertySignature */) && ts.hasQuestionToken(node)) { + if ((node.kind === 138 /* PropertyDeclaration */ || node.kind === 137 /* PropertySignature */) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 134 /* PropertyDeclaration */ || node.kind === 133 /* PropertySignature */) && node.parent.kind === 148 /* TypeLiteral */) { + if ((node.kind === 138 /* PropertyDeclaration */ || node.kind === 137 /* PropertySignature */) && node.parent.kind === 152 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.flags & 32 /* Private */)) { @@ -25701,14 +27376,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { - if (node.kind === 201 /* VariableDeclaration */) { + if (node.kind === 208 /* VariableDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 134 /* PropertyDeclaration */ || node.kind === 133 /* PropertySignature */) { + else if (node.kind === 138 /* PropertyDeclaration */ || node.kind === 137 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. if (node.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? @@ -25717,7 +27392,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 === 204 /* ClassDeclaration */) { + else if (node.parent.kind === 211 /* ClassDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -25749,7 +27424,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 178 /* OmittedExpression */) { + if (element.kind !== 184 /* OmittedExpression */) { elements.push(element); } } @@ -25819,7 +27494,7 @@ var ts; var type = getTypeAnnotationFromAccessor(node); if (!type) { // couldn't get type for the first accessor, try the another one - var anotherAccessor = node.kind === 138 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 142 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -25832,7 +27507,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 138 /* GetAccessor */ + return accessor.kind === 142 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -25841,7 +27516,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 139 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 143 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named if (accessorWithTypeAnnotation.parent.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? @@ -25891,17 +27566,17 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 203 /* FunctionDeclaration */) { + if (node.kind === 210 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 136 /* MethodDeclaration */) { + else if (node.kind === 140 /* MethodDeclaration */) { emitClassMemberDeclarationFlags(node); } - if (node.kind === 203 /* FunctionDeclaration */) { + if (node.kind === 210 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentSourceFile, node.name); } - else if (node.kind === 137 /* Constructor */) { + else if (node.kind === 141 /* Constructor */) { write("constructor"); } else { @@ -25919,11 +27594,11 @@ var ts; } function emitSignatureDeclaration(node) { // Construct signature or constructor type write new Signature - if (node.kind === 141 /* ConstructSignature */ || node.kind === 146 /* ConstructorType */) { + if (node.kind === 145 /* ConstructSignature */ || node.kind === 150 /* ConstructorType */) { write("new "); } emitTypeParameters(node.typeParameters); - if (node.kind === 142 /* IndexSignature */) { + if (node.kind === 146 /* IndexSignature */) { write("["); } else { @@ -25933,22 +27608,22 @@ var ts; enclosingDeclaration = node; // Parameters emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 142 /* IndexSignature */) { + if (node.kind === 146 /* IndexSignature */) { write("]"); } else { write(")"); } // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 145 /* FunctionType */ || node.kind === 146 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 148 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 149 /* FunctionType */ || node.kind === 150 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 152 /* TypeLiteral */) { // Emit type literal signature return type only if specified if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 137 /* Constructor */ && !(node.flags & 32 /* Private */)) { + else if (node.kind !== 141 /* Constructor */ && !(node.flags & 32 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -25959,26 +27634,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 141 /* ConstructSignature */: + case 145 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 140 /* CallSignature */: + case 144 /* CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 142 /* IndexSignature */: + case 146 /* IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: if (node.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -25986,7 +27661,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 === 204 /* ClassDeclaration */) { + else if (node.parent.kind === 211 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -26000,7 +27675,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 203 /* FunctionDeclaration */: + case 210 /* FunctionDeclaration */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -26035,9 +27710,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 145 /* FunctionType */ || - node.parent.kind === 146 /* ConstructorType */ || - node.parent.parent.kind === 148 /* TypeLiteral */) { + if (node.parent.kind === 149 /* FunctionType */ || + node.parent.kind === 150 /* ConstructorType */ || + node.parent.parent.kind === 152 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!(node.parent.flags & 32 /* Private */)) { @@ -26053,24 +27728,24 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccesibilityResult) { switch (node.parent.kind) { - case 137 /* Constructor */: + case 141 /* Constructor */: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 141 /* ConstructSignature */: + case 145 /* ConstructSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 140 /* CallSignature */: + case 144 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: if (node.parent.flags & 128 /* Static */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -26078,7 +27753,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 === 204 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 211 /* ClassDeclaration */) { return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -26091,7 +27766,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 203 /* FunctionDeclaration */: + case 210 /* FunctionDeclaration */: return symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -26103,12 +27778,12 @@ var ts; } function emitBindingPattern(bindingPattern) { // We have to explicitly emit square bracket and bracket because these tokens are not store inside the node. - if (bindingPattern.kind === 153 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 158 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 154 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 159 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -26127,7 +27802,7 @@ var ts; typeName: bindingElement.name } : undefined; } - if (bindingElement.kind === 178 /* OmittedExpression */) { + if (bindingElement.kind === 184 /* OmittedExpression */) { // If bindingElement is an omittedExpression (i.e. containing elision), // we will emit blank space (although this may differ from users' original code, // it allows emitSeparatedList to write separator appropriately) @@ -26136,7 +27811,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 155 /* BindingElement */) { + else if (bindingElement.kind === 160 /* BindingElement */) { if (bindingElement.propertyName) { // bindingElement has propertyName property in the following case: // { y: [a,b,c] ...} -> bindingPattern will have a property called propertyName for "y" @@ -26161,7 +27836,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 65 /* Identifier */); + ts.Debug.assert(bindingElement.name.kind === 66 /* Identifier */); // If the node is just an identifier, we will simply emit the text associated with the node's name // Example: // original: function foo({y = 10, x}) {} @@ -26177,45 +27852,45 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 203 /* FunctionDeclaration */: - case 208 /* ModuleDeclaration */: - case 211 /* ImportEqualsDeclaration */: - case 205 /* InterfaceDeclaration */: - case 204 /* ClassDeclaration */: - case 206 /* TypeAliasDeclaration */: - case 207 /* EnumDeclaration */: + case 210 /* FunctionDeclaration */: + case 215 /* ModuleDeclaration */: + case 218 /* ImportEqualsDeclaration */: + case 212 /* InterfaceDeclaration */: + case 211 /* ClassDeclaration */: + case 213 /* TypeAliasDeclaration */: + case 214 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 183 /* VariableStatement */: + case 190 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 212 /* ImportDeclaration */: + case 219 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible return emitModuleElement(node, !node.importClause); - case 218 /* ExportDeclaration */: + case 225 /* ExportDeclaration */: return emitExportDeclaration(node); - case 137 /* Constructor */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 141 /* Constructor */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: return writeFunctionDeclaration(node); - case 141 /* ConstructSignature */: - case 140 /* CallSignature */: - case 142 /* IndexSignature */: + case 145 /* ConstructSignature */: + case 144 /* CallSignature */: + case 146 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: return emitAccessorDeclaration(node); - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: return emitPropertyDeclaration(node); - case 229 /* EnumMember */: + case 244 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 217 /* ExportAssignment */: + case 224 /* ExportAssignment */: return emitExportAssignment(node); - case 230 /* SourceFile */: + case 245 /* SourceFile */: return emitSourceFile(node); } } function writeReferencePath(referencedFile) { - var declFileName = referencedFile.flags & 2048 /* DeclarationFile */ + var declFileName = referencedFile.flags & 8192 /* DeclarationFile */ ? referencedFile.fileName // Declaration file, use declaration file name : ts.shouldEmitToOwnFile(referencedFile, compilerOptions) ? ts.getOwnEmitOutputFilePath(referencedFile, host, ".d.ts") // Own output file so get the .d.ts file @@ -26278,15 +27953,18 @@ var ts; 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};"; // emit output for the __param helper function 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 /* ES3 */; var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; var diagnostics = []; var newLine = host.getNewLine(); + var jsxDesugaring = host.getCompilerOptions().jsx !== 1 /* Preserve */; + var shouldEmitJsx = function (s) { return (s.languageVariant === 1 /* JSX */ && !jsxDesugaring); }; if (targetSourceFile === undefined) { ts.forEach(host.getSourceFiles(), function (sourceFile) { if (ts.shouldEmitToOwnFile(sourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, ".js"); + var jsFilePath = ts.getOwnEmitOutputFilePath(sourceFile, host, shouldEmitJsx(sourceFile) ? ".jsx" : ".js"); emitFile(jsFilePath, sourceFile); } }); @@ -26297,7 +27975,7 @@ var ts; else { // targetSourceFile is specified (e.g calling emitter from language service or calling getSemanticDiagnostic from language service) if (ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions)) { - var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ".js"); + var jsFilePath = ts.getOwnEmitOutputFilePath(targetSourceFile, host, ts.forEach(host.getSourceFiles(), shouldEmitJsx) ? ".jsx" : ".js"); emitFile(jsFilePath, targetSourceFile); } else if (!ts.isDeclarationFile(targetSourceFile) && compilerOptions.out) { @@ -26351,6 +28029,7 @@ var ts; var extendsEmitted = false; var decorateEmitted = false; var paramEmitted = false; + var awaiterEmitted = false; var tempFlags = 0; var tempVariables; var tempParameters; @@ -26415,10 +28094,10 @@ var ts; // Note that names generated by makeTempVariableName and makeUniqueName will never conflict. function makeTempVariableName(flags) { if (flags && !(tempFlags & flags)) { - var name = flags === 268435456 /* _i */ ? "_i" : "_n"; - if (isUniqueName(name)) { + var name_19 = flags === 268435456 /* _i */ ? "_i" : "_n"; + if (isUniqueName(name_19)) { tempFlags |= flags; - return name; + return name_19; } } while (true) { @@ -26426,9 +28105,9 @@ var ts; tempFlags++; // Skip over 'i' and 'n' if (count !== 8 && count !== 13) { - var name_17 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); - if (isUniqueName(name_17)) { - return name_17; + var name_20 = count < 26 ? "_" + String.fromCharCode(97 /* a */ + count) : "_" + (count - 26); + if (isUniqueName(name_20)) { + return name_20; } } } @@ -26470,19 +28149,19 @@ var ts; } function generateNameForNode(node) { switch (node.kind) { - case 65 /* Identifier */: + case 66 /* Identifier */: return makeUniqueName(node.text); - case 208 /* ModuleDeclaration */: - case 207 /* EnumDeclaration */: + case 215 /* ModuleDeclaration */: + case 214 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 212 /* ImportDeclaration */: - case 218 /* ExportDeclaration */: + case 219 /* ImportDeclaration */: + case 225 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 203 /* FunctionDeclaration */: - case 204 /* ClassDeclaration */: - case 217 /* ExportAssignment */: + case 210 /* FunctionDeclaration */: + case 211 /* ClassDeclaration */: + case 224 /* ExportAssignment */: return generateNameForExportDefault(); - case 177 /* ClassExpression */: + case 183 /* ClassExpression */: return generateNameForClassExpression(); } } @@ -26653,8 +28332,8 @@ var ts; // Child scopes are always shown with a dot (even if they have no name), // unless it is a computed property. Then it is shown with brackets, // but the brackets are included in the name. - var name_18 = node.name; - if (!name_18 || name_18.kind !== 129 /* ComputedPropertyName */) { + var name_21 = node.name; + if (!name_21 || name_21.kind !== 133 /* ComputedPropertyName */) { scopeName = "." + scopeName; } scopeName = sourceMapData.sourceMapNames[parentIndex] + scopeName; @@ -26672,21 +28351,21 @@ var ts; // The scope was already given a name use it recordScopeNameStart(scopeName); } - else if (node.kind === 203 /* FunctionDeclaration */ || - node.kind === 165 /* FunctionExpression */ || - node.kind === 136 /* MethodDeclaration */ || - node.kind === 135 /* MethodSignature */ || - node.kind === 138 /* GetAccessor */ || - node.kind === 139 /* SetAccessor */ || - node.kind === 208 /* ModuleDeclaration */ || - node.kind === 204 /* ClassDeclaration */ || - node.kind === 207 /* EnumDeclaration */) { + else if (node.kind === 210 /* FunctionDeclaration */ || + node.kind === 170 /* FunctionExpression */ || + node.kind === 140 /* MethodDeclaration */ || + node.kind === 139 /* MethodSignature */ || + node.kind === 142 /* GetAccessor */ || + node.kind === 143 /* SetAccessor */ || + node.kind === 215 /* ModuleDeclaration */ || + node.kind === 211 /* ClassDeclaration */ || + node.kind === 214 /* EnumDeclaration */) { // Declaration and has associated name use it if (node.name) { - var name_19 = node.name; + var name_22 = node.name; // For computed property names, the text will include the brackets - scopeName = name_19.kind === 129 /* ComputedPropertyName */ - ? ts.getTextOfNode(name_19) + scopeName = name_22.kind === 133 /* ComputedPropertyName */ + ? ts.getTextOfNode(name_22) : node.name.text; } recordScopeNameStart(scopeName); @@ -26795,7 +28474,7 @@ var ts; if (ts.nodeIsSynthesized(node)) { return emitNodeWithoutSourceMap(node); } - if (node.kind !== 230 /* SourceFile */) { + if (node.kind !== 245 /* SourceFile */) { recordEmitNodeStartSpan(node); emitNodeWithoutSourceMap(node); recordEmitNodeEndSpan(node); @@ -26820,7 +28499,7 @@ var ts; } // Create a temporary variable with a unique unused name. function createTempVariable(flags) { - var result = ts.createSynthesizedNode(65 /* Identifier */); + var result = ts.createSynthesizedNode(66 /* Identifier */); result.text = makeTempVariableName(flags); return result; } @@ -27058,10 +28737,10 @@ var ts; write("("); emit(tempVariable); // Now we emit the expressions - if (node.template.kind === 174 /* TemplateExpression */) { + if (node.template.kind === 180 /* TemplateExpression */) { ts.forEach(node.template.templateSpans, function (templateSpan) { write(", "); - var needsParens = templateSpan.expression.kind === 172 /* BinaryExpression */ + var needsParens = templateSpan.expression.kind === 178 /* BinaryExpression */ && templateSpan.expression.operatorToken.kind === 23 /* CommaToken */; emitParenthesizedIf(templateSpan.expression, needsParens); }); @@ -27096,7 +28775,7 @@ var ts; // ("abc" + 1) << (2 + "") // rather than // "abc" + (1 << 2) + "" - var needsParens = templateSpan.expression.kind !== 164 /* ParenthesizedExpression */ + var needsParens = templateSpan.expression.kind !== 169 /* ParenthesizedExpression */ && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; if (i > 0 || headEmitted) { // If this is the first span and the head was not emitted, then this templateSpan's @@ -27138,11 +28817,11 @@ var ts; } function templateNeedsParens(template, parent) { switch (parent.kind) { - case 160 /* CallExpression */: - case 161 /* NewExpression */: + case 165 /* CallExpression */: + case 166 /* NewExpression */: return parent.expression === template; - case 162 /* TaggedTemplateExpression */: - case 164 /* ParenthesizedExpression */: + case 167 /* TaggedTemplateExpression */: + case 169 /* ParenthesizedExpression */: return false; default: return comparePrecedenceToBinaryPlus(parent) !== -1 /* LessThan */; @@ -27163,20 +28842,20 @@ var ts; // TODO (drosen): Note that we need to account for the upcoming 'yield' and // spread ('...') unary operators that are anticipated for ES6. switch (expression.kind) { - case 172 /* BinaryExpression */: + case 178 /* BinaryExpression */: switch (expression.operatorToken.kind) { - case 35 /* AsteriskToken */: - case 36 /* SlashToken */: - case 37 /* PercentToken */: + case 36 /* AsteriskToken */: + case 37 /* SlashToken */: + case 38 /* PercentToken */: return 1 /* GreaterThan */; - case 33 /* PlusToken */: - case 34 /* MinusToken */: + case 34 /* PlusToken */: + case 35 /* MinusToken */: return 0 /* EqualTo */; default: return -1 /* LessThan */; } - case 175 /* YieldExpression */: - case 173 /* ConditionalExpression */: + case 181 /* YieldExpression */: + case 179 /* ConditionalExpression */: return -1 /* LessThan */; default: return 1 /* GreaterThan */; @@ -27187,17 +28866,211 @@ var ts; emit(span.expression); emit(span.literal); } + function jsxEmitReact(node) { + /// Emit a tag name, which is either '"div"' for lower-cased names, or + /// 'Div' for upper-cased or dotted names + function emitTagName(name) { + if (name.kind === 66 /* Identifier */ && ts.isIntrinsicJsxName(name.text)) { + write('"'); + emit(name); + write('"'); + } + else { + emit(name); + } + } + /// Emit an attribute name, which is quoted if it needs to be quoted. Because + /// these emit into an object literal property name, we don't need to be worried + /// about keywords, just non-identifier characters + function emitAttributeName(name) { + if (/[A-Za-z_]+[\w*]/.test(name.text)) { + write('"'); + emit(name); + write('"'); + } + else { + emit(name); + } + } + /// Emit an name/value pair for an attribute (e.g. "x: 3") + function emitJsxAttribute(node) { + emitAttributeName(node.name); + write(": "); + if (node.initializer) { + emit(node.initializer); + } + else { + write("true"); + } + } + function emitJsxElement(openingNode, children) { + // Call React.createElement(tag, ... + emitLeadingComments(openingNode); + write("React.createElement("); + emitTagName(openingNode.tagName); + write(", "); + // Attribute list + if (openingNode.attributes.length === 0) { + // When there are no attributes, React wants "null" + write("null"); + } + else { + // Either emit one big object literal (no spread attribs), or + // a call to React.__spread + var attrs = openingNode.attributes; + if (ts.forEach(attrs, function (attr) { return attr.kind === 236 /* JsxSpreadAttribute */; })) { + write("React.__spread("); + var haveOpenedObjectLiteral = false; + for (var i_2 = 0; i_2 < attrs.length; i_2++) { + if (attrs[i_2].kind === 236 /* JsxSpreadAttribute */) { + // If this is the first argument, we need to emit a {} as the first argument + if (i_2 === 0) { + write("{}, "); + } + if (haveOpenedObjectLiteral) { + write("}"); + haveOpenedObjectLiteral = false; + } + if (i_2 > 0) { + write(", "); + } + emit(attrs[i_2].expression); + } + else { + ts.Debug.assert(attrs[i_2].kind === 235 /* JsxAttribute */); + if (haveOpenedObjectLiteral) { + write(", "); + } + else { + haveOpenedObjectLiteral = true; + if (i_2 > 0) { + write(", "); + } + write("{"); + } + emitJsxAttribute(attrs[i_2]); + } + } + if (haveOpenedObjectLiteral) + write("}"); + write(")"); // closing paren to React.__spread( + } + else { + // One object literal with all the attributes in them + write("{"); + for (var i = 0; i < attrs.length; i++) { + if (i > 0) { + write(", "); + } + emitJsxAttribute(attrs[i]); + } + write("}"); + } + } + // Children + if (children) { + for (var i = 0; i < children.length; i++) { + // Don't emit empty expressions + if (children[i].kind === 237 /* JsxExpression */ && !(children[i].expression)) { + continue; + } + // Don't emit empty strings + if (children[i].kind === 233 /* JsxText */) { + var text = getTextToEmit(children[i]); + if (text !== undefined) { + write(', "'); + write(text); + write('"'); + } + } + else { + write(", "); + emit(children[i]); + } + } + } + // Closing paren + write(")"); // closes "React.createElement(" + emitTrailingComments(openingNode); + } + if (node.kind === 230 /* JsxElement */) { + emitJsxElement(node.openingElement, node.children); + } + else { + ts.Debug.assert(node.kind === 231 /* JsxSelfClosingElement */); + emitJsxElement(node); + } + } + function jsxEmitPreserve(node) { + function emitJsxAttribute(node) { + emit(node.name); + 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 === 236 /* JsxSpreadAttribute */) { + emitJsxSpreadAttribute(attribs[i]); + } + else { + ts.Debug.assert(attribs[i].kind === 235 /* JsxAttribute */); + emitJsxAttribute(attribs[i]); + } + } + } + function emitJsxOpeningOrSelfClosingElement(node) { + write("<"); + emit(node.tagName); + if (node.attributes.length > 0 || (node.kind === 231 /* JsxSelfClosingElement */)) { + write(" "); + } + emitAttributes(node.attributes); + if (node.kind === 231 /* JsxSelfClosingElement */) { + 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 === 230 /* JsxElement */) { + emitJsxElement(node); + } + else { + ts.Debug.assert(node.kind === 231 /* JsxSelfClosingElement */); + emitJsxOpeningOrSelfClosingElement(node); + } + } // This function specifically handles numeric/string literals for enum and accessor 'identifiers'. // In a sense, it does not actually emit identifiers as much as it declares a name for a specific property. // For example, this is utilized when feeding in a result to Object.defineProperty. function emitExpressionForPropertyName(node) { - ts.Debug.assert(node.kind !== 155 /* BindingElement */); + ts.Debug.assert(node.kind !== 160 /* BindingElement */); if (node.kind === 8 /* StringLiteral */) { emitLiteral(node); } - else if (node.kind === 129 /* ComputedPropertyName */) { + else if (node.kind === 133 /* ComputedPropertyName */) { // if this is a decorated computed property, we will need to capture the result - // of the property expression so that we can apply decorators later. This is to ensure + // of the property expression so that we can apply decorators later. This is to ensure // we don't introduce unintended side effects: // // class C { @@ -27239,64 +29112,70 @@ var ts; function isExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 156 /* ArrayLiteralExpression */: - case 172 /* BinaryExpression */: - case 160 /* CallExpression */: - case 223 /* CaseClause */: - case 129 /* ComputedPropertyName */: - case 173 /* ConditionalExpression */: - case 132 /* Decorator */: - case 167 /* DeleteExpression */: - case 187 /* DoStatement */: - case 159 /* ElementAccessExpression */: - case 217 /* ExportAssignment */: - case 185 /* ExpressionStatement */: - case 179 /* ExpressionWithTypeArguments */: - case 189 /* ForStatement */: - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: - case 186 /* IfStatement */: - case 161 /* NewExpression */: - case 164 /* ParenthesizedExpression */: - case 171 /* PostfixUnaryExpression */: - case 170 /* PrefixUnaryExpression */: - case 194 /* ReturnStatement */: - case 228 /* ShorthandPropertyAssignment */: - case 176 /* SpreadElementExpression */: - case 196 /* SwitchStatement */: - case 162 /* TaggedTemplateExpression */: - case 180 /* TemplateSpan */: - case 198 /* ThrowStatement */: - case 163 /* TypeAssertionExpression */: - case 168 /* TypeOfExpression */: - case 169 /* VoidExpression */: - case 188 /* WhileStatement */: - case 195 /* WithStatement */: - case 175 /* YieldExpression */: + case 161 /* ArrayLiteralExpression */: + case 178 /* BinaryExpression */: + case 165 /* CallExpression */: + case 238 /* CaseClause */: + case 133 /* ComputedPropertyName */: + case 179 /* ConditionalExpression */: + case 136 /* Decorator */: + case 172 /* DeleteExpression */: + case 194 /* DoStatement */: + case 164 /* ElementAccessExpression */: + case 224 /* ExportAssignment */: + case 192 /* ExpressionStatement */: + case 185 /* ExpressionWithTypeArguments */: + case 196 /* ForStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: + case 193 /* IfStatement */: + case 231 /* JsxSelfClosingElement */: + case 232 /* JsxOpeningElement */: + case 166 /* NewExpression */: + case 169 /* ParenthesizedExpression */: + case 177 /* PostfixUnaryExpression */: + case 176 /* PrefixUnaryExpression */: + case 201 /* ReturnStatement */: + case 243 /* ShorthandPropertyAssignment */: + case 182 /* SpreadElementExpression */: + case 203 /* SwitchStatement */: + case 167 /* TaggedTemplateExpression */: + case 187 /* TemplateSpan */: + case 205 /* ThrowStatement */: + case 168 /* TypeAssertionExpression */: + case 173 /* TypeOfExpression */: + case 174 /* VoidExpression */: + case 195 /* WhileStatement */: + case 202 /* WithStatement */: + case 181 /* YieldExpression */: return true; - case 155 /* BindingElement */: - case 229 /* EnumMember */: - case 131 /* Parameter */: - case 227 /* PropertyAssignment */: - case 134 /* PropertyDeclaration */: - case 201 /* VariableDeclaration */: + case 160 /* BindingElement */: + case 244 /* EnumMember */: + case 135 /* Parameter */: + case 242 /* PropertyAssignment */: + case 138 /* PropertyDeclaration */: + case 208 /* VariableDeclaration */: return parent.initializer === node; - case 158 /* PropertyAccessExpression */: + case 163 /* PropertyAccessExpression */: return parent.expression === node; - case 166 /* ArrowFunction */: - case 165 /* FunctionExpression */: + case 171 /* ArrowFunction */: + case 170 /* FunctionExpression */: return parent.body === node; - case 211 /* ImportEqualsDeclaration */: + case 218 /* ImportEqualsDeclaration */: return parent.moduleReference === node; - case 128 /* QualifiedName */: + case 132 /* QualifiedName */: return parent.left === node; } return false; } function emitExpressionIdentifier(node) { + if (resolver.getNodeCheckFlags(node) & 2048 /* LexicalArguments */) { + write("_arguments"); + return; + } var container = resolver.getReferencedExportContainer(node); if (container) { - if (container.kind === 230 /* SourceFile */) { + if (container.kind === 245 /* SourceFile */) { // Identifier references module export if (languageVersion < 2 /* ES6 */ && compilerOptions.module !== 4 /* System */) { write("exports."); @@ -27311,13 +29190,13 @@ var ts; else if (languageVersion < 2 /* ES6 */) { var declaration = resolver.getReferencedImportDeclaration(node); if (declaration) { - if (declaration.kind === 213 /* ImportClause */) { + if (declaration.kind === 220 /* ImportClause */) { // Identifier references default import write(getGeneratedNameForNode(declaration.parent)); write(languageVersion === 0 /* ES3 */ ? '["default"]' : ".default"); return; } - else if (declaration.kind === 216 /* ImportSpecifier */) { + else if (declaration.kind === 223 /* ImportSpecifier */) { // Identifier references named import write(getGeneratedNameForNode(declaration.parent.parent.parent)); write("."); @@ -27337,10 +29216,10 @@ var ts; if (languageVersion < 2 /* ES6 */) { var parent_7 = node.parent; switch (parent_7.kind) { - case 155 /* BindingElement */: - case 204 /* ClassDeclaration */: - case 207 /* EnumDeclaration */: - case 201 /* VariableDeclaration */: + case 160 /* BindingElement */: + case 211 /* ClassDeclaration */: + case 214 /* EnumDeclaration */: + case 208 /* VariableDeclaration */: return parent_7.name === node && resolver.isNestedRedeclaration(parent_7); } } @@ -27374,7 +29253,7 @@ var ts; } else { var flags = resolver.getNodeCheckFlags(node); - if (flags & 16 /* SuperInstance */) { + if (flags & 256 /* SuperInstance */) { write("_super.prototype"); } else { @@ -27415,7 +29294,7 @@ var ts; emit(node.expression); } function emitYieldExpression(node) { - write(ts.tokenToString(110 /* YieldKeyword */)); + write(ts.tokenToString(111 /* YieldKeyword */)); if (node.asteriskToken) { write("*"); } @@ -27424,14 +29303,35 @@ var ts; emit(node.expression); } } + function emitAwaitExpression(node) { + var needsParenthesis = needsParenthesisForAwaitExpressionAsYield(node); + if (needsParenthesis) { + write("("); + } + write(ts.tokenToString(111 /* YieldKeyword */)); + write(" "); + emit(node.expression); + if (needsParenthesis) { + write(")"); + } + } + function needsParenthesisForAwaitExpressionAsYield(node) { + if (node.parent.kind === 178 /* BinaryExpression */ && !ts.isAssignmentOperator(node.parent.operatorToken.kind)) { + return true; + } + else if (node.parent.kind === 179 /* ConditionalExpression */ && node.parent.condition === node) { + return true; + } + return false; + } function needsParenthesisForPropertyAccessOrInvocation(node) { switch (node.kind) { - case 65 /* Identifier */: - case 156 /* ArrayLiteralExpression */: - case 158 /* PropertyAccessExpression */: - case 159 /* ElementAccessExpression */: - case 160 /* CallExpression */: - case 164 /* ParenthesizedExpression */: + case 66 /* Identifier */: + case 161 /* ArrayLiteralExpression */: + case 163 /* PropertyAccessExpression */: + case 164 /* ElementAccessExpression */: + case 165 /* CallExpression */: + case 169 /* ParenthesizedExpression */: // This list is not exhaustive and only includes those cases that are relevant // to the check in emitArrayLiteral. More cases can be added as needed. return false; @@ -27451,17 +29351,17 @@ var ts; write(", "); } var e = elements[pos]; - if (e.kind === 176 /* SpreadElementExpression */) { + if (e.kind === 182 /* SpreadElementExpression */) { e = e.expression; emitParenthesizedIf(e, group === 0 && needsParenthesisForPropertyAccessOrInvocation(e)); pos++; - if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 156 /* ArrayLiteralExpression */) { + if (pos === length && group === 0 && needsUniqueCopy && e.kind !== 161 /* ArrayLiteralExpression */) { write(".slice()"); } } else { var i = pos; - while (i < length && elements[i].kind !== 176 /* SpreadElementExpression */) { + while (i < length && elements[i].kind !== 182 /* SpreadElementExpression */) { i++; } write("["); @@ -27484,7 +29384,7 @@ var ts; } } function isSpreadElementExpression(node) { - return node.kind === 176 /* SpreadElementExpression */; + return node.kind === 182 /* SpreadElementExpression */; } function emitArrayLiteral(node) { var elements = node.elements; @@ -27497,7 +29397,7 @@ var ts; write("]"); } else { - emitListWithSpread(elements, true, (node.flags & 512 /* MultiLine */) !== 0, + emitListWithSpread(elements, true, (node.flags & 2048 /* MultiLine */) !== 0, /*trailingComma*/ elements.hasTrailingComma, true); } } @@ -27516,7 +29416,7 @@ var ts; emitLinePreservingList(node, properties, languageVersion >= 1 /* ES5 */, true); } else { - var multiLine = (node.flags & 512 /* MultiLine */) !== 0; + var multiLine = (node.flags & 2048 /* MultiLine */) !== 0; if (!multiLine) { write(" "); } @@ -27535,7 +29435,7 @@ var ts; write("}"); } function emitDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex) { - var multiLine = (node.flags & 512 /* MultiLine */) !== 0; + var multiLine = (node.flags & 2048 /* MultiLine */) !== 0; var properties = node.properties; write("("); if (multiLine) { @@ -27554,7 +29454,7 @@ var ts; writeComma(); var property = properties[i]; emitStart(property); - if (property.kind === 138 /* GetAccessor */ || property.kind === 139 /* SetAccessor */) { + if (property.kind === 142 /* GetAccessor */ || property.kind === 143 /* SetAccessor */) { // TODO (drosen): Reconcile with 'emitMemberFunctions'. var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property !== accessors.firstAccessor) { @@ -27606,13 +29506,13 @@ var ts; emitMemberAccessForPropertyName(property.name); emitEnd(property.name); write(" = "); - if (property.kind === 227 /* PropertyAssignment */) { + if (property.kind === 242 /* PropertyAssignment */) { emit(property.initializer); } - else if (property.kind === 228 /* ShorthandPropertyAssignment */) { + else if (property.kind === 243 /* ShorthandPropertyAssignment */) { emitExpressionIdentifier(property.name); } - else if (property.kind === 136 /* MethodDeclaration */) { + else if (property.kind === 140 /* MethodDeclaration */) { emitFunctionDeclaration(property); } else { @@ -27646,7 +29546,7 @@ var ts; // Everything until that point can be emitted as part of the initial object literal. var numInitialNonComputedProperties = numProperties; for (var i = 0, n = properties.length; i < n; i++) { - if (properties[i].name.kind === 129 /* ComputedPropertyName */) { + if (properties[i].name.kind === 133 /* ComputedPropertyName */) { numInitialNonComputedProperties = i; break; } @@ -27662,21 +29562,21 @@ var ts; emitObjectLiteralBody(node, properties.length); } function createBinaryExpression(left, operator, right, startsOnNewLine) { - var result = ts.createSynthesizedNode(172 /* BinaryExpression */, startsOnNewLine); + var result = ts.createSynthesizedNode(178 /* BinaryExpression */, startsOnNewLine); result.operatorToken = ts.createSynthesizedNode(operator); result.left = left; result.right = right; return result; } function createPropertyAccessExpression(expression, name) { - var result = ts.createSynthesizedNode(158 /* PropertyAccessExpression */); + var result = ts.createSynthesizedNode(163 /* PropertyAccessExpression */); result.expression = parenthesizeForAccess(expression); result.dotToken = ts.createSynthesizedNode(20 /* DotToken */); result.name = name; return result; } function createElementAccessExpression(expression, argumentExpression) { - var result = ts.createSynthesizedNode(159 /* ElementAccessExpression */); + var result = ts.createSynthesizedNode(164 /* ElementAccessExpression */); result.expression = parenthesizeForAccess(expression); result.argumentExpression = argumentExpression; return result; @@ -27684,7 +29584,7 @@ var ts; function parenthesizeForAccess(expr) { // When diagnosing whether the expression needs parentheses, the decision should be based // on the innermost expression in a chain of nested type assertions. - while (expr.kind === 163 /* TypeAssertionExpression */) { + while (expr.kind === 168 /* TypeAssertionExpression */ || expr.kind === 186 /* AsExpression */) { expr = expr.expression; } // isLeftHandSideExpression is almost the correct criterion for when it is not necessary @@ -27696,11 +29596,11 @@ var ts; // 1.x -> not the same as (1).x // if (ts.isLeftHandSideExpression(expr) && - expr.kind !== 161 /* NewExpression */ && + expr.kind !== 166 /* NewExpression */ && expr.kind !== 7 /* NumericLiteral */) { return expr; } - var node = ts.createSynthesizedNode(164 /* ParenthesizedExpression */); + var node = ts.createSynthesizedNode(169 /* ParenthesizedExpression */); node.expression = expr; return node; } @@ -27727,7 +29627,7 @@ var ts; // Return true if identifier resolves to an exported member of a namespace function isNamespaceExportReference(node) { var container = resolver.getReferencedExportContainer(node); - return container && container.kind !== 230 /* SourceFile */; + return container && container.kind !== 245 /* SourceFile */; } function emitShorthandPropertyAssignment(node) { // The name property of a short-hand property assignment is considered an expression position, so here @@ -27757,15 +29657,15 @@ var ts; if (constantValue !== undefined) { write(constantValue.toString()); if (!compilerOptions.removeComments) { - var propertyName = node.kind === 158 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); + var propertyName = node.kind === 163 /* PropertyAccessExpression */ ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); write(" /* " + propertyName + " */"); } return true; } return false; } - // Returns 'true' if the code was actually indented, false otherwise. - // If the code is not indented, an optional valueToWriteWhenNotIndenting will be + // Returns 'true' if the code was actually indented, false otherwise. + // If the code is not indented, an optional valueToWriteWhenNotIndenting will be // emitted instead. function indentIfOnDifferentLines(parent, node1, node2, valueToWriteWhenNotIndenting) { var realNodesAreOnDifferentLines = !ts.nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2); @@ -27789,7 +29689,18 @@ var ts; } emit(node.expression); var indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken); - write("."); + // 1 .toString is a valid property access, emit a space after the literal + var shouldEmitSpace; + if (!indentedBeforeDot && node.expression.kind === 7 /* NumericLiteral */) { + var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node.expression); + shouldEmitSpace = text.indexOf(ts.tokenToString(20 /* DotToken */)) < 0; + } + if (shouldEmitSpace) { + write(" ."); + } + else { + write("."); + } var indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name); emit(node.name); decreaseIndentIf(indentedBeforeDot, indentedAfterDot); @@ -27799,6 +29710,40 @@ var ts; write("."); emit(node.right); } + function emitQualifiedNameAsExpression(node, useFallback) { + if (node.left.kind === 66 /* Identifier */) { + emitEntityNameAsExpression(node.left, useFallback); + } + else if (useFallback) { + var temp = createAndRecordTempVariable(0 /* Auto */); + write("("); + emitNodeWithoutSourceMap(temp); + write(" = "); + emitEntityNameAsExpression(node.left, true); + write(") && "); + emitNodeWithoutSourceMap(temp); + } + else { + emitEntityNameAsExpression(node.left, false); + } + write("."); + emitNodeWithoutSourceMap(node.right); + } + function emitEntityNameAsExpression(node, useFallback) { + switch (node.kind) { + case 66 /* Identifier */: + if (useFallback) { + write("typeof "); + emitExpressionIdentifier(node); + write(" !== 'undefined' && "); + } + emitExpressionIdentifier(node); + break; + case 132 /* QualifiedName */: + emitQualifiedNameAsExpression(node, useFallback); + break; + } + } function emitIndexedAccess(node) { if (tryEmitConstantValue(node)) { return; @@ -27809,16 +29754,16 @@ var ts; write("]"); } function hasSpreadElement(elements) { - return ts.forEach(elements, function (e) { return e.kind === 176 /* SpreadElementExpression */; }); + return ts.forEach(elements, function (e) { return e.kind === 182 /* SpreadElementExpression */; }); } function skipParentheses(node) { - while (node.kind === 164 /* ParenthesizedExpression */ || node.kind === 163 /* TypeAssertionExpression */) { + while (node.kind === 169 /* ParenthesizedExpression */ || node.kind === 168 /* TypeAssertionExpression */ || node.kind === 186 /* AsExpression */) { node = node.expression; } return node; } function emitCallTarget(node) { - if (node.kind === 65 /* Identifier */ || node.kind === 93 /* ThisKeyword */ || node.kind === 91 /* SuperKeyword */) { + if (node.kind === 66 /* Identifier */ || node.kind === 94 /* ThisKeyword */ || node.kind === 92 /* SuperKeyword */) { emit(node); return node; } @@ -27833,20 +29778,20 @@ var ts; function emitCallWithSpread(node) { var target; var expr = skipParentheses(node.expression); - if (expr.kind === 158 /* PropertyAccessExpression */) { + if (expr.kind === 163 /* PropertyAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("."); emit(expr.name); } - else if (expr.kind === 159 /* ElementAccessExpression */) { + else if (expr.kind === 164 /* ElementAccessExpression */) { // Target will be emitted as "this" argument target = emitCallTarget(expr.expression); write("["); emit(expr.argumentExpression); write("]"); } - else if (expr.kind === 91 /* SuperKeyword */) { + else if (expr.kind === 92 /* SuperKeyword */) { target = expr; write("_super"); } @@ -27855,7 +29800,7 @@ var ts; } write(".apply("); if (target) { - if (target.kind === 91 /* SuperKeyword */) { + if (target.kind === 92 /* SuperKeyword */) { // Calls of form super(...) and super.foo(...) emitThis(target); } @@ -27878,13 +29823,13 @@ var ts; return; } var superCall = false; - if (node.expression.kind === 91 /* SuperKeyword */) { + if (node.expression.kind === 92 /* SuperKeyword */) { emitSuper(node.expression); superCall = true; } else { emit(node.expression); - superCall = node.expression.kind === 158 /* PropertyAccessExpression */ && node.expression.expression.kind === 91 /* SuperKeyword */; + superCall = node.expression.kind === 163 /* PropertyAccessExpression */ && node.expression.expression.kind === 92 /* SuperKeyword */; } if (superCall && languageVersion < 2 /* ES6 */) { write(".call("); @@ -27953,12 +29898,12 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 166 /* ArrowFunction */) { - if (node.expression.kind === 163 /* TypeAssertionExpression */) { + if (!ts.nodeIsSynthesized(node) && node.parent.kind !== 171 /* ArrowFunction */) { + if (node.expression.kind === 168 /* TypeAssertionExpression */ || node.expression.kind === 186 /* AsExpression */) { var operand = node.expression.expression; // Make sure we consider all nested cast expressions, e.g.: // (-A).x; - while (operand.kind === 163 /* TypeAssertionExpression */) { + while (operand.kind === 168 /* TypeAssertionExpression */ || operand.kind === 186 /* AsExpression */) { operand = operand.expression; } // We have an expression of the form: (SubExpr) @@ -27969,14 +29914,14 @@ var ts; // (typeof A).toString() should be emitted as (typeof A).toString() and not typeof A.toString() // new (A()) should be emitted as new (A()) and not new A() // (function foo() { })() should be emitted as an IIF (function foo(){})() and not declaration function foo(){} () - if (operand.kind !== 170 /* PrefixUnaryExpression */ && - operand.kind !== 169 /* VoidExpression */ && - operand.kind !== 168 /* TypeOfExpression */ && - operand.kind !== 167 /* DeleteExpression */ && - operand.kind !== 171 /* PostfixUnaryExpression */ && - operand.kind !== 161 /* NewExpression */ && - !(operand.kind === 160 /* CallExpression */ && node.parent.kind === 161 /* NewExpression */) && - !(operand.kind === 165 /* FunctionExpression */ && node.parent.kind === 160 /* CallExpression */)) { + if (operand.kind !== 176 /* PrefixUnaryExpression */ && + operand.kind !== 174 /* VoidExpression */ && + operand.kind !== 173 /* TypeOfExpression */ && + operand.kind !== 172 /* DeleteExpression */ && + operand.kind !== 177 /* PostfixUnaryExpression */ && + operand.kind !== 166 /* NewExpression */ && + !(operand.kind === 165 /* CallExpression */ && node.parent.kind === 166 /* NewExpression */) && + !(operand.kind === 170 /* FunctionExpression */ && node.parent.kind === 165 /* CallExpression */)) { emit(operand); return; } @@ -27987,25 +29932,25 @@ var ts; write(")"); } function emitDeleteExpression(node) { - write(ts.tokenToString(74 /* DeleteKeyword */)); + write(ts.tokenToString(75 /* DeleteKeyword */)); write(" "); emit(node.expression); } function emitVoidExpression(node) { - write(ts.tokenToString(99 /* VoidKeyword */)); + write(ts.tokenToString(100 /* VoidKeyword */)); write(" "); emit(node.expression); } function emitTypeOfExpression(node) { - write(ts.tokenToString(97 /* TypeOfKeyword */)); + write(ts.tokenToString(98 /* TypeOfKeyword */)); write(" "); emit(node.expression); } function isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node) { - if (!isCurrentFileSystemExternalModule() || node.kind !== 65 /* Identifier */ || ts.nodeIsSynthesized(node)) { + if (!isCurrentFileSystemExternalModule() || node.kind !== 66 /* Identifier */ || ts.nodeIsSynthesized(node)) { return false; } - var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 201 /* VariableDeclaration */ || node.parent.kind === 155 /* BindingElement */); + var isVariableDeclarationOrBindingElement = node.parent && (node.parent.kind === 208 /* VariableDeclaration */ || node.parent.kind === 160 /* BindingElement */); var targetDeclaration = isVariableDeclarationOrBindingElement ? node.parent : resolver.getReferencedValueDeclaration(node); @@ -28035,12 +29980,12 @@ var ts; // the resulting expression a prefix increment operation. And in the second, it will make the resulting // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. - if (node.operand.kind === 170 /* PrefixUnaryExpression */) { + if (node.operand.kind === 176 /* PrefixUnaryExpression */) { var operand = node.operand; - if (node.operator === 33 /* PlusToken */ && (operand.operator === 33 /* PlusToken */ || operand.operator === 38 /* PlusPlusToken */)) { + if (node.operator === 34 /* PlusToken */ && (operand.operator === 34 /* PlusToken */ || operand.operator === 39 /* PlusPlusToken */)) { write(" "); } - else if (node.operator === 34 /* MinusToken */ && (operand.operator === 34 /* MinusToken */ || operand.operator === 39 /* MinusMinusToken */)) { + else if (node.operator === 35 /* MinusToken */ && (operand.operator === 35 /* MinusToken */ || operand.operator === 40 /* MinusMinusToken */)) { write(" "); } } @@ -28060,7 +30005,7 @@ var ts; write("\", "); write(ts.tokenToString(node.operator)); emit(node.operand); - if (node.operator === 38 /* PlusPlusToken */) { + if (node.operator === 39 /* PlusPlusToken */) { write(") - 1)"); } else { @@ -28091,10 +30036,10 @@ var ts; } var current = node; while (current) { - if (current.kind === 230 /* SourceFile */) { + if (current.kind === 245 /* SourceFile */) { return !isExported || ((ts.getCombinedNodeFlags(node) & 1 /* Export */) !== 0); } - else if (ts.isFunctionLike(current) || current.kind === 209 /* ModuleBlock */) { + else if (ts.isFunctionLike(current) || current.kind === 216 /* ModuleBlock */) { return false; } else { @@ -28103,13 +30048,13 @@ var ts; } } function emitBinaryExpression(node) { - if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 53 /* EqualsToken */ && - (node.left.kind === 157 /* ObjectLiteralExpression */ || node.left.kind === 156 /* ArrayLiteralExpression */)) { - emitDestructuring(node, node.parent.kind === 185 /* ExpressionStatement */); + if (languageVersion < 2 /* ES6 */ && node.operatorToken.kind === 54 /* EqualsToken */ && + (node.left.kind === 162 /* ObjectLiteralExpression */ || node.left.kind === 161 /* ArrayLiteralExpression */)) { + emitDestructuring(node, node.parent.kind === 192 /* ExpressionStatement */); } else { - var exportChanged = node.operatorToken.kind >= 53 /* FirstAssignment */ && - node.operatorToken.kind <= 64 /* LastAssignment */ && + var exportChanged = node.operatorToken.kind >= 54 /* FirstAssignment */ && + node.operatorToken.kind <= 65 /* LastAssignment */ && isNameOfExportedSourceLevelDeclarationInSystemExternalModule(node.left); if (exportChanged) { // emit assignment 'x y' as 'exports("x", x y)' @@ -28144,7 +30089,7 @@ var ts; emit(node.whenFalse); decreaseIndentIf(indentedBeforeColon, indentedAfterColon); } - // Helper function to decrease the indent if we previously indented. Allows multiple + // Helper function to decrease the indent if we previously indented. Allows multiple // previous indent values to be considered at a time. This also allows caller to just // call this once, passing in all their appropriate indent values, instead of needing // to call this helper function multiple times. @@ -28157,7 +30102,7 @@ var ts; } } function isSingleLineEmptyBlock(node) { - if (node && node.kind === 182 /* Block */) { + if (node && node.kind === 189 /* Block */) { var block = node; return block.statements.length === 0 && nodeEndIsOnSameLineAsNodeStart(block, block); } @@ -28172,12 +30117,12 @@ var ts; emitToken(14 /* OpenBraceToken */, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 209 /* ModuleBlock */) { - ts.Debug.assert(node.parent.kind === 208 /* ModuleDeclaration */); + if (node.kind === 216 /* ModuleBlock */) { + ts.Debug.assert(node.parent.kind === 215 /* ModuleDeclaration */); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); - if (node.kind === 209 /* ModuleBlock */) { + if (node.kind === 216 /* ModuleBlock */) { emitTempDeclarations(true); } decreaseIndent(); @@ -28186,7 +30131,7 @@ var ts; scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 182 /* Block */) { + if (node.kind === 189 /* Block */) { write(" "); emit(node); } @@ -28198,11 +30143,11 @@ var ts; } } function emitExpressionStatement(node) { - emitParenthesizedIf(node.expression, node.expression.kind === 166 /* ArrowFunction */); + emitParenthesizedIf(node.expression, node.expression.kind === 171 /* ArrowFunction */); write(";"); } function emitIfStatement(node) { - var endPos = emitToken(84 /* IfKeyword */, node.pos); + var endPos = emitToken(85 /* IfKeyword */, node.pos); write(" "); endPos = emitToken(16 /* OpenParenToken */, endPos); emit(node.expression); @@ -28210,8 +30155,8 @@ var ts; emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - emitToken(76 /* ElseKeyword */, node.thenStatement.end); - if (node.elseStatement.kind === 186 /* IfStatement */) { + emitToken(77 /* ElseKeyword */, node.thenStatement.end); + if (node.elseStatement.kind === 193 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -28223,7 +30168,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 182 /* Block */) { + if (node.statement.kind === 189 /* Block */) { write(" "); } else { @@ -28249,13 +30194,13 @@ var ts; // variables in variable declaration list were already hoisted return false; } - var tokenKind = 98 /* VarKeyword */; + var tokenKind = 99 /* VarKeyword */; if (decl && languageVersion >= 2 /* ES6 */) { if (ts.isLet(decl)) { - tokenKind = 104 /* LetKeyword */; + tokenKind = 105 /* LetKeyword */; } else if (ts.isConst(decl)) { - tokenKind = 70 /* ConstKeyword */; + tokenKind = 71 /* ConstKeyword */; } } if (startPos !== undefined) { @@ -28264,13 +30209,13 @@ var ts; } else { switch (tokenKind) { - case 98 /* VarKeyword */: + case 99 /* VarKeyword */: write("var "); break; - case 104 /* LetKeyword */: + case 105 /* LetKeyword */: write("let "); break; - case 70 /* ConstKeyword */: + case 71 /* ConstKeyword */: write("const "); break; } @@ -28295,10 +30240,10 @@ var ts; return started; } function emitForStatement(node) { - var endPos = emitToken(82 /* ForKeyword */, node.pos); + var endPos = emitToken(83 /* ForKeyword */, node.pos); write(" "); endPos = emitToken(16 /* OpenParenToken */, endPos); - if (node.initializer && node.initializer.kind === 202 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 209 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; var startIsEmitted = tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); if (startIsEmitted) { @@ -28319,13 +30264,13 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInOrForOfStatement(node) { - if (languageVersion < 2 /* ES6 */ && node.kind === 191 /* ForOfStatement */) { + if (languageVersion < 2 /* ES6 */ && node.kind === 198 /* ForOfStatement */) { return emitDownLevelForOfStatement(node); } - var endPos = emitToken(82 /* ForKeyword */, node.pos); + var endPos = emitToken(83 /* ForKeyword */, node.pos); write(" "); endPos = emitToken(16 /* OpenParenToken */, endPos); - if (node.initializer.kind === 202 /* VariableDeclarationList */) { + if (node.initializer.kind === 209 /* VariableDeclarationList */) { var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length >= 1) { tryEmitStartOfVariableDeclarationList(variableDeclarationList, endPos); @@ -28335,7 +30280,7 @@ var ts; else { emit(node.initializer); } - if (node.kind === 190 /* ForInStatement */) { + if (node.kind === 197 /* ForInStatement */) { write(" in "); } else { @@ -28366,7 +30311,7 @@ var ts; // 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(82 /* ForKeyword */, node.pos); + var endPos = emitToken(83 /* ForKeyword */, node.pos); write(" "); endPos = emitToken(16 /* OpenParenToken */, endPos); // Do not emit the LHS let declaration yet, because it might contain destructuring. @@ -28377,7 +30322,7 @@ var ts; // for (let v of arr) { } // // we don't want to emit a temporary variable for the RHS, just use it directly. - var rhsIsIdentifier = node.expression.kind === 65 /* Identifier */; + var rhsIsIdentifier = node.expression.kind === 66 /* Identifier */; var counter = createTempVariable(268435456 /* _i */); var rhsReference = rhsIsIdentifier ? node.expression : createTempVariable(0 /* Auto */); // This is the let keyword for the counter and rhsReference. The let keyword for @@ -28420,7 +30365,7 @@ var ts; // let v = _a[_i]; var rhsIterationValue = createElementAccessExpression(rhsReference, counter); emitStart(node.initializer); - if (node.initializer.kind === 202 /* VariableDeclarationList */) { + if (node.initializer.kind === 209 /* VariableDeclarationList */) { write("var "); var variableDeclarationList = node.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -28449,8 +30394,8 @@ var ts; else { // Initializer is an expression. Emit the expression in the body, so that it's // evaluated on every iteration. - var assignmentExpression = createBinaryExpression(node.initializer, 53 /* EqualsToken */, rhsIterationValue, false); - if (node.initializer.kind === 156 /* ArrayLiteralExpression */ || node.initializer.kind === 157 /* ObjectLiteralExpression */) { + var assignmentExpression = createBinaryExpression(node.initializer, 54 /* EqualsToken */, rhsIterationValue, false); + if (node.initializer.kind === 161 /* ArrayLiteralExpression */ || node.initializer.kind === 162 /* ObjectLiteralExpression */) { // This is a destructuring pattern, so call emitDestructuring instead of emit. Calling emit will not work, because it will cause // the BinaryExpression to be passed in instead of the expression statement, which will cause emitDestructuring to crash. emitDestructuring(assignmentExpression, true, undefined); @@ -28461,7 +30406,7 @@ var ts; } emitEnd(node.initializer); write(";"); - if (node.statement.kind === 182 /* Block */) { + if (node.statement.kind === 189 /* Block */) { emitLines(node.statement.statements); } else { @@ -28473,12 +30418,12 @@ var ts; write("}"); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 193 /* BreakStatement */ ? 66 /* BreakKeyword */ : 71 /* ContinueKeyword */, node.pos); + emitToken(node.kind === 200 /* BreakStatement */ ? 67 /* BreakKeyword */ : 72 /* ContinueKeyword */, node.pos); emitOptional(" ", node.label); write(";"); } function emitReturnStatement(node) { - emitToken(90 /* ReturnKeyword */, node.pos); + emitToken(91 /* ReturnKeyword */, node.pos); emitOptional(" ", node.expression); write(";"); } @@ -28489,7 +30434,7 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var endPos = emitToken(92 /* SwitchKeyword */, node.pos); + var endPos = emitToken(93 /* SwitchKeyword */, node.pos); write(" "); emitToken(16 /* OpenParenToken */, endPos); emit(node.expression); @@ -28518,7 +30463,7 @@ var ts; ts.getLineOfLocalPosition(currentSourceFile, ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 223 /* CaseClause */) { + if (node.kind === 238 /* CaseClause */) { write("case "); emit(node.expression); write(":"); @@ -28553,7 +30498,7 @@ var ts; } function emitCatchClause(node) { writeLine(); - var endPos = emitToken(68 /* CatchKeyword */, node.pos); + var endPos = emitToken(69 /* CatchKeyword */, node.pos); write(" "); emitToken(16 /* OpenParenToken */, endPos); emit(node.variableDeclaration); @@ -28562,7 +30507,7 @@ var ts; emitBlock(node.block); } function emitDebuggerStatement(node) { - emitToken(72 /* DebuggerKeyword */, node.pos); + emitToken(73 /* DebuggerKeyword */, node.pos); write(";"); } function emitLabelledStatement(node) { @@ -28573,7 +30518,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 208 /* ModuleDeclaration */); + } while (node && node.kind !== 215 /* ModuleDeclaration */); return node; } function emitContainingModuleName(node) { @@ -28598,7 +30543,7 @@ var ts; function createVoidZero() { var zero = ts.createSynthesizedNode(7 /* NumericLiteral */); zero.text = "0"; - var result = ts.createSynthesizedNode(169 /* VoidExpression */); + var result = ts.createSynthesizedNode(174 /* VoidExpression */); result.expression = zero; return result; } @@ -28611,7 +30556,7 @@ var ts; // emit export default as // export("default", ) write(exportFunctionForFile + "(\""); - if (node.flags & 256 /* Default */) { + if (node.flags & 1024 /* Default */) { write("default"); } else { @@ -28622,7 +30567,7 @@ var ts; write(")"); } else { - if (node.flags & 256 /* Default */) { + if (node.flags & 1024 /* Default */) { if (languageVersion === 0 /* ES3 */) { write("exports[\"default\"]"); } @@ -28674,15 +30619,15 @@ var ts; // Also temporary variables should be explicitly allocated for source level declarations when module target is system // because actual variable declarations are hoisted var canDefineTempVariablesInPlace = false; - if (root.kind === 201 /* VariableDeclaration */) { + if (root.kind === 208 /* VariableDeclaration */) { var isExported = ts.getCombinedNodeFlags(root) & 1 /* Export */; var isSourceLevelForSystemModuleKind = shouldHoistDeclarationInSystemJsModule(root); canDefineTempVariablesInPlace = !isExported && !isSourceLevelForSystemModuleKind; } - else if (root.kind === 131 /* Parameter */) { + else if (root.kind === 135 /* Parameter */) { canDefineTempVariablesInPlace = true; } - if (root.kind === 172 /* BinaryExpression */) { + if (root.kind === 178 /* BinaryExpression */) { emitAssignmentExpression(root); } else { @@ -28693,7 +30638,7 @@ var ts; if (emitCount++) { write(", "); } - var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 201 /* VariableDeclaration */ || name.parent.kind === 155 /* BindingElement */); + var isVariableDeclarationOrBindingElement = name.parent && (name.parent.kind === 208 /* VariableDeclaration */ || name.parent.kind === 160 /* BindingElement */); var exportChanged = isNameOfExportedSourceLevelDeclarationInSystemExternalModule(name); if (exportChanged) { write(exportFunctionForFile + "(\""); @@ -28713,7 +30658,7 @@ var ts; } } function ensureIdentifier(expr) { - if (expr.kind !== 65 /* Identifier */) { + if (expr.kind !== 66 /* Identifier */) { var identifier = createTempVariable(0 /* Auto */); if (!canDefineTempVariablesInPlace) { recordTempDeclaration(identifier); @@ -28728,18 +30673,18 @@ var ts; // we need to generate a temporary variable value = ensureIdentifier(value); // Return the expression 'value === void 0 ? defaultValue : value' - var equals = ts.createSynthesizedNode(172 /* BinaryExpression */); + var equals = ts.createSynthesizedNode(178 /* BinaryExpression */); equals.left = value; - equals.operatorToken = ts.createSynthesizedNode(30 /* EqualsEqualsEqualsToken */); + equals.operatorToken = ts.createSynthesizedNode(31 /* EqualsEqualsEqualsToken */); equals.right = createVoidZero(); return createConditionalExpression(equals, defaultValue, value); } function createConditionalExpression(condition, whenTrue, whenFalse) { - var cond = ts.createSynthesizedNode(173 /* ConditionalExpression */); + var cond = ts.createSynthesizedNode(179 /* ConditionalExpression */); cond.condition = condition; - cond.questionToken = ts.createSynthesizedNode(50 /* QuestionToken */); + cond.questionToken = ts.createSynthesizedNode(51 /* QuestionToken */); cond.whenTrue = whenTrue; - cond.colonToken = ts.createSynthesizedNode(51 /* ColonToken */); + cond.colonToken = ts.createSynthesizedNode(52 /* ColonToken */); cond.whenFalse = whenFalse; return cond; } @@ -28753,14 +30698,14 @@ var ts; // otherwise occur when the identifier is emitted. var syntheticName = ts.createSynthesizedNode(propName.kind); syntheticName.text = propName.text; - if (syntheticName.kind !== 65 /* Identifier */) { + if (syntheticName.kind !== 66 /* Identifier */) { return createElementAccessExpression(object, syntheticName); } return createPropertyAccessExpression(object, syntheticName); } function createSliceCall(value, sliceIndex) { - var call = ts.createSynthesizedNode(160 /* CallExpression */); - var sliceIdentifier = ts.createSynthesizedNode(65 /* Identifier */); + var call = ts.createSynthesizedNode(165 /* CallExpression */); + var sliceIdentifier = ts.createSynthesizedNode(66 /* Identifier */); sliceIdentifier.text = "slice"; call.expression = createPropertyAccessExpression(value, sliceIdentifier); call.arguments = ts.createSynthesizedNodeArray(); @@ -28776,7 +30721,7 @@ var ts; } for (var _a = 0; _a < properties.length; _a++) { var p = properties[_a]; - if (p.kind === 227 /* PropertyAssignment */ || p.kind === 228 /* ShorthandPropertyAssignment */) { + if (p.kind === 242 /* PropertyAssignment */ || p.kind === 243 /* ShorthandPropertyAssignment */) { var propName = p.name; emitDestructuringAssignment(p.initializer || propName, createPropertyAccessForDestructuringProperty(value, propName)); } @@ -28791,8 +30736,8 @@ var ts; } for (var i = 0; i < elements.length; i++) { var e = elements[i]; - if (e.kind !== 178 /* OmittedExpression */) { - if (e.kind !== 176 /* SpreadElementExpression */) { + if (e.kind !== 184 /* OmittedExpression */) { + if (e.kind !== 182 /* SpreadElementExpression */) { emitDestructuringAssignment(e, createElementAccessExpression(value, createNumericLiteral(i))); } else if (i === elements.length - 1) { @@ -28802,14 +30747,14 @@ var ts; } } function emitDestructuringAssignment(target, value) { - if (target.kind === 172 /* BinaryExpression */ && target.operatorToken.kind === 53 /* EqualsToken */) { + if (target.kind === 178 /* BinaryExpression */ && target.operatorToken.kind === 54 /* EqualsToken */) { value = createDefaultValueCheck(value, target.right); target = target.left; } - if (target.kind === 157 /* ObjectLiteralExpression */) { + if (target.kind === 162 /* ObjectLiteralExpression */) { emitObjectLiteralAssignment(target, value); } - else if (target.kind === 156 /* ArrayLiteralExpression */) { + else if (target.kind === 161 /* ArrayLiteralExpression */) { emitArrayLiteralAssignment(target, value); } else { @@ -28823,14 +30768,14 @@ var ts; emitDestructuringAssignment(target, value); } else { - if (root.parent.kind !== 164 /* ParenthesizedExpression */) { + if (root.parent.kind !== 169 /* ParenthesizedExpression */) { write("("); } value = ensureIdentifier(value); emitDestructuringAssignment(target, value); write(", "); emit(value); - if (root.parent.kind !== 164 /* ParenthesizedExpression */) { + if (root.parent.kind !== 169 /* ParenthesizedExpression */) { write(")"); } } @@ -28854,12 +30799,12 @@ var ts; } for (var i = 0; i < elements.length; i++) { var element = elements[i]; - if (pattern.kind === 153 /* ObjectBindingPattern */) { + if (pattern.kind === 158 /* ObjectBindingPattern */) { // Rewrite element to a declaration with an initializer that fetches property var propName = element.propertyName || element.name; emitBindingElement(element, createPropertyAccessForDestructuringProperty(value, propName)); } - else if (element.kind !== 178 /* OmittedExpression */) { + else if (element.kind !== 184 /* OmittedExpression */) { if (!element.dotDotDotToken) { // Rewrite element to a declaration that accesses array element at index i emitBindingElement(element, createElementAccessExpression(value, createNumericLiteral(i))); @@ -28894,12 +30839,12 @@ var ts; // for (...) { var = void 0; } // this is necessary to preserve ES6 semantic in scenarios like // for (...) { let x; console.log(x); x = 1 } // assignment on one iteration should not affect other iterations - var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 256 /* BlockScopedBindingInLoop */) && - (getCombinedFlagsForIdentifier(node.name) & 4096 /* Let */); + var isUninitializedLet = (resolver.getNodeCheckFlags(node) & 16384 /* BlockScopedBindingInLoop */) && + (getCombinedFlagsForIdentifier(node.name) & 16384 /* Let */); // NOTE: default initialization should not be added to let bindings in for-in\for-of statements if (isUninitializedLet && - node.parent.parent.kind !== 190 /* ForInStatement */ && - node.parent.parent.kind !== 191 /* ForOfStatement */) { + node.parent.parent.kind !== 197 /* ForInStatement */ && + node.parent.parent.kind !== 198 /* ForOfStatement */) { initializer = createVoidZero(); } } @@ -28917,11 +30862,11 @@ var ts; } } function emitExportVariableAssignments(node) { - if (node.kind === 178 /* OmittedExpression */) { + if (node.kind === 184 /* OmittedExpression */) { return; } var name = node.name; - if (name.kind === 65 /* Identifier */) { + if (name.kind === 66 /* Identifier */) { emitExportMemberAssignments(name); } else if (ts.isBindingPattern(name)) { @@ -28929,7 +30874,7 @@ var ts; } } function getCombinedFlagsForIdentifier(node) { - if (!node.parent || (node.parent.kind !== 201 /* VariableDeclaration */ && node.parent.kind !== 155 /* BindingElement */)) { + if (!node.parent || (node.parent.kind !== 208 /* VariableDeclaration */ && node.parent.kind !== 160 /* BindingElement */)) { return 0; } return ts.getCombinedNodeFlags(node.parent); @@ -28937,7 +30882,7 @@ var ts; function isES6ExportedDeclaration(node) { return !!(node.flags & 1 /* Export */) && languageVersion >= 2 /* ES6 */ && - node.parent.kind === 230 /* SourceFile */; + node.parent.kind === 245 /* SourceFile */; } function emitVariableStatement(node) { var startIsEmitted = false; @@ -28988,12 +30933,12 @@ var ts; function emitParameter(node) { if (languageVersion < 2 /* ES6 */) { if (ts.isBindingPattern(node.name)) { - var name_20 = createTempVariable(0 /* Auto */); + var name_23 = createTempVariable(0 /* Auto */); if (!tempParameters) { tempParameters = []; } - tempParameters.push(name_20); - emit(name_20); + tempParameters.push(name_23); + emit(name_23); } else { emit(node.name); @@ -29010,32 +30955,46 @@ var ts; function emitDefaultValueAssignments(node) { if (languageVersion < 2 /* ES6 */) { var tempIndex = 0; - ts.forEach(node.parameters, function (p) { + ts.forEach(node.parameters, function (parameter) { // A rest parameter cannot have a binding pattern or an initializer, // so let's just ignore it. - if (p.dotDotDotToken) { + if (parameter.dotDotDotToken) { return; } - if (ts.isBindingPattern(p.name)) { - writeLine(); - write("var "); - emitDestructuring(p, false, tempParameters[tempIndex]); - write(";"); - tempIndex++; + var paramName = parameter.name, initializer = parameter.initializer; + if (ts.isBindingPattern(paramName)) { + // In cases where a binding pattern is simply '[]' or '{}', + // we usually don't want to emit a var declaration; however, in the presence + // of an initializer, we must emit that expression to preserve side effects. + 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 (p.initializer) { + else if (initializer) { writeLine(); - emitStart(p); + emitStart(parameter); write("if ("); - emitNodeWithoutSourceMap(p.name); + emitNodeWithoutSourceMap(paramName); write(" === void 0)"); - emitEnd(p); + emitEnd(parameter); write(" { "); - emitStart(p); - emitNodeWithoutSourceMap(p.name); + emitStart(parameter); + emitNodeWithoutSourceMap(paramName); write(" = "); - emitNodeWithoutSourceMap(p.initializer); - emitEnd(p); + emitNodeWithoutSourceMap(initializer); + emitEnd(parameter); write("; }"); } }); @@ -29084,12 +31043,12 @@ var ts; } } function emitAccessor(node) { - write(node.kind === 138 /* GetAccessor */ ? "get " : "set "); + write(node.kind === 142 /* GetAccessor */ ? "get " : "set "); emit(node.name); emitSignatureAndBody(node); } function shouldEmitAsArrowFunction(node) { - return node.kind === 166 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; + return node.kind === 171 /* ArrowFunction */ && languageVersion >= 2 /* ES6 */; } function emitDeclarationName(node) { if (node.name) { @@ -29100,11 +31059,11 @@ var ts; } } function shouldEmitFunctionName(node) { - if (node.kind === 165 /* FunctionExpression */) { + if (node.kind === 170 /* FunctionExpression */) { // Emit name if one is present return !!node.name; } - if (node.kind === 203 /* FunctionDeclaration */) { + if (node.kind === 210 /* FunctionDeclaration */) { // Emit name if one is present, or emit generated name in down-level case (for export default case) return !!node.name || languageVersion < 2 /* ES6 */; } @@ -29113,7 +31072,7 @@ var ts; if (ts.nodeIsMissing(node.body)) { return emitOnlyPinnedOrTripleSlashComments(node); } - if (node.kind !== 136 /* MethodDeclaration */ && node.kind !== 135 /* MethodSignature */) { + if (node.kind !== 140 /* MethodDeclaration */ && node.kind !== 139 /* MethodSignature */) { // Methods will emit the comments as part of emitting method declaration emitLeadingComments(node); } @@ -29122,7 +31081,7 @@ var ts; if (!shouldEmitAsArrowFunction(node)) { if (isES6ExportedDeclaration(node)) { write("export "); - if (node.flags & 256 /* Default */) { + if (node.flags & 1024 /* Default */) { write("default "); } } @@ -29136,10 +31095,10 @@ var ts; emitDeclarationName(node); } emitSignatureAndBody(node); - if (languageVersion < 2 /* ES6 */ && node.kind === 203 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { + if (languageVersion < 2 /* ES6 */ && node.kind === 210 /* FunctionDeclaration */ && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - if (node.kind !== 136 /* MethodDeclaration */ && node.kind !== 135 /* MethodSignature */) { + if (node.kind !== 140 /* MethodDeclaration */ && node.kind !== 139 /* MethodSignature */) { emitTrailingComments(node); } } @@ -29170,6 +31129,137 @@ var ts; } emitSignatureParameters(node); } + function emitAsyncFunctionBodyForES6(node) { + var promiseConstructor = ts.getEntityNameFromTypeNode(node.type); + var isArrowFunction = node.kind === 171 /* ArrowFunction */; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 4096 /* CaptureArguments */) !== 0; + var args; + // An async function is emit as an outer function that calls an inner + // generator function. To preserve lexical bindings, we pass the current + // `this` and `arguments` objects to `__awaiter`. The generator function + // passed to `__awaiter` is executed inside of the callback to the + // promise constructor. + // + // The emit for an async arrow without a lexical `arguments` binding might be: + // + // // input + // let a = async (b) => { await b; } + // + // // output + // let a = (b) => __awaiter(this, void 0, void 0, function* () { + // yield b; + // }); + // + // The emit for an async arrow with a lexical `arguments` binding might be: + // + // // input + // let a = async (b) => { await arguments[0]; } + // + // // output + // let a = (b) => __awaiter(this, arguments, void 0, function* (arguments) { + // yield arguments[0]; + // }); + // + // The emit for an async function expression without a lexical `arguments` binding + // might be: + // + // // input + // let a = async function (b) { + // await b; + // } + // + // // output + // let a = function (b) { + // return __awaiter(this, void 0, void 0, function* () { + // yield b; + // }); + // } + // + // The emit for an async function expression with a lexical `arguments` binding + // might be: + // + // // input + // let a = async function (b) { + // await arguments[0]; + // } + // + // // output + // let a = function (b) { + // return __awaiter(this, arguments, void 0, function* (_arguments) { + // yield _arguments[0]; + // }); + // } + // + // The emit for an async function expression with a lexical `arguments` binding + // and a return type annotation might be: + // + // // input + // let a = async function (b): MyPromise { + // await arguments[0]; + // } + // + // // output + // let a = function (b) { + // return __awaiter(this, arguments, MyPromise, function* (_arguments) { + // yield _arguments[0]; + // }); + // } + // + // If this is not an async arrow, emit the opening brace of the function body + // and the start of the return statement. + 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"); + } + // Emit the call to __awaiter. + if (hasLexicalArguments) { + write(", function* (_arguments)"); + } + else { + write(", function* ()"); + } + // Emit the signature and body for the inner generator function. + emitFunctionBody(node); + write(")"); + // If this is not an async arrow, emit the closing brace of the outer function body. + if (!isArrowFunction) { + write(";"); + decreaseIndent(); + writeLine(); + write("}"); + } + } + function emitFunctionBody(node) { + if (!node.body) { + // There can be no body when there are parse errors. Just emit an empty block + // in that case. + write(" { }"); + } + else { + if (node.body.kind === 189 /* Block */) { + emitBlockFunctionBody(node, node.body); + } + else { + emitExpressionFunctionBody(node, node.body); + } + } + } function emitSignatureAndBody(node) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; @@ -29185,16 +31275,12 @@ var ts; else { emitSignatureParameters(node); } - if (!node.body) { - // There can be no body when there are parse errors. Just emit an empty block - // in that case. - write(" { }"); - } - else if (node.body.kind === 182 /* Block */) { - emitBlockFunctionBody(node, node.body); + var isAsync = ts.isAsyncFunctionLike(node); + if (isAsync && languageVersion === 2 /* ES6 */) { + emitAsyncFunctionBodyForES6(node); } else { - emitExpressionFunctionBody(node, node.body); + emitFunctionBody(node); } if (!isES6ExportedDeclaration(node)) { emitExportMemberAssignment(node); @@ -29210,21 +31296,21 @@ var ts; emitRestParameter(node); } function emitExpressionFunctionBody(node, body) { - if (languageVersion < 2 /* ES6 */) { + if (languageVersion < 2 /* ES6 */ || node.flags & 512 /* Async */) { emitDownLevelExpressionFunctionBody(node, body); return; } - // For es6 and higher we can emit the expression as is. However, in the case + // For es6 and higher we can emit the expression as is. However, in the case // where the expression might end up looking like a block when emitted, we'll // also wrap it in parentheses first. For example if you have: a => {} // then we need to generate: a => ({}) write(" "); // Unwrap all type assertions. var current = body; - while (current.kind === 163 /* TypeAssertionExpression */) { + while (current.kind === 168 /* TypeAssertionExpression */) { current = current.expression; } - emitParenthesizedIf(body, current.kind === 157 /* ObjectLiteralExpression */); + emitParenthesizedIf(body, current.kind === 162 /* ObjectLiteralExpression */); } function emitDownLevelExpressionFunctionBody(node, body) { write(" {"); @@ -29300,11 +31386,11 @@ var ts; function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 185 /* ExpressionStatement */) { + if (statement && statement.kind === 192 /* ExpressionStatement */) { var expr = statement.expression; - if (expr && expr.kind === 160 /* CallExpression */) { + if (expr && expr.kind === 165 /* CallExpression */) { var func = expr.expression; - if (func && func.kind === 91 /* SuperKeyword */) { + if (func && func.kind === 92 /* SuperKeyword */) { return statement; } } @@ -29334,7 +31420,7 @@ var ts; emitNodeWithoutSourceMap(memberName); write("]"); } - else if (memberName.kind === 129 /* ComputedPropertyName */) { + else if (memberName.kind === 133 /* ComputedPropertyName */) { emitComputedPropertyName(memberName); } else { @@ -29346,7 +31432,7 @@ var ts; var properties = []; for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if (member.kind === 134 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { + if (member.kind === 138 /* PropertyDeclaration */ && isStatic === ((member.flags & 128 /* Static */) !== 0) && member.initializer) { properties.push(member); } } @@ -29386,11 +31472,11 @@ var ts; } function emitMemberFunctionsForES5AndLower(node) { ts.forEach(node.members, function (member) { - if (member.kind === 181 /* SemicolonClassElement */) { + if (member.kind === 188 /* SemicolonClassElement */) { writeLine(); write(";"); } - else if (member.kind === 136 /* MethodDeclaration */ || node.kind === 135 /* MethodSignature */) { + else if (member.kind === 140 /* MethodDeclaration */ || node.kind === 139 /* MethodSignature */) { if (!member.body) { return emitOnlyPinnedOrTripleSlashComments(member); } @@ -29409,7 +31495,7 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 138 /* GetAccessor */ || member.kind === 139 /* SetAccessor */) { + else if (member.kind === 142 /* GetAccessor */ || member.kind === 143 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { writeLine(); @@ -29459,22 +31545,22 @@ var ts; function emitMemberFunctionsForES6AndHigher(node) { for (var _a = 0, _b = node.members; _a < _b.length; _a++) { var member = _b[_a]; - if ((member.kind === 136 /* MethodDeclaration */ || node.kind === 135 /* MethodSignature */) && !member.body) { + if ((member.kind === 140 /* MethodDeclaration */ || node.kind === 139 /* MethodSignature */) && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } - else if (member.kind === 136 /* MethodDeclaration */ || - member.kind === 138 /* GetAccessor */ || - member.kind === 139 /* SetAccessor */) { + else if (member.kind === 140 /* MethodDeclaration */ || + member.kind === 142 /* GetAccessor */ || + member.kind === 143 /* SetAccessor */) { writeLine(); emitLeadingComments(member); emitStart(member); if (member.flags & 128 /* Static */) { write("static "); } - if (member.kind === 138 /* GetAccessor */) { + if (member.kind === 142 /* GetAccessor */) { write("get "); } - else if (member.kind === 139 /* SetAccessor */) { + else if (member.kind === 143 /* SetAccessor */) { write("set "); } if (member.asteriskToken) { @@ -29485,7 +31571,7 @@ var ts; emitEnd(member); emitTrailingComments(member); } - else if (member.kind === 181 /* SemicolonClassElement */) { + else if (member.kind === 188 /* SemicolonClassElement */) { writeLine(); write(";"); } @@ -29510,11 +31596,11 @@ var ts; var hasInstancePropertyWithInitializer = false; // Emit the constructor overload pinned comments ts.forEach(node.members, function (member) { - if (member.kind === 137 /* Constructor */ && !member.body) { + if (member.kind === 141 /* Constructor */ && !member.body) { emitOnlyPinnedOrTripleSlashComments(member); } // Check if there is any non-static property assignment - if (member.kind === 134 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { + if (member.kind === 138 /* PropertyDeclaration */ && member.initializer && (member.flags & 128 /* Static */) === 0) { hasInstancePropertyWithInitializer = true; } }); @@ -29622,7 +31708,7 @@ var ts; } function emitClassLikeDeclarationForES6AndHigher(node) { var thisNodeIsDecorated = ts.nodeIsDecorated(node); - if (node.kind === 204 /* ClassDeclaration */) { + if (node.kind === 211 /* ClassDeclaration */) { if (thisNodeIsDecorated) { // To preserve the correct runtime semantics when decorators are applied to the class, // the emit needs to follow one of the following rules: @@ -29676,7 +31762,7 @@ var ts; // _default = __decorate([dec], _default); // export default _default; // - if (isES6ExportedDeclaration(node) && !(node.flags & 256 /* Default */)) { + if (isES6ExportedDeclaration(node) && !(node.flags & 1024 /* Default */)) { write("export "); } write("let "); @@ -29685,15 +31771,15 @@ var ts; } else if (isES6ExportedDeclaration(node)) { write("export "); - if (node.flags & 256 /* Default */) { + if (node.flags & 1024 /* Default */) { write("default "); } } } // If the class has static properties, and it's a class expression, then we'll need - // to specialize the emit a bit. for a class expression of the form: + // to specialize the emit a bit. for a class expression of the form: // - // class C { static a = 1; static b = 2; ... } + // class C { static a = 1; static b = 2; ... } // // We'll emit: // @@ -29702,7 +31788,7 @@ var ts; // This keeps the expression as an expression, while ensuring that the static parts // of it have been initialized by the time it is used. var staticProperties = getInitializedProperties(node, true); - var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 177 /* ClassExpression */; + var isClassExpressionWithStaticProperties = staticProperties.length > 0 && node.kind === 183 /* ClassExpression */; var tempVariable; if (isClassExpressionWithStaticProperties) { tempVariable = createAndRecordTempVariable(0 /* Auto */); @@ -29713,7 +31799,7 @@ var ts; } write("class"); // check if this is an "export default class" as it may not have a name. Do not emit the name if the class is decorated. - if ((node.name || !(node.flags & 256 /* Default */)) && !thisNodeIsDecorated) { + if ((node.name || !(node.flags & 1024 /* Default */)) && !thisNodeIsDecorated) { write(" "); emitDeclarationName(node); } @@ -29777,7 +31863,7 @@ var ts; emitEnd(node); write(";"); } - else if (isES6ExportedDeclaration(node) && (node.flags & 256 /* Default */) && thisNodeIsDecorated) { + else if (isES6ExportedDeclaration(node) && (node.flags & 1024 /* Default */) && thisNodeIsDecorated) { // if this is a top level default export of decorated class, write the export after the declaration. writeLine(); write("export default "); @@ -29786,7 +31872,7 @@ var ts; } } function emitClassLikeDeclarationBelowES6(node) { - if (node.kind === 204 /* ClassDeclaration */) { + if (node.kind === 211 /* ClassDeclaration */) { // source file level classes in system modules are hoisted so 'var's for them are already defined if (!shouldHoistDeclarationInSystemJsModule(node)) { write("var "); @@ -29845,11 +31931,11 @@ var ts; emit(baseTypeNode.expression); } write(")"); - if (node.kind === 204 /* ClassDeclaration */) { + if (node.kind === 211 /* ClassDeclaration */) { write(";"); } emitEnd(node); - if (node.kind === 204 /* ClassDeclaration */) { + if (node.kind === 211 /* ClassDeclaration */) { emitExportMemberAssignment(node); } if (languageVersion < 2 /* ES6 */ && node.parent === currentSourceFile && node.name) { @@ -29941,7 +32027,7 @@ var ts; else { decorators = member.decorators; // we only decorate the parameters here if this is a method - if (member.kind === 136 /* MethodDeclaration */) { + if (member.kind === 140 /* MethodDeclaration */) { functionLikeMember = member; } } @@ -29955,7 +32041,7 @@ var ts; // // The emit for a method is: // - // Object.defineProperty(C.prototype, "method", + // Object.defineProperty(C.prototype, "method", // __decorate([ // dec, // __param(0, dec2), @@ -29963,10 +32049,10 @@ var ts; // __metadata("design:paramtypes", [Object]), // __metadata("design:returntype", void 0) // ], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method"))); - // + // // The emit for an accessor is: // - // Object.defineProperty(C.prototype, "accessor", + // Object.defineProperty(C.prototype, "accessor", // __decorate([ // dec // ], C.prototype, "accessor", Object.getOwnPropertyDescriptor(C.prototype, "accessor"))); @@ -29979,7 +32065,7 @@ var ts; // writeLine(); emitStart(member); - if (member.kind !== 134 /* PropertyDeclaration */) { + if (member.kind !== 138 /* PropertyDeclaration */) { write("Object.defineProperty("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -30009,7 +32095,7 @@ var ts; write(", "); emitExpressionForPropertyName(member.name); emitEnd(member.name); - if (member.kind !== 134 /* PropertyDeclaration */) { + if (member.kind !== 138 /* PropertyDeclaration */) { write(", Object.getOwnPropertyDescriptor("); emitStart(member.name); emitClassMemberPrefix(node, member); @@ -30048,112 +32134,259 @@ var ts; } function shouldEmitTypeMetadata(node) { // This method determines whether to emit the "design:type" metadata based on the node's kind. - // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata + // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 136 /* MethodDeclaration */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 134 /* PropertyDeclaration */: + case 140 /* MethodDeclaration */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 138 /* PropertyDeclaration */: return true; } return false; } function shouldEmitReturnTypeMetadata(node) { // This method determines whether to emit the "design:returntype" metadata based on the node's kind. - // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata + // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 136 /* MethodDeclaration */: + case 140 /* MethodDeclaration */: return true; } return false; } function shouldEmitParamTypesMetadata(node) { // This method determines whether to emit the "design:paramtypes" metadata based on the node's kind. - // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata + // The caller should have already tested whether the node has decorators and whether the emitDecoratorMetadata // compiler option is set. switch (node.kind) { - case 204 /* ClassDeclaration */: - case 136 /* MethodDeclaration */: - case 139 /* SetAccessor */: + case 211 /* ClassDeclaration */: + case 140 /* MethodDeclaration */: + case 143 /* SetAccessor */: return true; } return false; } + /** Serializes the type of a declaration to an appropriate JS constructor value. Used by the __metadata decorator for a class member. */ + function emitSerializedTypeOfNode(node) { + // serialization of the type of a declaration uses the following rules: + // + // * The serialized type of a ClassDeclaration is "Function" + // * The serialized type of a ParameterDeclaration is the serialized type of its type annotation. + // * The serialized type of a PropertyDeclaration is the serialized type of its type annotation. + // * The serialized type of an AccessorDeclaration is the serialized type of the return type annotation of its getter or parameter type annotation of its setter. + // * The serialized type of any other FunctionLikeDeclaration is "Function". + // * The serialized type of any other node is "void 0". + // + // For rules on serializing type annotations, see `serializeTypeNode`. + switch (node.kind) { + case 211 /* ClassDeclaration */: + write("Function"); + return; + case 138 /* PropertyDeclaration */: + emitSerializedTypeNode(node.type); + return; + case 135 /* Parameter */: + emitSerializedTypeNode(node.type); + return; + case 142 /* GetAccessor */: + emitSerializedTypeNode(node.type); + return; + case 143 /* SetAccessor */: + emitSerializedTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); + return; + } + if (ts.isFunctionLike(node)) { + write("Function"); + return; + } + write("void 0"); + } + function emitSerializedTypeNode(node) { + switch (node.kind) { + case 100 /* VoidKeyword */: + write("void 0"); + return; + case 157 /* ParenthesizedType */: + emitSerializedTypeNode(node.type); + return; + case 149 /* FunctionType */: + case 150 /* ConstructorType */: + write("Function"); + return; + case 153 /* ArrayType */: + case 154 /* TupleType */: + write("Array"); + return; + case 147 /* TypePredicate */: + case 117 /* BooleanKeyword */: + write("Boolean"); + return; + case 127 /* StringKeyword */: + case 8 /* StringLiteral */: + write("String"); + return; + case 125 /* NumberKeyword */: + write("Number"); + return; + case 128 /* SymbolKeyword */: + write("Symbol"); + return; + case 148 /* TypeReference */: + emitSerializedTypeReferenceNode(node); + return; + case 151 /* TypeQuery */: + case 152 /* TypeLiteral */: + case 155 /* UnionType */: + case 156 /* IntersectionType */: + case 114 /* AnyKeyword */: + break; + default: + ts.Debug.fail("Cannot serialize unexpected type node."); + break; + } + write("Object"); + } + /** Serializes a TypeReferenceNode to an appropriate JS constructor value. Used by the __metadata decorator. */ + function emitSerializedTypeReferenceNode(node) { + var typeName = node.typeName; + var result = resolver.getTypeReferenceSerializationKind(node); + switch (result) { + case ts.TypeReferenceSerializationKind.Unknown: + var temp = createAndRecordTempVariable(0 /* Auto */); + 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 /* ES6 */) { + write("typeof Symbol === 'function' ? Symbol : Object"); + } + else { + write("Symbol"); + } + break; + case ts.TypeReferenceSerializationKind.TypeWithCallSignature: + write("Function"); + break; + case ts.TypeReferenceSerializationKind.ObjectType: + write("Object"); + break; + } + } + /** Serializes the parameter types of a function or the constructor of a class. Used by the __metadata decorator for a method or set accessor. */ + function emitSerializedParameterTypesOfNode(node) { + // serialization of parameter types uses the following rules: + // + // * If the declaration is a class, the parameters of the first constructor with a body are used. + // * If the declaration is function-like and has a body, the parameters of the function are used. + // + // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. + if (node) { + var valueDeclaration; + if (node.kind === 211 /* ClassDeclaration */) { + 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 === 153 /* ArrayType */) { + parameterType = parameterType.elementType; + } + else if (parameterType.kind === 148 /* TypeReference */ && parameterType.typeArguments && parameterType.typeArguments.length === 1) { + parameterType = parameterType.typeArguments[0]; + } + else { + parameterType = undefined; + } + emitSerializedTypeNode(parameterType); + } + else { + emitSerializedTypeOfNode(parameters[i]); + } + } + } + } + } + } + /** Serializes the return type of function. Used by the __metadata decorator for a method. */ + function emitSerializedReturnTypeOfNode(node) { + if (node && ts.isFunctionLike(node)) { + emitSerializedTypeNode(node.type); + return; + } + write("void 0"); + } function emitSerializedTypeMetadata(node, writeComma) { // This method emits the serialized type metadata for a decorator target. // The caller should have already tested whether the node has decorators. var argumentsWritten = 0; if (compilerOptions.emitDecoratorMetadata) { if (shouldEmitTypeMetadata(node)) { - var serializedType = resolver.serializeTypeOfNode(node); - if (serializedType) { - if (writeComma) { - write(", "); - } - writeLine(); - write("__metadata('design:type', "); - emitSerializedType(node, serializedType); - write(")"); - argumentsWritten++; + if (writeComma) { + write(", "); } + writeLine(); + write("__metadata('design:type', "); + emitSerializedTypeOfNode(node); + write(")"); + argumentsWritten++; } if (shouldEmitParamTypesMetadata(node)) { - var serializedTypes = resolver.serializeParameterTypesOfNode(node); - if (serializedTypes) { - if (writeComma || argumentsWritten) { - write(", "); - } - writeLine(); - write("__metadata('design:paramtypes', ["); - for (var i = 0; i < serializedTypes.length; ++i) { - if (i > 0) { - write(", "); - } - emitSerializedType(node, serializedTypes[i]); - } - write("])"); - argumentsWritten++; + if (writeComma || argumentsWritten) { + write(", "); } + writeLine(); + write("__metadata('design:paramtypes', ["); + emitSerializedParameterTypesOfNode(node); + write("])"); + argumentsWritten++; } if (shouldEmitReturnTypeMetadata(node)) { - var serializedType = resolver.serializeReturnTypeOfNode(node); - if (serializedType) { - if (writeComma || argumentsWritten) { - write(", "); - } - writeLine(); - write("__metadata('design:returntype', "); - emitSerializedType(node, serializedType); - write(")"); - argumentsWritten++; + if (writeComma || argumentsWritten) { + write(", "); } + writeLine(); + write("__metadata('design:returntype', "); + emitSerializedReturnTypeOfNode(node); + write(")"); + argumentsWritten++; } } return argumentsWritten; } - function serializeTypeNameSegment(location, path, index) { - switch (index) { - case 0: - return "typeof " + path[index] + " !== 'undefined' && " + path[index]; - case 1: - return serializeTypeNameSegment(location, path, index - 1) + "." + path[index]; - default: - var temp = createAndRecordTempVariable(0 /* Auto */).text; - return "(" + temp + " = " + serializeTypeNameSegment(location, path, index - 1) + ") && " + temp + "." + path[index]; - } - } - function emitSerializedType(location, name) { - if (typeof name === "string") { - write(name); - return; - } - else { - ts.Debug.assert(name.length > 0, "Invalid serialized type name"); - write("(" + serializeTypeNameSegment(location, name, name.length - 1) + ") || Object"); - } - } function emitInterfaceDeclaration(node) { emitOnlyPinnedOrTripleSlashComments(node); } @@ -30252,7 +32485,7 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 208 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 215 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -30261,7 +32494,7 @@ var ts; return ts.isInstantiatedModule(node, compilerOptions.preserveConstEnums || compilerOptions.isolatedModules); } function isModuleMergedWithES6Class(node) { - return languageVersion === 2 /* ES6 */ && !!(resolver.getNodeCheckFlags(node) & 2048 /* LexicalModuleMergesWithClass */); + return languageVersion === 2 /* ES6 */ && !!(resolver.getNodeCheckFlags(node) & 32768 /* LexicalModuleMergesWithClass */); } function emitModuleDeclaration(node) { // Emit only if this module is non-ambient. @@ -30288,7 +32521,7 @@ var ts; write(getGeneratedNameForNode(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 209 /* ModuleBlock */) { + if (node.body.kind === 216 /* ModuleBlock */) { var saveTempFlags = tempFlags; var saveTempVariables = tempVariables; tempFlags = 0; @@ -30321,7 +32554,7 @@ var ts; emitModuleMemberName(node); write(" = {}));"); emitEnd(node); - if (!isES6ExportedDeclaration(node) && node.name.kind === 65 /* Identifier */ && node.parent === currentSourceFile) { + if (!isES6ExportedDeclaration(node) && node.name.kind === 66 /* Identifier */ && node.parent === currentSourceFile) { if (compilerOptions.module === 4 /* System */ && (node.flags & 1 /* Export */)) { writeLine(); write(exportFunctionForFile + "(\""); @@ -30346,16 +32579,16 @@ var ts; } } function getNamespaceDeclarationNode(node) { - if (node.kind === 211 /* ImportEqualsDeclaration */) { + if (node.kind === 218 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 214 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 221 /* NamespaceImport */) { return importClause.namedBindings; } } function isDefaultImport(node) { - return node.kind === 212 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; + return node.kind === 219 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } function emitExportImportAssignments(node) { if (ts.isAliasSymbolDeclaration(node) && resolver.isValueAliasDeclaration(node)) { @@ -30383,7 +32616,7 @@ var ts; if (shouldEmitNamedBindings) { emitLeadingComments(node.importClause.namedBindings); emitStart(node.importClause.namedBindings); - if (node.importClause.namedBindings.kind === 214 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 221 /* NamespaceImport */) { write("* as "); emit(node.importClause.namedBindings.name); } @@ -30409,7 +32642,7 @@ var ts; } function emitExternalImportDeclaration(node) { if (ts.contains(externalImports, node)) { - var isExportedImport = node.kind === 211 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; + var isExportedImport = node.kind === 218 /* ImportEqualsDeclaration */ && (node.flags & 1 /* Export */) !== 0; var namespaceDeclaration = getNamespaceDeclarationNode(node); if (compilerOptions.module !== 2 /* AMD */) { emitLeadingComments(node); @@ -30428,7 +32661,7 @@ var ts; // import { x, y } from "foo" // import d, * as x from "foo" // import d, { x, y } from "foo" - var isNakedImport = 212 /* ImportDeclaration */ && !node.importClause; + var isNakedImport = 219 /* ImportDeclaration */ && !node.importClause; if (!isNakedImport) { write("var "); write(getGeneratedNameForNode(node)); @@ -30592,8 +32825,8 @@ var ts; write("export default "); var expression = node.expression; emit(expression); - if (expression.kind !== 203 /* FunctionDeclaration */ && - expression.kind !== 204 /* ClassDeclaration */) { + if (expression.kind !== 210 /* FunctionDeclaration */ && + expression.kind !== 211 /* ClassDeclaration */) { write(";"); } emitEnd(node); @@ -30629,7 +32862,7 @@ var ts; for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) { var node = _b[_a]; switch (node.kind) { - case 212 /* ImportDeclaration */: + case 219 /* ImportDeclaration */: if (!node.importClause || resolver.isReferencedAliasDeclaration(node.importClause, true)) { // import "mod" @@ -30639,13 +32872,13 @@ var ts; externalImports.push(node); } break; - case 211 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 222 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { + case 218 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 229 /* ExternalModuleReference */ && resolver.isReferencedAliasDeclaration(node)) { // import x = require("mod") where x is referenced externalImports.push(node); } break; - case 218 /* ExportDeclaration */: + case 225 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -30661,12 +32894,12 @@ var ts; // export { x, y } for (var _c = 0, _d = node.exportClause.elements; _c < _d.length; _c++) { var specifier = _d[_c]; - var name_21 = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name_21] || (exportSpecifiers[name_21] = [])).push(specifier); + var name_24 = (specifier.propertyName || specifier.name).text; + (exportSpecifiers[name_24] || (exportSpecifiers[name_24] = [])).push(specifier); } } break; - case 217 /* ExportAssignment */: + case 224 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; @@ -30692,10 +32925,10 @@ var ts; if (namespaceDeclaration && !isDefaultImport(node)) { return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, namespaceDeclaration.name); } - if (node.kind === 212 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 219 /* ImportDeclaration */ && node.importClause) { return getGeneratedNameForNode(node); } - if (node.kind === 218 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 225 /* ExportDeclaration */ && node.moduleSpecifier) { return getGeneratedNameForNode(node); } } @@ -30715,8 +32948,8 @@ var ts; for (var _a = 0; _a < externalImports.length; _a++) { var importNode = externalImports[_a]; // do not create variable declaration for exports and imports that lack import clause - var skipNode = importNode.kind === 218 /* ExportDeclaration */ || - (importNode.kind === 212 /* ImportDeclaration */ && !importNode.importClause); + var skipNode = importNode.kind === 225 /* ExportDeclaration */ || + (importNode.kind === 219 /* ImportDeclaration */ && !importNode.importClause); if (skipNode) { continue; } @@ -30749,7 +32982,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _a = 0; _a < externalImports.length; _a++) { var externalImport = externalImports[_a]; - if (externalImport.kind === 218 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 225 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -30781,7 +33014,7 @@ var ts; } for (var _d = 0; _d < externalImports.length; _d++) { var externalImport = externalImports[_d]; - if (externalImport.kind !== 218 /* ExportDeclaration */) { + if (externalImport.kind !== 225 /* ExportDeclaration */) { continue; } var exportDecl = externalImport; @@ -30824,8 +33057,8 @@ var ts; } function writeExportedName(node) { // do not record default exports - // they are local to module and never overwritten (explicitly skipped) by star export - if (node.kind !== 65 /* Identifier */ && node.flags & 256 /* Default */) { + // they are local to module and never overwritten (explicitly skipped) by star export + if (node.kind !== 66 /* Identifier */ && node.flags & 1024 /* Default */) { return; } if (started) { @@ -30836,7 +33069,7 @@ var ts; } writeLine(); write("'"); - if (node.kind === 65 /* Identifier */) { + if (node.kind === 66 /* Identifier */) { emitNodeWithoutSourceMap(node); } else { @@ -30846,7 +33079,7 @@ var ts; } } function processTopLevelVariableAndFunctionDeclarations(node) { - // per ES6 spec: + // per ES6 spec: // 15.2.1.16.4 ModuleDeclarationInstantiation() Concrete Method // - var declarations are initialized to undefined - 14.a.ii // - function/generator declarations are instantiated - 16.a.iv @@ -30865,12 +33098,12 @@ var ts; var seen = {}; for (var i = 0; i < hoistedVars.length; ++i) { var local = hoistedVars[i]; - var name_22 = local.kind === 65 /* Identifier */ + var name_25 = local.kind === 66 /* Identifier */ ? local : local.name; - if (name_22) { + if (name_25) { // do not emit duplicate entries (in case of declaration merging) in the list of hoisted variables - var text = ts.unescapeIdentifier(name_22.text); + var text = ts.unescapeIdentifier(name_25.text); if (ts.hasProperty(seen, text)) { continue; } @@ -30881,13 +33114,13 @@ var ts; if (i !== 0) { write(", "); } - if (local.kind === 204 /* ClassDeclaration */ || local.kind === 208 /* ModuleDeclaration */ || local.kind === 207 /* EnumDeclaration */) { + if (local.kind === 211 /* ClassDeclaration */ || local.kind === 215 /* ModuleDeclaration */ || local.kind === 214 /* EnumDeclaration */) { emitDeclarationName(local); } else { emit(local); } - var flags = ts.getCombinedNodeFlags(local.kind === 65 /* Identifier */ ? local.parent : local); + var flags = ts.getCombinedNodeFlags(local.kind === 66 /* Identifier */ ? local.parent : local); if (flags & 1 /* Export */) { if (!exportedDeclarations) { exportedDeclarations = []; @@ -30915,21 +33148,21 @@ var ts; if (node.flags & 2 /* Ambient */) { return; } - if (node.kind === 203 /* FunctionDeclaration */) { + if (node.kind === 210 /* FunctionDeclaration */) { if (!hoistedFunctionDeclarations) { hoistedFunctionDeclarations = []; } hoistedFunctionDeclarations.push(node); return; } - if (node.kind === 204 /* ClassDeclaration */) { + if (node.kind === 211 /* ClassDeclaration */) { if (!hoistedVars) { hoistedVars = []; } hoistedVars.push(node); return; } - if (node.kind === 207 /* EnumDeclaration */) { + if (node.kind === 214 /* EnumDeclaration */) { if (shouldEmitEnumDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -30938,7 +33171,7 @@ var ts; } return; } - if (node.kind === 208 /* ModuleDeclaration */) { + if (node.kind === 215 /* ModuleDeclaration */) { if (shouldEmitModuleDeclaration(node)) { if (!hoistedVars) { hoistedVars = []; @@ -30947,17 +33180,17 @@ var ts; } return; } - if (node.kind === 201 /* VariableDeclaration */ || node.kind === 155 /* BindingElement */) { + if (node.kind === 208 /* VariableDeclaration */ || node.kind === 160 /* BindingElement */) { if (shouldHoistVariable(node, false)) { - var name_23 = node.name; - if (name_23.kind === 65 /* Identifier */) { + var name_26 = node.name; + if (name_26.kind === 66 /* Identifier */) { if (!hoistedVars) { hoistedVars = []; } - hoistedVars.push(name_23); + hoistedVars.push(name_26); } else { - ts.forEachChild(name_23, visit); + ts.forEachChild(name_26, visit); } } return; @@ -30978,10 +33211,10 @@ var ts; // hoist variable if // - it is not block scoped // - it is top level block scoped - // if block scoped variables are nested in some another block then + // if block scoped variables are nested in some another block then // no other functions can use them except ones that are defined at least in the same block - return (ts.getCombinedNodeFlags(node) & 12288 /* BlockScoped */) === 0 || - ts.getEnclosingBlockScopeContainer(node).kind === 230 /* SourceFile */; + return (ts.getCombinedNodeFlags(node) & 49152 /* BlockScoped */) === 0 || + ts.getEnclosingBlockScopeContainer(node).kind === 245 /* SourceFile */; } function isCurrentFileSystemExternalModule() { return compilerOptions.module === 4 /* System */ && ts.isExternalModule(currentSourceFile); @@ -31052,21 +33285,21 @@ var ts; var parameterName = "_" + importVariableName; write("function (" + parameterName + ") {"); switch (importNode.kind) { - case 212 /* ImportDeclaration */: + case 219 /* ImportDeclaration */: if (!importNode.importClause) { // 'import "..."' case // module is imported only for side-effects, setter body will be empty break; } // fall-through - case 211 /* ImportEqualsDeclaration */: + case 218 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== ""); increaseIndent(); writeLine(); // save import into the local write(importVariableName + " = " + parameterName + ";"); writeLine(); - var defaultName = importNode.kind === 212 /* ImportDeclaration */ + var defaultName = importNode.kind === 219 /* ImportDeclaration */ ? importNode.importClause.name : importNode.name; if (defaultName) { @@ -31078,10 +33311,10 @@ var ts; emitExportMemberAssignments(defaultName); writeLine(); } - if (importNode.kind === 212 /* ImportDeclaration */ && + if (importNode.kind === 219 /* ImportDeclaration */ && importNode.importClause.namedBindings) { var namedBindings = importNode.importClause.namedBindings; - if (namedBindings.kind === 214 /* NamespaceImport */) { + if (namedBindings.kind === 221 /* NamespaceImport */) { // emit re-export for namespace // import * as n from 'foo' // export {n} @@ -31101,7 +33334,7 @@ var ts; } decreaseIndent(); break; - case 218 /* ExportDeclaration */: + case 225 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== ""); increaseIndent(); if (importNode.exportClause) { @@ -31144,10 +33377,10 @@ var ts; // - imports/exports are not emitted for system modules // - function declarations are not emitted because they were already hoisted switch (statement.kind) { - case 218 /* ExportDeclaration */: - case 212 /* ImportDeclaration */: - case 211 /* ImportEqualsDeclaration */: - case 203 /* FunctionDeclaration */: + case 225 /* ExportDeclaration */: + case 219 /* ImportDeclaration */: + case 218 /* ImportEqualsDeclaration */: + case 210 /* FunctionDeclaration */: continue; } writeLine(); @@ -31162,14 +33395,15 @@ var ts; // System modules has the following shape // System.register(['dep-1', ... 'dep-n'], function(exports) {/* module body function */}) // 'exports' here is a function 'exports(name: string, value: T): T' that is used to publish exported values. - // 'exports' returns its 'value' argument so in most cases expressions + // 'exports' returns its 'value' argument so in most cases expressions // that mutate exported values can be rewritten as: - // expr -> exports('name', expr). - // The only exception in this rule is postfix unary operators, + // expr -> exports('name', expr). + // The only exception in this rule is postfix unary operators, // see comment to 'emitPostfixUnaryExpression' for more details ts.Debug.assert(!exportFunctionForFile); // make sure that name of 'exports' function does not conflict with existing identifiers exportFunctionForFile = makeUniqueName("exports"); + writeLine(); write("System.register("); if (node.moduleName) { write("\"" + node.moduleName + "\", "); @@ -31203,12 +33437,12 @@ var ts; // 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 = []; // names of modules with corresponding parameter in the - // factory function. - var unaliasedModuleNames = []; // names of modules with no corresponding parameters in - // factory function. - var importAliasNames = []; // names of the parameters in the factory function; these - // parameters need to match the indexes of the corresponding + // names of modules with corresponding parameter in the factory function + var aliasedModuleNames = []; + // names of modules with no corresponding parameters in factory function + var unaliasedModuleNames = []; + var importAliasNames = []; // names of the parameters in the factory function; these + // parameters need to match the indexes of the corresponding // module names in aliasedModuleNames. // Fill in amd-dependency tags for (var _a = 0, _b = node.amdDependencies; _a < _b.length; _a++) { @@ -31301,7 +33535,7 @@ var ts; emitCaptureThisForNodeIfNecessary(node); emitLinesStartingAt(node.statements, startIndex); emitTempDeclarations(true); - // Emit exportDefault if it exists will happen as part + // Emit exportDefault if it exists will happen as part // or normal statement emit. } function emitExportEquals(emitAsReturn) { @@ -31314,6 +33548,91 @@ var ts; emitEnd(exportEquals); } } + function emitJsxElement(node) { + switch (compilerOptions.jsx) { + case 2 /* React */: + jsxEmitReact(node); + break; + case 1 /* Preserve */: + // Fall back to preserve if None was specified (we'll error earlier) + default: + jsxEmitPreserve(node); + break; + } + } + function trimReactWhitespace(node) { + var result = undefined; + var text = ts.getTextOfNode(node); + var firstNonWhitespace = 0; + var lastNonWhitespace = -1; + // JSX trims whitespace at the end and beginning of lines, except that the + // start/end of a tag is considered a start/end of a line only if that line is + // on the same line as the closing tag. See examples in tests/cases/conformance/jsx/tsxReactEmitWhitespace.tsx + 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; + } + return result; + } + function getTextToEmit(node) { + switch (compilerOptions.jsx) { + case 2 /* React */: + var text = trimReactWhitespace(node); + if (text.length === 0) { + return undefined; + } + else { + return text; + } + case 1 /* Preserve */: + default: + return ts.getTextOfNode(node, true); + } + } + function emitJsxText(node) { + switch (compilerOptions.jsx) { + case 2 /* React */: + write('"'); + write(trimReactWhitespace(node)); + write('"'); + break; + case 1 /* Preserve */: + default: + write(ts.getTextOfNode(node, true)); + break; + } + } + function emitJsxExpression(node) { + if (node.expression) { + switch (compilerOptions.jsx) { + case 1 /* Preserve */: + default: + write('{'); + emit(node.expression); + write('}'); + break; + case 2 /* React */: + emit(node.expression); + break; + } + } + } function emitDirectivePrologues(statements, startWithNewLine) { for (var i = 0; i < statements.length; ++i) { if (ts.isPrologueDirective(statements[i])) { @@ -31353,17 +33672,21 @@ var ts; writeLines(extendsHelper); extendsEmitted = true; } - if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 512 /* EmitDecorate */) { + if (!decorateEmitted && resolver.getNodeCheckFlags(node) & 16 /* EmitDecorate */) { writeLines(decorateHelper); if (compilerOptions.emitDecoratorMetadata) { writeLines(metadataHelper); } decorateEmitted = true; } - if (!paramEmitted && resolver.getNodeCheckFlags(node) & 1024 /* EmitParam */) { + if (!paramEmitted && resolver.getNodeCheckFlags(node) & 32 /* EmitParam */) { writeLines(paramHelper); paramEmitted = true; } + if (!awaiterEmitted && resolver.getNodeCheckFlags(node) & 64 /* EmitAwaiter */) { + writeLines(awaiterHelper); + awaiterEmitted = true; + } } if (ts.isExternalModule(node) || compilerOptions.isolatedModules) { if (languageVersion >= 2 /* ES6 */) { @@ -31413,31 +33736,31 @@ var ts; switch (node.kind) { // All of these entities are emitted in a specialized fashion. As such, we allow // the specialized methods for each to handle the comments on the nodes. - case 205 /* InterfaceDeclaration */: - case 203 /* FunctionDeclaration */: - case 212 /* ImportDeclaration */: - case 211 /* ImportEqualsDeclaration */: - case 206 /* TypeAliasDeclaration */: - case 217 /* ExportAssignment */: + case 212 /* InterfaceDeclaration */: + case 210 /* FunctionDeclaration */: + case 219 /* ImportDeclaration */: + case 218 /* ImportEqualsDeclaration */: + case 213 /* TypeAliasDeclaration */: + case 224 /* ExportAssignment */: return false; - case 183 /* VariableStatement */: + case 190 /* VariableStatement */: return shouldEmitLeadingAndTrailingCommentsForVariableStatement(node); - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: // Only emit the leading/trailing comments for a module if we're actually // emitting the module as well. return shouldEmitModuleDeclaration(node); - case 207 /* EnumDeclaration */: + case 214 /* EnumDeclaration */: // Only emit the leading/trailing comments for an enum if we're actually // emitting the module as well. return shouldEmitEnumDeclaration(node); } - // If this is the expression body of an arrow function that we're down-leveling, + // If this is the expression body of an arrow function that we're down-leveling, // then we don't want to emit comments when we emit the body. It will have already // been taken care of when we emitted the 'return' statement for the function // expression body. - if (node.kind !== 182 /* Block */ && + if (node.kind !== 189 /* Block */ && node.parent && - node.parent.kind === 166 /* ArrowFunction */ && + node.parent.kind === 171 /* ArrowFunction */ && node.parent.body === node && compilerOptions.target <= 1 /* ES5 */) { return false; @@ -31448,25 +33771,25 @@ var ts; function emitJavaScriptWorker(node) { // Check if the node can be emitted regardless of the ScriptTarget switch (node.kind) { - case 65 /* Identifier */: + case 66 /* Identifier */: return emitIdentifier(node); - case 131 /* Parameter */: + case 135 /* Parameter */: return emitParameter(node); - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: return emitMethod(node); - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: return emitAccessor(node); - case 93 /* ThisKeyword */: + case 94 /* ThisKeyword */: return emitThis(node); - case 91 /* SuperKeyword */: + case 92 /* SuperKeyword */: return emitSuper(node); - case 89 /* NullKeyword */: + case 90 /* NullKeyword */: return write("null"); - case 95 /* TrueKeyword */: + case 96 /* TrueKeyword */: return write("true"); - case 80 /* FalseKeyword */: + case 81 /* FalseKeyword */: return write("false"); case 7 /* NumericLiteral */: case 8 /* StringLiteral */: @@ -31476,131 +33799,142 @@ var ts; case 12 /* TemplateMiddle */: case 13 /* TemplateTail */: return emitLiteral(node); - case 174 /* TemplateExpression */: + case 180 /* TemplateExpression */: return emitTemplateExpression(node); - case 180 /* TemplateSpan */: + case 187 /* TemplateSpan */: return emitTemplateSpan(node); - case 128 /* QualifiedName */: + case 230 /* JsxElement */: + case 231 /* JsxSelfClosingElement */: + return emitJsxElement(node); + case 233 /* JsxText */: + return emitJsxText(node); + case 237 /* JsxExpression */: + return emitJsxExpression(node); + case 132 /* QualifiedName */: return emitQualifiedName(node); - case 153 /* ObjectBindingPattern */: + case 158 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 154 /* ArrayBindingPattern */: + case 159 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 155 /* BindingElement */: + case 160 /* BindingElement */: return emitBindingElement(node); - case 156 /* ArrayLiteralExpression */: + case 161 /* ArrayLiteralExpression */: return emitArrayLiteral(node); - case 157 /* ObjectLiteralExpression */: + case 162 /* ObjectLiteralExpression */: return emitObjectLiteral(node); - case 227 /* PropertyAssignment */: + case 242 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 228 /* ShorthandPropertyAssignment */: + case 243 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 129 /* ComputedPropertyName */: + case 133 /* ComputedPropertyName */: return emitComputedPropertyName(node); - case 158 /* PropertyAccessExpression */: + case 163 /* PropertyAccessExpression */: return emitPropertyAccess(node); - case 159 /* ElementAccessExpression */: + case 164 /* ElementAccessExpression */: return emitIndexedAccess(node); - case 160 /* CallExpression */: + case 165 /* CallExpression */: return emitCallExpression(node); - case 161 /* NewExpression */: + case 166 /* NewExpression */: return emitNewExpression(node); - case 162 /* TaggedTemplateExpression */: + case 167 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 163 /* TypeAssertionExpression */: + case 168 /* TypeAssertionExpression */: return emit(node.expression); - case 164 /* ParenthesizedExpression */: + case 186 /* AsExpression */: + return emit(node.expression); + case 169 /* ParenthesizedExpression */: return emitParenExpression(node); - case 203 /* FunctionDeclaration */: - case 165 /* FunctionExpression */: - case 166 /* ArrowFunction */: + case 210 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: return emitFunctionDeclaration(node); - case 167 /* DeleteExpression */: + case 172 /* DeleteExpression */: return emitDeleteExpression(node); - case 168 /* TypeOfExpression */: + case 173 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 169 /* VoidExpression */: + case 174 /* VoidExpression */: return emitVoidExpression(node); - case 170 /* PrefixUnaryExpression */: + case 175 /* AwaitExpression */: + return emitAwaitExpression(node); + case 176 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 171 /* PostfixUnaryExpression */: + case 177 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 172 /* BinaryExpression */: + case 178 /* BinaryExpression */: return emitBinaryExpression(node); - case 173 /* ConditionalExpression */: + case 179 /* ConditionalExpression */: return emitConditionalExpression(node); - case 176 /* SpreadElementExpression */: + case 182 /* SpreadElementExpression */: return emitSpreadElementExpression(node); - case 175 /* YieldExpression */: + case 181 /* YieldExpression */: return emitYieldExpression(node); - case 178 /* OmittedExpression */: + case 184 /* OmittedExpression */: return; - case 182 /* Block */: - case 209 /* ModuleBlock */: + case 189 /* Block */: + case 216 /* ModuleBlock */: return emitBlock(node); - case 183 /* VariableStatement */: + case 190 /* VariableStatement */: return emitVariableStatement(node); - case 184 /* EmptyStatement */: + case 191 /* EmptyStatement */: return write(";"); - case 185 /* ExpressionStatement */: + case 192 /* ExpressionStatement */: return emitExpressionStatement(node); - case 186 /* IfStatement */: + case 193 /* IfStatement */: return emitIfStatement(node); - case 187 /* DoStatement */: + case 194 /* DoStatement */: return emitDoStatement(node); - case 188 /* WhileStatement */: + case 195 /* WhileStatement */: return emitWhileStatement(node); - case 189 /* ForStatement */: + case 196 /* ForStatement */: return emitForStatement(node); - case 191 /* ForOfStatement */: - case 190 /* ForInStatement */: + case 198 /* ForOfStatement */: + case 197 /* ForInStatement */: return emitForInOrForOfStatement(node); - case 192 /* ContinueStatement */: - case 193 /* BreakStatement */: + case 199 /* ContinueStatement */: + case 200 /* BreakStatement */: return emitBreakOrContinueStatement(node); - case 194 /* ReturnStatement */: + case 201 /* ReturnStatement */: return emitReturnStatement(node); - case 195 /* WithStatement */: + case 202 /* WithStatement */: return emitWithStatement(node); - case 196 /* SwitchStatement */: + case 203 /* SwitchStatement */: return emitSwitchStatement(node); - case 223 /* CaseClause */: - case 224 /* DefaultClause */: + case 238 /* CaseClause */: + case 239 /* DefaultClause */: return emitCaseOrDefaultClause(node); - case 197 /* LabeledStatement */: + case 204 /* LabeledStatement */: return emitLabelledStatement(node); - case 198 /* ThrowStatement */: + case 205 /* ThrowStatement */: return emitThrowStatement(node); - case 199 /* TryStatement */: + case 206 /* TryStatement */: return emitTryStatement(node); - case 226 /* CatchClause */: + case 241 /* CatchClause */: return emitCatchClause(node); - case 200 /* DebuggerStatement */: + case 207 /* DebuggerStatement */: return emitDebuggerStatement(node); - case 201 /* VariableDeclaration */: + case 208 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 177 /* ClassExpression */: + case 183 /* ClassExpression */: return emitClassExpression(node); - case 204 /* ClassDeclaration */: + case 211 /* ClassDeclaration */: return emitClassDeclaration(node); - case 205 /* InterfaceDeclaration */: + case 212 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 207 /* EnumDeclaration */: + case 214 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 229 /* EnumMember */: + case 244 /* EnumMember */: return emitEnumMember(node); - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 212 /* ImportDeclaration */: + case 219 /* ImportDeclaration */: return emitImportDeclaration(node); - case 211 /* ImportEqualsDeclaration */: + case 218 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 218 /* ExportDeclaration */: + case 225 /* ExportDeclaration */: return emitExportDeclaration(node); - case 217 /* ExportAssignment */: + case 224 /* ExportAssignment */: return emitExportAssignment(node); - case 230 /* SourceFile */: + case 245 /* SourceFile */: return emitSourceFileNode(node); } } @@ -31632,7 +33966,7 @@ var ts; function getLeadingCommentsToEmit(node) { // Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments if (node.parent) { - if (node.parent.kind === 230 /* SourceFile */ || node.pos !== node.parent.pos) { + if (node.parent.kind === 245 /* SourceFile */ || node.pos !== node.parent.pos) { if (hasDetachedComments(node.pos)) { // get comments without detached comments return getLeadingCommentsWithoutDetachedComments(); @@ -31647,7 +33981,7 @@ var ts; function getTrailingCommentsToEmit(node) { // Emit the trailing comments only if the parent's pos doesn't match because parent should take care of emitting these comments if (node.parent) { - if (node.parent.kind === 230 /* SourceFile */ || node.end !== node.parent.end) { + if (node.parent.kind === 245 /* SourceFile */ || node.end !== node.parent.end) { return ts.getTrailingCommentRanges(currentSourceFile.text, node.end); } } @@ -31843,10 +34177,10 @@ var ts; }; } ts.createCompilerHost = createCompilerHost; - function getPreEmitDiagnostics(program, sourceFile) { - var diagnostics = program.getOptionsDiagnostics().concat(program.getSyntacticDiagnostics(sourceFile), program.getGlobalDiagnostics(), program.getSemanticDiagnostics(sourceFile)); + function getPreEmitDiagnostics(program, sourceFile, cancellationToken) { + var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (program.getCompilerOptions().declaration) { - diagnostics.concat(program.getDeclarationDiagnostics(sourceFile)); + diagnostics.concat(program.getDeclarationDiagnostics(sourceFile, cancellationToken)); } return ts.sortAndDeduplicateDiagnostics(diagnostics); } @@ -31947,10 +34281,15 @@ var ts; function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false)); } - function emit(sourceFile, writeFileCallback) { + function emit(sourceFile, writeFileCallback, cancellationToken) { + var _this = this; + return runWithCancellationToken(function () { return emitWorker(_this, sourceFile, writeFileCallback, cancellationToken); }); + } + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken) { // If the noEmitOnError flag is set, then check if we have any errors so far. If so, - // immediately bail out. - if (options.noEmitOnError && getPreEmitDiagnostics(this).length > 0) { + // immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we + // get any preEmit diagnostics, not just the ones + if (options.noEmitOnError && getPreEmitDiagnostics(program, undefined, cancellationToken).length > 0) { return { diagnostics: [], sourceMaps: undefined, emitSkipped: true }; } // Create the emit resolver outside of the "emitTime" tracking code below. That way @@ -31970,43 +34309,71 @@ var ts; function getSourceFile(fileName) { return filesByName.get(fileName); } - function getDiagnosticsHelper(sourceFile, getDiagnostics) { + function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) { if (sourceFile) { - return getDiagnostics(sourceFile); + return getDiagnostics(sourceFile, cancellationToken); } var allDiagnostics = []; ts.forEach(program.getSourceFiles(), function (sourceFile) { - ts.addRange(allDiagnostics, getDiagnostics(sourceFile)); + if (cancellationToken) { + cancellationToken.throwIfCancellationRequested(); + } + ts.addRange(allDiagnostics, getDiagnostics(sourceFile, cancellationToken)); }); return ts.sortAndDeduplicateDiagnostics(allDiagnostics); } - function getSyntacticDiagnostics(sourceFile) { - return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile); + function getSyntacticDiagnostics(sourceFile, cancellationToken) { + return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile, cancellationToken); } - function getSemanticDiagnostics(sourceFile) { - return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile); + function getSemanticDiagnostics(sourceFile, cancellationToken) { + return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile, cancellationToken); } - function getDeclarationDiagnostics(sourceFile) { - return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile); + function getDeclarationDiagnostics(sourceFile, cancellationToken) { + return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken); } - function getSyntacticDiagnosticsForFile(sourceFile) { + function getSyntacticDiagnosticsForFile(sourceFile, cancellationToken) { return sourceFile.parseDiagnostics; } - function getSemanticDiagnosticsForFile(sourceFile) { - var typeChecker = getDiagnosticsProducingTypeChecker(); - ts.Debug.assert(!!sourceFile.bindDiagnostics); - var bindDiagnostics = sourceFile.bindDiagnostics; - var checkDiagnostics = typeChecker.getDiagnostics(sourceFile); - var programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName); - return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics); - } - function getDeclarationDiagnosticsForFile(sourceFile) { - if (!ts.isDeclarationFile(sourceFile)) { - var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile); - // Don't actually write any files since we're just getting diagnostics. - var writeFile = function () { }; - return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile); + function runWithCancellationToken(func) { + try { + return func(); } + catch (e) { + if (e instanceof ts.OperationCanceledException) { + // We were canceled while performing the operation. Because our type checker + // might be a bad state, we need to throw it away. + // + // Note: we are overly agressive here. We do not actually *have* to throw away + // the "noDiagnosticsTypeChecker". However, for simplicity, i'd like to keep + // the lifetimes of these two TypeCheckers the same. Also, we generally only + // cancel when the user has made a change anyways. And, in that case, we (the + // program instance) will get thrown away anyways. So trying to keep one of + // these type checkers alive doesn't serve much purpose. + noDiagnosticsTypeChecker = undefined; + diagnosticsProducingTypeChecker = undefined; + } + throw e; + } + } + function getSemanticDiagnosticsForFile(sourceFile, cancellationToken) { + return runWithCancellationToken(function () { + var typeChecker = getDiagnosticsProducingTypeChecker(); + ts.Debug.assert(!!sourceFile.bindDiagnostics); + var bindDiagnostics = sourceFile.bindDiagnostics; + var checkDiagnostics = typeChecker.getDiagnostics(sourceFile, cancellationToken); + var programDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName); + return bindDiagnostics.concat(checkDiagnostics).concat(programDiagnostics); + }); + } + function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) { + return runWithCancellationToken(function () { + if (!ts.isDeclarationFile(sourceFile)) { + var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); + // Don't actually write any files since we're just getting diagnostics. + var writeFile_1 = function () { }; + return ts.getDeclarationDiagnostics(getEmitHost(writeFile_1), resolver, sourceFile); + } + }); } function getOptionsDiagnostics() { var allDiagnostics = []; @@ -32027,7 +34394,6 @@ var ts; function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { var start; var length; - var extensions; var diagnosticArgument; if (refEnd !== undefined && refPos !== undefined) { start = refPos; @@ -32132,7 +34498,7 @@ var ts; } function processImportedModules(file, basePath) { ts.forEach(file.statements, function (node) { - if (node.kind === 212 /* ImportDeclaration */ || node.kind === 211 /* ImportEqualsDeclaration */ || node.kind === 218 /* ExportDeclaration */) { + if (node.kind === 219 /* ImportDeclaration */ || node.kind === 218 /* ImportEqualsDeclaration */ || node.kind === 225 /* ExportDeclaration */) { var moduleNameExpr = ts.getExternalModuleName(node); if (moduleNameExpr && moduleNameExpr.kind === 8 /* StringLiteral */) { var moduleNameText = moduleNameExpr.text; @@ -32153,9 +34519,9 @@ var ts; } } } - else if (node.kind === 208 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { + else if (node.kind === 215 /* ModuleDeclaration */ && node.name.kind === 8 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || ts.isDeclarationFile(file))) { // TypeScript 1.0 spec (April 2014): 12.1.6 - // An AmbientExternalModuleDeclaration declares an external module. + // An AmbientExternalModuleDeclaration declares an external module. // This type of declaration is permitted only in the global module. // The StringLiteral must specify a top - level external module name. // Relative external module names are not permitted @@ -32166,7 +34532,7 @@ var ts; var moduleName = nameLiteral.text; if (moduleName) { // TypeScript 1.0 spec (April 2014): 12.1.6 - // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules + // An ExternalImportDeclaration in anAmbientExternalModuleDeclaration may reference other external modules // only through top - level external module names. Relative external module names are not permitted. var searchName = ts.normalizePath(ts.combinePaths(basePath, moduleName)); ts.forEach(ts.supportedExtensions, function (extension) { return findModuleSourceFile(searchName + extension, nameLiteral); }); @@ -32284,7 +34650,7 @@ var ts; } } else if (firstExternalModuleSourceFile && languageVersion < 2 /* ES6 */ && !options.module) { - // We cannot use createDiagnosticFromNode because nodes do not have parents yet + // We cannot use createDiagnosticFromNode because nodes do not have parents yet var span = ts.getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator); diagnostics.add(ts.createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_unless_the_module_flag_is_provided)); } @@ -32307,7 +34673,7 @@ var ts; commonSourceDirectory = computeCommonSourceDirectory(files); } if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== ts.directorySeparator) { - // Make sure directory path ends with directory separator so this string can directly + // Make sure directory path ends with directory separator so this string can directly // used to replace with "" to get the relative path of the source file and the relative path doesn't // start with / making it rooted path commonSourceDirectory += ts.directorySeparator; @@ -32325,6 +34691,10 @@ var ts; !options.experimentalDecorators) { diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified)); } + if (options.experimentalAsyncFunctions && + options.target !== 2 /* ES6 */) { + diagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_experimentalAsyncFunctions_cannot_be_specified_when_targeting_ES5_or_lower)); + } } } ts.createProgram = createProgram; @@ -32369,6 +34739,16 @@ var ts; name: "inlineSources", type: "boolean" }, + { + name: "jsx", + type: { + "preserve": 1 /* Preserve */, + "react": 2 /* React */ + }, + paramType: ts.Diagnostics.KIND, + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, + error: ts.Diagnostics.Argument_for_jsx_must_be_preserve_or_react + }, { name: "listFiles", type: "boolean" @@ -32524,6 +34904,11 @@ 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", @@ -32585,10 +34970,10 @@ var ts; break; // If not a primitive, the possible types are specified in what is effectively a map of options. default: - var map = opt.type; + var map_2 = opt.type; var key = (args[i++] || "").toLowerCase(); - if (ts.hasProperty(map, key)) { - options[opt.name] = map[key]; + if (ts.hasProperty(map_2, key)) { + options[opt.name] = map_2[key]; } else { errors.push(ts.createCompilerDiagnostic(opt.error)); @@ -32645,8 +35030,9 @@ var ts; * @param fileName The path to the config file */ function readConfigFile(fileName) { + var text = ''; try { - var text = ts.sys.readFile(fileName); + text = ts.sys.readFile(fileName); } catch (e) { return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message) }; @@ -32731,11 +35117,22 @@ var ts; } else { var exclude = json["exclude"] instanceof Array ? ts.map(json["exclude"], ts.normalizeSlashes) : undefined; - var sysFiles = host.readDirectory(basePath, ".ts", exclude); + var sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)); for (var i = 0; i < sysFiles.length; i++) { - var name = sysFiles[i]; - if (!ts.fileExtensionIs(name, ".d.ts") || !ts.contains(sysFiles, name.substr(0, name.length - 5) + ".ts")) { - fileNames.push(name); + var name_27 = sysFiles[i]; + if (ts.fileExtensionIs(name_27, ".d.ts")) { + var baseName = name_27.substr(0, name_27.length - ".d.ts".length); + if (!ts.contains(sysFiles, baseName + ".tsx") && !ts.contains(sysFiles, baseName + ".ts")) { + fileNames.push(name_27); + } + } + else if (ts.fileExtensionIs(name_27, ".ts")) { + if (!ts.contains(sysFiles, name_27 + "x")) { + fileNames.push(name_27); + } + } + else { + fileNames.push(name_27); } } } @@ -32816,7 +35213,7 @@ var ts; } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 166 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 171 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; @@ -32828,7 +35225,7 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 182 /* Block */: + case 189 /* Block */: if (!ts.isFunctionBlock(n)) { var parent_8 = n.parent; var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); @@ -32836,18 +35233,18 @@ var ts; // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collaps the block, but consider its hint span // to be the entire span of the parent. - if (parent_8.kind === 187 /* DoStatement */ || - parent_8.kind === 190 /* ForInStatement */ || - parent_8.kind === 191 /* ForOfStatement */ || - parent_8.kind === 189 /* ForStatement */ || - parent_8.kind === 186 /* IfStatement */ || - parent_8.kind === 188 /* WhileStatement */ || - parent_8.kind === 195 /* WithStatement */ || - parent_8.kind === 226 /* CatchClause */) { + if (parent_8.kind === 194 /* DoStatement */ || + parent_8.kind === 197 /* ForInStatement */ || + parent_8.kind === 198 /* ForOfStatement */ || + parent_8.kind === 196 /* ForStatement */ || + parent_8.kind === 193 /* IfStatement */ || + parent_8.kind === 195 /* WhileStatement */ || + parent_8.kind === 202 /* WithStatement */ || + parent_8.kind === 241 /* CatchClause */) { addOutliningSpan(parent_8, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent_8.kind === 199 /* TryStatement */) { + if (parent_8.kind === 206 /* TryStatement */) { // Could be the try-block, or the finally-block. var tryStatement = parent_8; if (tryStatement.tryBlock === n) { @@ -32855,7 +35252,7 @@ var ts; break; } else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 81 /* FinallyKeyword */, sourceFile); + var finallyKeyword = ts.findChildOfKind(tryStatement, 82 /* FinallyKeyword */, sourceFile); if (finallyKeyword) { addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); break; @@ -32874,23 +35271,23 @@ var ts; break; } // Fallthrough. - case 209 /* ModuleBlock */: { + case 216 /* ModuleBlock */: { var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 204 /* ClassDeclaration */: - case 205 /* InterfaceDeclaration */: - case 207 /* EnumDeclaration */: - case 157 /* ObjectLiteralExpression */: - case 210 /* CaseBlock */: { + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: + case 214 /* EnumDeclaration */: + case 162 /* ObjectLiteralExpression */: + case 217 /* CaseBlock */: { var openBrace = ts.findChildOfKind(n, 14 /* OpenBraceToken */, sourceFile); var closeBrace = ts.findChildOfKind(n, 15 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 156 /* ArrayLiteralExpression */: + case 161 /* ArrayLiteralExpression */: var openBracket = ts.findChildOfKind(n, 18 /* OpenBracketToken */, sourceFile); var closeBracket = ts.findChildOfKind(n, 19 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); @@ -32918,12 +35315,12 @@ var ts; ts.forEach(program.getSourceFiles(), function (sourceFile) { cancellationToken.throwIfCancellationRequested(); var nameToDeclarations = sourceFile.getNamedDeclarations(); - for (var name_24 in nameToDeclarations) { - var declarations = ts.getProperty(nameToDeclarations, name_24); + for (var name_28 in nameToDeclarations) { + var declarations = ts.getProperty(nameToDeclarations, name_28); if (declarations) { // First do a quick check to see if the name of the declaration matches the // last portion of the (possibly) dotted name they're searching for. - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_24); + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name_28); if (!matches) { continue; } @@ -32936,14 +35333,14 @@ var ts; if (!containers) { return undefined; } - matches = patternMatcher.getMatches(containers, name_24); + matches = patternMatcher.getMatches(containers, name_28); if (!matches) { continue; } } var fileName = sourceFile.fileName; var matchKind = bestMatchKind(matches); - rawItems.push({ name: name_24, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); + rawItems.push({ name: name_28, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); } } } @@ -32967,7 +35364,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 65 /* Identifier */ || + if (node.kind === 66 /* Identifier */ || node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) { return node.text; @@ -32981,7 +35378,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 129 /* ComputedPropertyName */) { + else if (declaration.name.kind === 133 /* ComputedPropertyName */) { return tryAddComputedPropertyName(declaration.name.expression, containers, true); } else { @@ -33002,7 +35399,7 @@ var ts; } return true; } - if (expression.kind === 158 /* PropertyAccessExpression */) { + if (expression.kind === 163 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -33015,7 +35412,7 @@ var ts; var containers = []; // First, if we started with a computed property name, then add all but the last // portion into the container array. - if (declaration.name.kind === 129 /* ComputedPropertyName */) { + if (declaration.name.kind === 133 /* ComputedPropertyName */) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { return undefined; } @@ -33091,17 +35488,17 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: // If we have a module declared as A.B.C, it is more "intuitive" // to say it only has a single layer of depth do { current = current.parent; - } while (current.kind === 208 /* ModuleDeclaration */); + } while (current.kind === 215 /* ModuleDeclaration */); // fall through - case 204 /* ClassDeclaration */: - case 207 /* EnumDeclaration */: - case 205 /* InterfaceDeclaration */: - case 203 /* FunctionDeclaration */: + case 211 /* ClassDeclaration */: + case 214 /* EnumDeclaration */: + case 212 /* InterfaceDeclaration */: + case 210 /* FunctionDeclaration */: indent++; } current = current.parent; @@ -33112,21 +35509,21 @@ var ts; var childNodes = []; function visit(node) { switch (node.kind) { - case 183 /* VariableStatement */: + case 190 /* VariableStatement */: ts.forEach(node.declarationList.declarations, visit); break; - case 153 /* ObjectBindingPattern */: - case 154 /* ArrayBindingPattern */: + case 158 /* ObjectBindingPattern */: + case 159 /* ArrayBindingPattern */: ts.forEach(node.elements, visit); break; - case 218 /* ExportDeclaration */: + case 225 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 212 /* ImportDeclaration */: + case 219 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -33138,7 +35535,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 214 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 221 /* NamespaceImport */) { childNodes.push(importClause.namedBindings); } else { @@ -33147,21 +35544,21 @@ var ts; } } break; - case 155 /* BindingElement */: - case 201 /* VariableDeclaration */: + case 160 /* BindingElement */: + case 208 /* VariableDeclaration */: if (ts.isBindingPattern(node.name)) { visit(node.name); break; } // Fall through - case 204 /* ClassDeclaration */: - case 207 /* EnumDeclaration */: - case 205 /* InterfaceDeclaration */: - case 208 /* ModuleDeclaration */: - case 203 /* FunctionDeclaration */: - case 211 /* ImportEqualsDeclaration */: - case 216 /* ImportSpecifier */: - case 220 /* ExportSpecifier */: + case 211 /* ClassDeclaration */: + case 214 /* EnumDeclaration */: + case 212 /* InterfaceDeclaration */: + case 215 /* ModuleDeclaration */: + case 210 /* FunctionDeclaration */: + case 218 /* ImportEqualsDeclaration */: + case 223 /* ImportSpecifier */: + case 227 /* ExportSpecifier */: childNodes.push(node); break; } @@ -33209,17 +35606,17 @@ var ts; for (var _i = 0; _i < nodes.length; _i++) { var node = nodes[_i]; switch (node.kind) { - case 204 /* ClassDeclaration */: - case 207 /* EnumDeclaration */: - case 205 /* InterfaceDeclaration */: + case 211 /* ClassDeclaration */: + case 214 /* EnumDeclaration */: + case 212 /* InterfaceDeclaration */: topLevelNodes.push(node); break; - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 203 /* FunctionDeclaration */: + case 210 /* FunctionDeclaration */: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -33230,12 +35627,12 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 203 /* FunctionDeclaration */) { + if (functionDeclaration.kind === 210 /* FunctionDeclaration */) { // A function declaration is 'top level' if it contains any function declarations // within it. - if (functionDeclaration.body && functionDeclaration.body.kind === 182 /* Block */) { + if (functionDeclaration.body && functionDeclaration.body.kind === 189 /* Block */) { // Proper function declarations can only have identifier names - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 203 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 210 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { return true; } // Or if it is not parented by another function. i.e all functions @@ -33272,7 +35669,7 @@ var ts; } function merge(target, source) { // First, add any spans in the source to the target. - target.spans.push.apply(target.spans, source.spans); + ts.addRange(target.spans, source.spans); if (source.childItems) { if (!target.childItems) { target.childItems = []; @@ -33295,44 +35692,44 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 131 /* Parameter */: + case 135 /* Parameter */: if (ts.isBindingPattern(node.name)) { break; } - if ((node.flags & 499 /* Modifier */) === 0) { + if ((node.flags & 2035 /* Modifier */) === 0) { return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 138 /* GetAccessor */: + case 142 /* GetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); - case 139 /* SetAccessor */: + case 143 /* SetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 142 /* IndexSignature */: + case 146 /* IndexSignature */: return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 229 /* EnumMember */: + case 244 /* EnumMember */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 140 /* CallSignature */: + case 144 /* CallSignature */: return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 141 /* ConstructSignature */: + case 145 /* ConstructSignature */: return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 203 /* FunctionDeclaration */: + case 210 /* FunctionDeclaration */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 201 /* VariableDeclaration */: - case 155 /* BindingElement */: + case 208 /* VariableDeclaration */: + case 160 /* BindingElement */: var variableDeclarationNode; - var name_25; - if (node.kind === 155 /* BindingElement */) { - name_25 = node.name; + var name_29; + if (node.kind === 160 /* BindingElement */) { + name_29 = node.name; variableDeclarationNode = node; // binding elements are added only for variable declarations // bubble up to the containing variable declaration - while (variableDeclarationNode && variableDeclarationNode.kind !== 201 /* VariableDeclaration */) { + while (variableDeclarationNode && variableDeclarationNode.kind !== 208 /* VariableDeclaration */) { variableDeclarationNode = variableDeclarationNode.parent; } ts.Debug.assert(variableDeclarationNode !== undefined); @@ -33340,24 +35737,24 @@ var ts; else { ts.Debug.assert(!ts.isBindingPattern(node.name)); variableDeclarationNode = node; - name_25 = node.name; + name_29 = node.name; } if (ts.isConst(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_25), ts.ScriptElementKind.constElement); + return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.constElement); } else if (ts.isLet(variableDeclarationNode)) { - return createItem(node, getTextOfNode(name_25), ts.ScriptElementKind.letElement); + return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.letElement); } else { - return createItem(node, getTextOfNode(name_25), ts.ScriptElementKind.variableElement); + return createItem(node, getTextOfNode(name_29), ts.ScriptElementKind.variableElement); } - case 137 /* Constructor */: + case 141 /* Constructor */: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); - case 220 /* ExportSpecifier */: - case 216 /* ImportSpecifier */: - case 211 /* ImportEqualsDeclaration */: - case 213 /* ImportClause */: - case 214 /* NamespaceImport */: + case 227 /* ExportSpecifier */: + case 223 /* ImportSpecifier */: + case 218 /* ImportEqualsDeclaration */: + case 220 /* ImportClause */: + case 221 /* NamespaceImport */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.alias); } return undefined; @@ -33387,17 +35784,17 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 230 /* SourceFile */: + case 245 /* SourceFile */: return createSourceFileItem(node); - case 204 /* ClassDeclaration */: + case 211 /* ClassDeclaration */: return createClassItem(node); - case 207 /* EnumDeclaration */: + case 214 /* EnumDeclaration */: return createEnumItem(node); - case 205 /* InterfaceDeclaration */: + case 212 /* InterfaceDeclaration */: return createIterfaceItem(node); - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: return createModuleItem(node); - case 203 /* FunctionDeclaration */: + case 210 /* FunctionDeclaration */: return createFunctionItem(node); } return undefined; @@ -33409,7 +35806,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 208 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 215 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -33421,7 +35818,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 === 182 /* Block */) { + if (node.body && node.body.kind === 189 /* Block */) { var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); return getNavigationBarItem(!node.name ? "default" : node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } @@ -33442,14 +35839,14 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 137 /* Constructor */ && member; + return member.kind === 141 /* Constructor */ && member; }); // Add the constructor parameters in as children of the class (for property parameters). // Note that *all non-binding pattern named* parameters will be added to the nodes array, but parameters that // are not properties will be filtered out later by createChildItem. var nodes = removeDynamicallyNamedProperties(node); if (constructor) { - nodes.push.apply(nodes, ts.filter(constructor.parameters, function (p) { return !ts.isBindingPattern(p.name); })); + ts.addRange(nodes, ts.filter(constructor.parameters, function (p) { return !ts.isBindingPattern(p.name); })); } childItems = getItemsWorker(sortNodes(nodes), createChildItem); } @@ -33466,7 +35863,7 @@ var ts; } } function removeComputedProperties(node) { - return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 129 /* ComputedPropertyName */; }); + return ts.filter(node.members, function (member) { return member.name === undefined || member.name.kind !== 133 /* ComputedPropertyName */; }); } /** * Like removeComputedProperties, but retains the properties with well known symbol names @@ -33475,13 +35872,13 @@ var ts; return ts.filter(node.members, function (member) { return !ts.hasDynamicName(member); }); } function getInnermostModule(node) { - while (node.body.kind === 208 /* ModuleDeclaration */) { + while (node.body.kind === 215 /* ModuleDeclaration */) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 230 /* SourceFile */ + return node.kind === 245 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromBounds(node.getStart(), node.getEnd()); } @@ -34276,15 +36673,15 @@ var ts; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function createJavaScriptSignatureHelpItems(argumentInfo) { - if (argumentInfo.invocation.kind !== 160 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 165 /* CallExpression */) { return undefined; } // See if we can find some symbol with the call expression name that has call signatures. var callExpression = argumentInfo.invocation; var expression = callExpression.expression; - var name = expression.kind === 65 /* Identifier */ + var name = expression.kind === 66 /* Identifier */ ? expression - : expression.kind === 158 /* PropertyAccessExpression */ + : expression.kind === 163 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -34317,7 +36714,7 @@ var ts; * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind === 160 /* CallExpression */ || node.parent.kind === 161 /* NewExpression */) { + if (node.parent.kind === 165 /* CallExpression */ || node.parent.kind === 166 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: // 1. The token introduces a list, and should begin a sig help session @@ -34370,25 +36767,25 @@ var ts; }; } } - else if (node.kind === 10 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 162 /* TaggedTemplateExpression */) { + else if (node.kind === 10 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 167 /* TaggedTemplateExpression */) { // Check if we're actually inside the template; // otherwise we'll fall out and return undefined. if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, 0); } } - else if (node.kind === 11 /* TemplateHead */ && node.parent.parent.kind === 162 /* TaggedTemplateExpression */) { + else if (node.kind === 11 /* TemplateHead */ && node.parent.parent.kind === 167 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 174 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 180 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } - else if (node.parent.kind === 180 /* TemplateSpan */ && node.parent.parent.parent.kind === 162 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 187 /* TemplateSpan */ && node.parent.parent.parent.kind === 167 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 174 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 180 /* TemplateExpression */); // If we're just after a template tail, don't show signature help. if (node.kind === 13 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { return undefined; @@ -34506,7 +36903,7 @@ var ts; // // This is because a Missing node has no width. However, what we actually want is to include trivia // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. - if (template.kind === 174 /* TemplateExpression */) { + if (template.kind === 180 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -34515,7 +36912,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 230 /* SourceFile */; n = n.parent) { + for (var n = node; n.kind !== 245 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -34572,23 +36969,23 @@ var ts; var prefixDisplayParts = []; var suffixDisplayParts = []; if (callTargetDisplayParts) { - prefixDisplayParts.push.apply(prefixDisplayParts, callTargetDisplayParts); + ts.addRange(prefixDisplayParts, callTargetDisplayParts); } if (isTypeParameterList) { prefixDisplayParts.push(ts.punctuationPart(24 /* LessThanToken */)); var typeParameters = candidateSignature.typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(25 /* GreaterThanToken */)); + suffixDisplayParts.push(ts.punctuationPart(26 /* GreaterThanToken */)); var parameterParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation); }); - suffixDisplayParts.push.apply(suffixDisplayParts, parameterParts); + ts.addRange(suffixDisplayParts, parameterParts); } else { var typeParameterParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); }); - prefixDisplayParts.push.apply(prefixDisplayParts, typeParameterParts); + ts.addRange(prefixDisplayParts, typeParameterParts); prefixDisplayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); var parameters = candidateSignature.parameters; signatureHelpParameters = parameters.length > 0 ? ts.map(parameters, createSignatureHelpParameterForParameter) : emptyArray; @@ -34597,7 +36994,7 @@ var ts; var returnTypeParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation); }); - suffixDisplayParts.push.apply(suffixDisplayParts, returnTypeParts); + ts.addRange(suffixDisplayParts, returnTypeParts); return { isVariadic: candidateSignature.hasRestParameter, prefixDisplayParts: prefixDisplayParts, @@ -34716,40 +37113,40 @@ var ts; return false; } switch (n.kind) { - case 204 /* ClassDeclaration */: - case 205 /* InterfaceDeclaration */: - case 207 /* EnumDeclaration */: - case 157 /* ObjectLiteralExpression */: - case 153 /* ObjectBindingPattern */: - case 148 /* TypeLiteral */: - case 182 /* Block */: - case 209 /* ModuleBlock */: - case 210 /* CaseBlock */: + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: + case 214 /* EnumDeclaration */: + case 162 /* ObjectLiteralExpression */: + case 158 /* ObjectBindingPattern */: + case 152 /* TypeLiteral */: + case 189 /* Block */: + case 216 /* ModuleBlock */: + case 217 /* CaseBlock */: return nodeEndsWith(n, 15 /* CloseBraceToken */, sourceFile); - case 226 /* CatchClause */: + case 241 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 161 /* NewExpression */: + case 166 /* NewExpression */: if (!n.arguments) { return true; } // fall through - case 160 /* CallExpression */: - case 164 /* ParenthesizedExpression */: - case 152 /* ParenthesizedType */: + case 165 /* CallExpression */: + case 169 /* ParenthesizedExpression */: + case 157 /* ParenthesizedType */: return nodeEndsWith(n, 17 /* CloseParenToken */, sourceFile); - case 145 /* FunctionType */: - case 146 /* ConstructorType */: + case 149 /* FunctionType */: + case 150 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 137 /* Constructor */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 203 /* FunctionDeclaration */: - case 165 /* FunctionExpression */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 141 /* ConstructSignature */: - case 140 /* CallSignature */: - case 166 /* ArrowFunction */: + case 141 /* Constructor */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 210 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 145 /* ConstructSignature */: + case 144 /* CallSignature */: + case 171 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -34759,63 +37156,63 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 17 /* CloseParenToken */, sourceFile); - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 186 /* IfStatement */: + case 193 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 185 /* ExpressionStatement */: + case 192 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile); - case 156 /* ArrayLiteralExpression */: - case 154 /* ArrayBindingPattern */: - case 159 /* ElementAccessExpression */: - case 129 /* ComputedPropertyName */: - case 150 /* TupleType */: + case 161 /* ArrayLiteralExpression */: + case 159 /* ArrayBindingPattern */: + case 164 /* ElementAccessExpression */: + case 133 /* ComputedPropertyName */: + case 154 /* TupleType */: return nodeEndsWith(n, 19 /* CloseBracketToken */, sourceFile); - case 142 /* IndexSignature */: + case 146 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 19 /* CloseBracketToken */, sourceFile); - case 223 /* CaseClause */: - case 224 /* DefaultClause */: + case 238 /* CaseClause */: + case 239 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicitly always consider them non-completed return false; - case 189 /* ForStatement */: - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: - case 188 /* WhileStatement */: + case 196 /* ForStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: + case 195 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 187 /* DoStatement */: + case 194 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - var hasWhileKeyword = findChildOfKind(n, 100 /* WhileKeyword */, sourceFile); + var hasWhileKeyword = findChildOfKind(n, 101 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { return nodeEndsWith(n, 17 /* CloseParenToken */, sourceFile); } return isCompletedNode(n.statement, sourceFile); - case 147 /* TypeQuery */: + case 151 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 168 /* TypeOfExpression */: - case 167 /* DeleteExpression */: - case 169 /* VoidExpression */: - case 175 /* YieldExpression */: - case 176 /* SpreadElementExpression */: + case 173 /* TypeOfExpression */: + case 172 /* DeleteExpression */: + case 174 /* VoidExpression */: + case 181 /* YieldExpression */: + case 182 /* SpreadElementExpression */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 162 /* TaggedTemplateExpression */: + case 167 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 174 /* TemplateExpression */: + case 180 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 180 /* TemplateSpan */: + case 187 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 170 /* PrefixUnaryExpression */: + case 176 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 172 /* BinaryExpression */: + case 178 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 173 /* ConditionalExpression */: + case 179 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -34871,7 +37268,7 @@ var ts; // for the position of the relevant node (or comma). var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { // find syntax list that covers the span of the node - if (c.kind === 253 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 268 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -35005,7 +37402,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 230 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 245 /* SourceFile */); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. // Try to find the rightmost token in the file without filtering. @@ -35041,6 +37438,8 @@ var ts; result.push(ts.ScriptElementKindModifier.publicMemberModifier); if (flags & 128 /* Static */) result.push(ts.ScriptElementKindModifier.staticModifier); + if (flags & 256 /* Abstract */) + result.push(ts.ScriptElementKindModifier.abstractModifier); if (flags & 1 /* Export */) result.push(ts.ScriptElementKindModifier.exportedModifier); if (ts.isInAmbientContext(node)) @@ -35049,21 +37448,21 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 144 /* TypeReference */ || node.kind === 160 /* CallExpression */) { + if (node.kind === 148 /* TypeReference */ || node.kind === 165 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 204 /* ClassDeclaration */ || node.kind === 205 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 211 /* ClassDeclaration */ || node.kind === 212 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 127 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 131 /* LastToken */; } ts.isToken = isToken; function isWord(kind) { - return kind === 65 /* Identifier */ || ts.isKeyword(kind); + return kind === 66 /* Identifier */ || ts.isKeyword(kind); } ts.isWord = isWord; function isPropertyName(kind) { @@ -35074,7 +37473,7 @@ var ts; } ts.isComment = isComment; function isPunctuation(kind) { - return 14 /* FirstPunctuation */ <= kind && kind <= 64 /* LastPunctuation */; + return 14 /* FirstPunctuation */ <= kind && kind <= 65 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { @@ -35084,9 +37483,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 108 /* PublicKeyword */: - case 106 /* PrivateKeyword */: - case 107 /* ProtectedKeyword */: + case 109 /* PublicKeyword */: + case 107 /* PrivateKeyword */: + case 108 /* ProtectedKeyword */: return true; } return false; @@ -35114,7 +37513,7 @@ var ts; var ts; (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 131 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 135 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -35278,6 +37677,41 @@ var ts; }); } ts.signatureToDisplayParts = signatureToDisplayParts; + function getDeclaredName(typeChecker, symbol, location) { + // If this is an export or import specifier it could have been renamed using the 'as' syntax. + // If so we want to search for whatever is under the cursor. + if (isImportOrExportSpecifierName(location)) { + return location.getText(); + } + // Try to get the local symbol if we're dealing with an 'export default' + // since that symbol has the "true" name. + var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); + var name = typeChecker.symbolToString(localExportDefaultSymbol || symbol); + return name; + } + ts.getDeclaredName = getDeclaredName; + function isImportOrExportSpecifierName(location) { + return location.parent && + (location.parent.kind === 223 /* ImportSpecifier */ || location.parent.kind === 227 /* ExportSpecifier */) && + location.parent.propertyName === location; + } + ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; + /** + * Strip off existed single quotes or double quotes from a given string + * + * @return non-quoted string + */ + function stripQuotes(name) { + var length = name.length; + if (length >= 2 && + name.charCodeAt(0) === name.charCodeAt(length - 1) && + (name.charCodeAt(0) === 34 /* doubleQuote */ || name.charCodeAt(0) === 39 /* singleQuote */)) { + return name.substring(1, length - 1); + } + ; + return name; + } + ts.stripQuotes = stripQuotes; })(ts || (ts = {})); /// /// @@ -35356,11 +37790,11 @@ var ts; function shouldRescanGreaterThanToken(node) { if (node) { switch (node.kind) { - case 27 /* GreaterThanEqualsToken */: - case 60 /* GreaterThanGreaterThanEqualsToken */: - case 61 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 42 /* GreaterThanGreaterThanGreaterThanToken */: - case 41 /* GreaterThanGreaterThanToken */: + case 28 /* GreaterThanEqualsToken */: + case 61 /* GreaterThanGreaterThanEqualsToken */: + case 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 43 /* GreaterThanGreaterThanGreaterThanToken */: + case 42 /* GreaterThanGreaterThanToken */: return true; } } @@ -35374,7 +37808,7 @@ var ts; container.kind === 13 /* TemplateTail */; } function startsWithSlashToken(t) { - return t === 36 /* SlashToken */ || t === 57 /* SlashEqualsToken */; + return t === 37 /* SlashToken */ || t === 58 /* SlashEqualsToken */; } function readTokenInfo(n) { if (!isOnToken()) { @@ -35410,7 +37844,7 @@ var ts; scanner.scan(); } var currentToken = scanner.getToken(); - if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 25 /* GreaterThanToken */) { + if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 26 /* GreaterThanToken */) { currentToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === currentToken); lastScanAction = 1 /* RescanGreaterThanToken */; @@ -35742,17 +38176,17 @@ var ts; this.IgnoreAfterLineComment = new formatting.Rule(formatting.RuleDescriptor.create3(2 /* SingleLineCommentTrivia */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create1(1 /* Ignore */)); // Space after keyword but not before ; or : or ? this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 22 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 51 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 50 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(51 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); - this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(50 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); - this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(50 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52 /* ColonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 51 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* ColonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 2 /* Space */)); + this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(51 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsConditionalOperatorContext), 2 /* Space */)); + this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(51 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Space after }. this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* CloseBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied - this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* CloseBraceToken */, 76 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* CloseBraceToken */, 100 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* CloseBraceToken */, 77 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(15 /* CloseBraceToken */, 101 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(15 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 19 /* CloseBracketToken */, 23 /* CommaToken */, 22 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // No space for indexer and dot this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 20 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); @@ -35765,10 +38199,10 @@ var ts; this.FunctionOpenBraceLeftTokenRange = formatting.Shared.TokenRange.AnyIncludingMultilineComments; this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([65 /* Identifier */, 3 /* MultiLineCommentTrivia */]); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([66 /* Identifier */, 3 /* MultiLineCommentTrivia */]); this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a control flow construct - this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 75 /* DoKeyword */, 96 /* TryKeyword */, 81 /* FinallyKeyword */, 76 /* ElseKeyword */]); + this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 76 /* DoKeyword */, 97 /* TryKeyword */, 82 /* FinallyKeyword */, 77 /* ElseKeyword */]); this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(14 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 2 /* Space */)); @@ -35782,71 +38216,71 @@ var ts; // Prefix operators generally shouldn't have a space between // them and their target unary expression. 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 /* Delete */)); - this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(38 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(39 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 38 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 39 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(39 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(40 /* MinusMinusToken */, formatting.Shared.TokenRange.UnaryPredecrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostincrementExpressions, 39 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 40 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(38 /* PlusPlusToken */, 33 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(33 /* PlusToken */, 33 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(33 /* PlusToken */, 38 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(39 /* MinusMinusToken */, 34 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(34 /* MinusToken */, 34 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(34 /* MinusToken */, 39 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(39 /* PlusPlusToken */, 34 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(34 /* PlusToken */, 34 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(34 /* PlusToken */, 39 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(40 /* MinusMinusToken */, 35 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* MinusToken */, 35 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(35 /* MinusToken */, 40 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([98 /* VarKeyword */, 94 /* ThrowKeyword */, 88 /* NewKeyword */, 74 /* DeleteKeyword */, 90 /* ReturnKeyword */, 97 /* TypeOfKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([104 /* LetKeyword */, 70 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([99 /* VarKeyword */, 95 /* ThrowKeyword */, 89 /* NewKeyword */, 75 /* DeleteKeyword */, 91 /* ReturnKeyword */, 98 /* TypeOfKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterLetConstInVariableDeclaration = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([105 /* LetKeyword */, 71 /* ConstKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), 2 /* Space */)); this.NoSpaceBeforeOpenParenInFuncCall = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); - this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(83 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(84 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(99 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(90 /* ReturnKeyword */, 22 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(100 /* VoidKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 2 /* Space */)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(91 /* ReturnKeyword */, 22 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] - this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 75 /* DoKeyword */, 76 /* ElseKeyword */, 67 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2 /* Space */)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 76 /* DoKeyword */, 77 /* ElseKeyword */, 68 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 2 /* Space */)); // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([96 /* TryKeyword */, 81 /* FinallyKeyword */]), 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([97 /* TryKeyword */, 82 /* FinallyKeyword */]), 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // get x() {} // set x(val) {} - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([116 /* GetKeyword */, 122 /* SetKeyword */]), 65 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([120 /* GetKeyword */, 126 /* SetKeyword */]), 66 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. this.SpaceBeforeBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.BinaryKeywordOperators), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); this.SpaceAfterBinaryKeywordOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.BinaryKeywordOperators, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); // TypeScript-specific higher priority rules // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses - this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(114 /* ConstructorKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(118 /* ConstructorKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Use of module as a function call. e.g.: import m2 = module("m2"); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([118 /* ModuleKeyword */, 120 /* RequireKeyword */]), 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([122 /* ModuleKeyword */, 124 /* RequireKeyword */]), 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([69 /* ClassKeyword */, 115 /* DeclareKeyword */, 77 /* EnumKeyword */, 78 /* ExportKeyword */, 79 /* ExtendsKeyword */, 116 /* GetKeyword */, 102 /* ImplementsKeyword */, 85 /* ImportKeyword */, 103 /* InterfaceKeyword */, 118 /* ModuleKeyword */, 119 /* NamespaceKeyword */, 106 /* PrivateKeyword */, 108 /* PublicKeyword */, 122 /* SetKeyword */, 109 /* StaticKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([79 /* ExtendsKeyword */, 102 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([112 /* AbstractKeyword */, 70 /* ClassKeyword */, 119 /* DeclareKeyword */, 74 /* DefaultKeyword */, 78 /* EnumKeyword */, 79 /* ExportKeyword */, 80 /* ExtendsKeyword */, 120 /* GetKeyword */, 103 /* ImplementsKeyword */, 86 /* ImportKeyword */, 104 /* InterfaceKeyword */, 122 /* ModuleKeyword */, 123 /* NamespaceKeyword */, 107 /* PrivateKeyword */, 109 /* PublicKeyword */, 108 /* ProtectedKeyword */, 126 /* SetKeyword */, 110 /* StaticKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([80 /* ExtendsKeyword */, 103 /* ImplementsKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(8 /* StringLiteral */, 14 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); // Lambda expressions - this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(32 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(33 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); // Optional parameters and let args - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(21 /* DotDotDotToken */, 65 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(50 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 23 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(21 /* DotDotDotToken */, 66 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(51 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([17 /* CloseParenToken */, 23 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); // generics this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 24 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* CloseParenToken */, 24 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* LessThanToken */, formatting.Shared.TokenRange.TypeNames), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 25 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); - this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(25 /* GreaterThanToken */, formatting.Shared.TokenRange.FromTokens([16 /* OpenParenToken */, 18 /* OpenBracketToken */, 25 /* GreaterThanToken */, 23 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 26 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); + this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(26 /* GreaterThanToken */, formatting.Shared.TokenRange.FromTokens([16 /* OpenParenToken */, 18 /* OpenBracketToken */, 26 /* GreaterThanToken */, 23 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 8 /* Delete */)); // Remove spaces in empty interface literals. e.g.: x: {} this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(14 /* OpenBraceToken */, 15 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 8 /* Delete */)); // decorators - this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 52 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(52 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([65 /* Identifier */, 78 /* ExportKeyword */, 73 /* DefaultKeyword */, 69 /* ClassKeyword */, 109 /* StaticKeyword */, 108 /* PublicKeyword */, 106 /* PrivateKeyword */, 107 /* ProtectedKeyword */, 116 /* GetKeyword */, 122 /* SetKeyword */, 18 /* OpenBracketToken */, 35 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); - this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(83 /* FunctionKeyword */, 35 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); - this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(35 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([65 /* Identifier */, 16 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); - this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(110 /* YieldKeyword */, 35 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); - this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([110 /* YieldKeyword */, 35 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 53 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(53 /* AtToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterDecorator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.Any, formatting.Shared.TokenRange.FromTokens([112 /* AbstractKeyword */, 66 /* Identifier */, 79 /* ExportKeyword */, 74 /* DefaultKeyword */, 70 /* ClassKeyword */, 110 /* StaticKeyword */, 109 /* PublicKeyword */, 107 /* PrivateKeyword */, 108 /* ProtectedKeyword */, 120 /* GetKeyword */, 126 /* SetKeyword */, 18 /* OpenBracketToken */, 36 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); + this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(84 /* FunctionKeyword */, 36 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); + this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(36 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([66 /* Identifier */, 16 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(111 /* YieldKeyword */, 36 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8 /* Delete */)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([111 /* YieldKeyword */, 36 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ @@ -35933,14 +38367,14 @@ var ts; this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenParenToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); this.NoSpaceBeforeCloseParen = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 8 /* Delete */)); // Insert space after function keyword for anonymous functions - this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(83 /* FunctionKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); - this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(83 /* FunctionKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(84 /* FunctionKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(84 /* FunctionKeyword */, 16 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); } Rules.prototype.getRuleName = function (rule) { var o = this; - for (var name_26 in o) { - if (o[name_26] === rule) { - return name_26; + for (var name_30 in o) { + if (o[name_30] === rule) { + return name_30; } } throw new Error("Unknown rule"); @@ -35949,37 +38383,38 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 189 /* ForStatement */; + return context.contextNode.kind === 196 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 172 /* BinaryExpression */: - case 173 /* ConditionalExpression */: - case 143 /* TypePredicate */: + case 178 /* BinaryExpression */: + case 179 /* ConditionalExpression */: + case 186 /* AsExpression */: + case 147 /* TypePredicate */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 155 /* BindingElement */: + case 160 /* BindingElement */: // equals in type X = ... - case 206 /* TypeAliasDeclaration */: + case 213 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 211 /* ImportEqualsDeclaration */: + case 218 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 201 /* VariableDeclaration */: + case 208 /* VariableDeclaration */: // equal in p = 0; - case 131 /* Parameter */: - case 229 /* EnumMember */: - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: - return context.currentTokenSpan.kind === 53 /* EqualsToken */ || context.nextTokenSpan.kind === 53 /* EqualsToken */; + case 135 /* Parameter */: + case 244 /* EnumMember */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: + return context.currentTokenSpan.kind === 54 /* EqualsToken */ || context.nextTokenSpan.kind === 54 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 190 /* ForInStatement */: - return context.currentTokenSpan.kind === 86 /* InKeyword */ || context.nextTokenSpan.kind === 86 /* InKeyword */; + case 197 /* ForInStatement */: + return context.currentTokenSpan.kind === 87 /* InKeyword */ || context.nextTokenSpan.kind === 87 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 191 /* ForOfStatement */: - return context.currentTokenSpan.kind === 127 /* OfKeyword */ || context.nextTokenSpan.kind === 127 /* OfKeyword */; + case 198 /* ForOfStatement */: + return context.currentTokenSpan.kind === 131 /* OfKeyword */ || context.nextTokenSpan.kind === 131 /* OfKeyword */; } return false; }; @@ -35987,7 +38422,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 173 /* ConditionalExpression */; + return context.contextNode.kind === 179 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -36031,92 +38466,92 @@ var ts; return true; } switch (node.kind) { - case 182 /* Block */: - case 210 /* CaseBlock */: - case 157 /* ObjectLiteralExpression */: - case 209 /* ModuleBlock */: + case 189 /* Block */: + case 217 /* CaseBlock */: + case 162 /* ObjectLiteralExpression */: + case 216 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 203 /* FunctionDeclaration */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 210 /* FunctionDeclaration */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: //case SyntaxKind.MemberFunctionDeclaration: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: ///case SyntaxKind.MethodSignature: - case 140 /* CallSignature */: - case 165 /* FunctionExpression */: - case 137 /* Constructor */: - case 166 /* ArrowFunction */: + case 144 /* CallSignature */: + case 170 /* FunctionExpression */: + case 141 /* Constructor */: + case 171 /* ArrowFunction */: //case SyntaxKind.ConstructorDeclaration: //case SyntaxKind.SimpleArrowFunctionExpression: //case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 205 /* InterfaceDeclaration */: + case 212 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 203 /* FunctionDeclaration */ || context.contextNode.kind === 165 /* FunctionExpression */; + return context.contextNode.kind === 210 /* FunctionDeclaration */ || context.contextNode.kind === 170 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 204 /* ClassDeclaration */: - case 205 /* InterfaceDeclaration */: - case 207 /* EnumDeclaration */: - case 148 /* TypeLiteral */: - case 208 /* ModuleDeclaration */: + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: + case 214 /* EnumDeclaration */: + case 152 /* TypeLiteral */: + case 215 /* ModuleDeclaration */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 204 /* ClassDeclaration */: - case 208 /* ModuleDeclaration */: - case 207 /* EnumDeclaration */: - case 182 /* Block */: - case 226 /* CatchClause */: - case 209 /* ModuleBlock */: - case 196 /* SwitchStatement */: + case 211 /* ClassDeclaration */: + case 215 /* ModuleDeclaration */: + case 214 /* EnumDeclaration */: + case 189 /* Block */: + case 241 /* CatchClause */: + case 216 /* ModuleBlock */: + case 203 /* SwitchStatement */: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 186 /* IfStatement */: - case 196 /* SwitchStatement */: - case 189 /* ForStatement */: - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: - case 188 /* WhileStatement */: - case 199 /* TryStatement */: - case 187 /* DoStatement */: - case 195 /* WithStatement */: + case 193 /* IfStatement */: + case 203 /* SwitchStatement */: + case 196 /* ForStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: + case 195 /* WhileStatement */: + case 206 /* TryStatement */: + case 194 /* DoStatement */: + case 202 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 226 /* CatchClause */: + case 241 /* CatchClause */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 157 /* ObjectLiteralExpression */; + return context.contextNode.kind === 162 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 160 /* CallExpression */; + return context.contextNode.kind === 165 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 161 /* NewExpression */; + return context.contextNode.kind === 166 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -36140,38 +38575,38 @@ var ts; while (ts.isExpression(node)) { node = node.parent; } - return node.kind === 132 /* Decorator */; + return node.kind === 136 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 202 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 209 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 208 /* ModuleDeclaration */; + return context.contextNode.kind === 215 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 148 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 152 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; }; Rules.IsTypeArgumentOrParameter = function (token, parent) { - if (token.kind !== 24 /* LessThanToken */ && token.kind !== 25 /* GreaterThanToken */) { + if (token.kind !== 24 /* LessThanToken */ && token.kind !== 26 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 144 /* TypeReference */: - case 204 /* ClassDeclaration */: - case 205 /* InterfaceDeclaration */: - case 203 /* FunctionDeclaration */: - case 165 /* FunctionExpression */: - case 166 /* ArrowFunction */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 140 /* CallSignature */: - case 141 /* ConstructSignature */: - case 160 /* CallExpression */: - case 161 /* NewExpression */: + case 148 /* TypeReference */: + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: + case 210 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 144 /* CallSignature */: + case 145 /* ConstructSignature */: + case 165 /* CallExpression */: + case 166 /* NewExpression */: return true; default: return false; @@ -36182,10 +38617,10 @@ var ts; Rules.IsTypeArgumentOrParameter(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 99 /* VoidKeyword */ && context.currentTokenParent.kind === 169 /* VoidExpression */; + return context.currentTokenSpan.kind === 100 /* VoidKeyword */ && context.currentTokenParent.kind === 174 /* VoidExpression */; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 175 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 181 /* YieldExpression */ && context.contextNode.expression !== undefined; }; return Rules; })(); @@ -36209,7 +38644,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 127 /* LastToken */ + 1; + this.mapRowLength = 131 /* LastToken */ + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); //new Array(this.mapRowLength * this.mapRowLength); // This array is used only during construction of the rulesbucket in the map var rulesBucketConstructionStateList = new Array(this.map.length); //new Array(this.map.length); @@ -36404,7 +38839,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0 /* FirstToken */; token <= 127 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 131 /* LastToken */; token++) { result.push(token); } return result; @@ -36446,17 +38881,17 @@ var ts; }; TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(66 /* FirstKeyword */, 127 /* LastKeyword */); - TokenRange.BinaryOperators = TokenRange.FromRange(24 /* FirstBinaryOperator */, 64 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([86 /* InKeyword */, 87 /* InstanceOfKeyword */, 127 /* OfKeyword */, 117 /* IsKeyword */]); - TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([38 /* PlusPlusToken */, 39 /* MinusMinusToken */, 47 /* TildeToken */, 46 /* ExclamationToken */]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([7 /* NumericLiteral */, 65 /* Identifier */, 16 /* OpenParenToken */, 18 /* OpenBracketToken */, 14 /* OpenBraceToken */, 93 /* ThisKeyword */, 88 /* NewKeyword */]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([65 /* Identifier */, 16 /* OpenParenToken */, 93 /* ThisKeyword */, 88 /* NewKeyword */]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([65 /* Identifier */, 17 /* CloseParenToken */, 19 /* CloseBracketToken */, 88 /* NewKeyword */]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([65 /* Identifier */, 16 /* OpenParenToken */, 93 /* ThisKeyword */, 88 /* NewKeyword */]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([65 /* Identifier */, 17 /* CloseParenToken */, 19 /* CloseBracketToken */, 88 /* NewKeyword */]); + TokenRange.Keywords = TokenRange.FromRange(67 /* FirstKeyword */, 131 /* LastKeyword */); + TokenRange.BinaryOperators = TokenRange.FromRange(24 /* FirstBinaryOperator */, 65 /* LastBinaryOperator */); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([87 /* InKeyword */, 88 /* InstanceOfKeyword */, 131 /* OfKeyword */, 113 /* AsKeyword */, 121 /* IsKeyword */]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([39 /* PlusPlusToken */, 40 /* MinusMinusToken */, 48 /* TildeToken */, 47 /* ExclamationToken */]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([7 /* NumericLiteral */, 66 /* Identifier */, 16 /* OpenParenToken */, 18 /* OpenBracketToken */, 14 /* OpenBraceToken */, 94 /* ThisKeyword */, 89 /* NewKeyword */]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([66 /* Identifier */, 16 /* OpenParenToken */, 94 /* ThisKeyword */, 89 /* NewKeyword */]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([66 /* Identifier */, 17 /* CloseParenToken */, 19 /* CloseBracketToken */, 89 /* NewKeyword */]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([66 /* Identifier */, 16 /* OpenParenToken */, 94 /* ThisKeyword */, 89 /* NewKeyword */]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([66 /* Identifier */, 17 /* CloseParenToken */, 19 /* CloseBracketToken */, 89 /* NewKeyword */]); TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([65 /* Identifier */, 121 /* NumberKeyword */, 123 /* StringKeyword */, 113 /* BooleanKeyword */, 124 /* SymbolKeyword */, 99 /* VoidKeyword */, 112 /* AnyKeyword */]); + TokenRange.TypeNames = TokenRange.FromTokens([66 /* Identifier */, 125 /* NumberKeyword */, 127 /* StringKeyword */, 117 /* BooleanKeyword */, 128 /* SymbolKeyword */, 100 /* VoidKeyword */, 114 /* AnyKeyword */]); return TokenRange; })(); Shared.TokenRange = TokenRange; @@ -36660,17 +39095,17 @@ var ts; // i.e. parent is class declaration with the list of members and node is one of members. function isListElement(parent, node) { switch (parent.kind) { - case 204 /* ClassDeclaration */: - case 205 /* InterfaceDeclaration */: + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 182 /* Block */ && ts.rangeContainsRange(body.statements, node); - case 230 /* SourceFile */: - case 182 /* Block */: - case 209 /* ModuleBlock */: + return body && body.kind === 189 /* Block */ && ts.rangeContainsRange(body.statements, node); + case 245 /* SourceFile */: + case 189 /* Block */: + case 216 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 226 /* CatchClause */: + case 241 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -36843,9 +39278,9 @@ var ts; // - source file // - switch\default clauses if (isSomeBlock(parent.kind) || - parent.kind === 230 /* SourceFile */ || - parent.kind === 223 /* CaseClause */ || - parent.kind === 224 /* DefaultClause */) { + parent.kind === 245 /* SourceFile */ || + parent.kind === 238 /* CaseClause */ || + parent.kind === 239 /* DefaultClause */) { indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } else { @@ -36881,19 +39316,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 204 /* ClassDeclaration */: return 69 /* ClassKeyword */; - case 205 /* InterfaceDeclaration */: return 103 /* InterfaceKeyword */; - case 203 /* FunctionDeclaration */: return 83 /* FunctionKeyword */; - case 207 /* EnumDeclaration */: return 207 /* EnumDeclaration */; - case 138 /* GetAccessor */: return 116 /* GetKeyword */; - case 139 /* SetAccessor */: return 122 /* SetKeyword */; - case 136 /* MethodDeclaration */: + case 211 /* ClassDeclaration */: return 70 /* ClassKeyword */; + case 212 /* InterfaceDeclaration */: return 104 /* InterfaceKeyword */; + case 210 /* FunctionDeclaration */: return 84 /* FunctionKeyword */; + case 214 /* EnumDeclaration */: return 214 /* EnumDeclaration */; + case 142 /* GetAccessor */: return 120 /* GetKeyword */; + case 143 /* SetAccessor */: return 126 /* SetKeyword */; + case 140 /* MethodDeclaration */: if (node.asteriskToken) { - return 35 /* AsteriskToken */; + return 36 /* AsteriskToken */; } // fall-through - case 134 /* PropertyDeclaration */: - case 131 /* Parameter */: + case 138 /* PropertyDeclaration */: + case 135 /* Parameter */: return node.name.kind; } } @@ -36924,9 +39359,9 @@ var ts; case 15 /* CloseBraceToken */: case 18 /* OpenBracketToken */: case 19 /* CloseBracketToken */: - case 76 /* ElseKeyword */: - case 100 /* WhileKeyword */: - case 52 /* AtToken */: + case 77 /* ElseKeyword */: + case 101 /* WhileKeyword */: + case 53 /* AtToken */: return indentation; default: // if token line equals to the line of containing node (this is a first token in the node) - use node indentation @@ -37026,7 +39461,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 132 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 136 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; @@ -37349,20 +39784,20 @@ var ts; } function isSomeBlock(kind) { switch (kind) { - case 182 /* Block */: - case 209 /* ModuleBlock */: + case 189 /* Block */: + case 216 /* ModuleBlock */: return true; } return false; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 137 /* Constructor */: - case 203 /* FunctionDeclaration */: - case 165 /* FunctionExpression */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 166 /* ArrowFunction */: + case 141 /* Constructor */: + case 210 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 171 /* ArrowFunction */: if (node.typeParameters === list) { return 24 /* LessThanToken */; } @@ -37370,8 +39805,8 @@ var ts; return 16 /* OpenParenToken */; } break; - case 160 /* CallExpression */: - case 161 /* NewExpression */: + case 165 /* CallExpression */: + case 166 /* NewExpression */: if (node.typeArguments === list) { return 24 /* LessThanToken */; } @@ -37379,7 +39814,7 @@ var ts; return 16 /* OpenParenToken */; } break; - case 144 /* TypeReference */: + case 148 /* TypeReference */: if (node.typeArguments === list) { return 24 /* LessThanToken */; } @@ -37391,7 +39826,7 @@ var ts; case 16 /* OpenParenToken */: return 17 /* CloseParenToken */; case 24 /* LessThanToken */: - return 25 /* GreaterThanToken */; + return 26 /* GreaterThanToken */; } return 0 /* Unknown */; } @@ -37478,7 +39913,7 @@ var ts; return 0; } var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line; - if (precedingToken.kind === 23 /* CommaToken */ && precedingToken.parent.kind !== 172 /* BinaryExpression */) { + if (precedingToken.kind === 23 /* CommaToken */ && precedingToken.parent.kind !== 178 /* BinaryExpression */) { // previous token is comma that separates items in list - find the previous item and try to derive indentation from it var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1 /* Unknown */) { @@ -37597,7 +40032,7 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && - (parent.kind === 230 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 245 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -37630,8 +40065,8 @@ var ts; return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 186 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 76 /* ElseKeyword */, sourceFile); + if (parent.kind === 193 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 77 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -37642,23 +40077,23 @@ var ts; function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 144 /* TypeReference */: + case 148 /* TypeReference */: if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { return node.parent.typeArguments; } break; - case 157 /* ObjectLiteralExpression */: + case 162 /* ObjectLiteralExpression */: return node.parent.properties; - case 156 /* ArrayLiteralExpression */: + case 161 /* ArrayLiteralExpression */: return node.parent.elements; - case 203 /* FunctionDeclaration */: - case 165 /* FunctionExpression */: - case 166 /* ArrowFunction */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 140 /* CallSignature */: - case 141 /* ConstructSignature */: { + case 210 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 144 /* CallSignature */: + case 145 /* ConstructSignature */: { var start = node.getStart(sourceFile); if (node.parent.typeParameters && ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { @@ -37669,8 +40104,8 @@ var ts; } break; } - case 161 /* NewExpression */: - case 160 /* CallExpression */: { + case 166 /* NewExpression */: + case 165 /* CallExpression */: { var start = node.getStart(sourceFile); if (node.parent.typeArguments && ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { @@ -37700,8 +40135,8 @@ var ts; if (node.kind === 17 /* CloseParenToken */) { return -1 /* Unknown */; } - if (node.parent && (node.parent.kind === 160 /* CallExpression */ || - node.parent.kind === 161 /* NewExpression */) && + if (node.parent && (node.parent.kind === 165 /* CallExpression */ || + node.parent.kind === 166 /* NewExpression */) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -37719,10 +40154,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 160 /* CallExpression */: - case 161 /* NewExpression */: - case 158 /* PropertyAccessExpression */: - case 159 /* ElementAccessExpression */: + case 165 /* CallExpression */: + case 166 /* NewExpression */: + case 163 /* PropertyAccessExpression */: + case 164 /* ElementAccessExpression */: node = node.expression; break; default: @@ -37787,28 +40222,28 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 204 /* ClassDeclaration */: - case 205 /* InterfaceDeclaration */: - case 207 /* EnumDeclaration */: - case 156 /* ArrayLiteralExpression */: - case 182 /* Block */: - case 209 /* ModuleBlock */: - case 157 /* ObjectLiteralExpression */: - case 148 /* TypeLiteral */: - case 150 /* TupleType */: - case 210 /* CaseBlock */: - case 224 /* DefaultClause */: - case 223 /* CaseClause */: - case 164 /* ParenthesizedExpression */: - case 160 /* CallExpression */: - case 161 /* NewExpression */: - case 183 /* VariableStatement */: - case 201 /* VariableDeclaration */: - case 217 /* ExportAssignment */: - case 194 /* ReturnStatement */: - case 173 /* ConditionalExpression */: - case 154 /* ArrayBindingPattern */: - case 153 /* ObjectBindingPattern */: + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: + case 214 /* EnumDeclaration */: + case 161 /* ArrayLiteralExpression */: + case 189 /* Block */: + case 216 /* ModuleBlock */: + case 162 /* ObjectLiteralExpression */: + case 152 /* TypeLiteral */: + case 154 /* TupleType */: + case 217 /* CaseBlock */: + case 239 /* DefaultClause */: + case 238 /* CaseClause */: + case 169 /* ParenthesizedExpression */: + case 165 /* CallExpression */: + case 166 /* NewExpression */: + case 190 /* VariableStatement */: + case 208 /* VariableDeclaration */: + case 224 /* ExportAssignment */: + case 201 /* ReturnStatement */: + case 179 /* ConditionalExpression */: + case 159 /* ArrayBindingPattern */: + case 158 /* ObjectBindingPattern */: return true; } return false; @@ -37818,22 +40253,22 @@ var ts; return true; } switch (parent) { - case 187 /* DoStatement */: - case 188 /* WhileStatement */: - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: - case 189 /* ForStatement */: - case 186 /* IfStatement */: - case 203 /* FunctionDeclaration */: - case 165 /* FunctionExpression */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 140 /* CallSignature */: - case 166 /* ArrowFunction */: - case 137 /* Constructor */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - return child !== 182 /* Block */; + case 194 /* DoStatement */: + case 195 /* WhileStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: + case 196 /* ForStatement */: + case 193 /* IfStatement */: + case 210 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 144 /* CallSignature */: + case 171 /* ArrowFunction */: + case 141 /* Constructor */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + return child !== 189 /* Block */; default: return false; } @@ -37866,7 +40301,6 @@ var ts; var StringScriptSnapshot = (function () { function StringScriptSnapshot(text) { this.text = text; - this._lineStartPositions = undefined; } StringScriptSnapshot.prototype.getText = function (start, end) { return this.text.substring(start, end); @@ -37931,13 +40365,13 @@ var ts; while (pos < end) { var token = scanner.scan(); var textPos = scanner.getTextPos(); - nodes.push(createNode(token, pos, textPos, 1024 /* Synthetic */, this)); + nodes.push(createNode(token, pos, textPos, 4096 /* Synthetic */, this)); pos = textPos; } return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(253 /* SyntaxList */, nodes.pos, nodes.end, 1024 /* Synthetic */, this); + var list = createNode(268 /* SyntaxList */, nodes.pos, nodes.end, 4096 /* Synthetic */, this); list._children = []; var pos = nodes.pos; for (var _i = 0; _i < nodes.length; _i++) { @@ -37956,7 +40390,7 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 128 /* FirstNode */) { + if (this.kind >= 132 /* FirstNode */) { scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos = this.pos; @@ -38001,7 +40435,7 @@ var ts; var children = this.getChildren(); for (var _i = 0; _i < children.length; _i++) { var child = children[_i]; - if (child.kind < 128 /* FirstNode */) { + if (child.kind < 132 /* FirstNode */) { return child; } return child.getFirstToken(sourceFile); @@ -38011,7 +40445,7 @@ var ts; var children = this.getChildren(sourceFile); for (var i = children.length - 1; i >= 0; i--) { var child = children[i]; - if (child.kind < 128 /* FirstNode */) { + if (child.kind < 132 /* FirstNode */) { return child; } return child.getLastToken(sourceFile); @@ -38064,27 +40498,27 @@ var ts; if (ts.indexOf(declarations, declaration) === indexOfDeclaration) { var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); // If it is parameter - try and get the jsDoc comment with @param tag from function declaration's jsDoc comments - if (canUseParsedParamTagComments && declaration.kind === 131 /* Parameter */) { + if (canUseParsedParamTagComments && declaration.kind === 135 /* Parameter */) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { - jsDocCommentParts.push.apply(jsDocCommentParts, cleanedParamJsDocComment); + ts.addRange(jsDocCommentParts, cleanedParamJsDocComment); } }); } // If this is left side of dotted module declaration, there is no doc comments associated with this node - if (declaration.kind === 208 /* ModuleDeclaration */ && declaration.body.kind === 208 /* ModuleDeclaration */) { + if (declaration.kind === 215 /* ModuleDeclaration */ && declaration.body.kind === 215 /* ModuleDeclaration */) { return; } // If this is dotted module name, get the doc comments from the parent - while (declaration.kind === 208 /* ModuleDeclaration */ && declaration.parent.kind === 208 /* ModuleDeclaration */) { + while (declaration.kind === 215 /* ModuleDeclaration */ && declaration.parent.kind === 215 /* ModuleDeclaration */) { declaration = declaration.parent; } // Get the cleaned js doc comment text from the declaration - ts.forEach(getJsDocCommentTextRange(declaration.kind === 201 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 208 /* VariableDeclaration */ ? declaration.parent.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { - jsDocCommentParts.push.apply(jsDocCommentParts, cleanedJsDocComment); + ts.addRange(jsDocCommentParts, cleanedJsDocComment); } }); } @@ -38420,9 +40854,9 @@ var ts; if (result_2 !== undefined) { return result_2; } - if (declaration.name.kind === 129 /* ComputedPropertyName */) { + if (declaration.name.kind === 133 /* ComputedPropertyName */) { var expr = declaration.name.expression; - if (expr.kind === 158 /* PropertyAccessExpression */) { + if (expr.kind === 163 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -38432,7 +40866,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 65 /* Identifier */ || + if (node.kind === 66 /* Identifier */ || node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) { return node.text; @@ -38442,9 +40876,9 @@ var ts; } function visit(node) { switch (node.kind) { - case 203 /* FunctionDeclaration */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 210 /* FunctionDeclaration */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -38464,60 +40898,60 @@ var ts; ts.forEachChild(node, visit); } break; - case 204 /* ClassDeclaration */: - case 205 /* InterfaceDeclaration */: - case 206 /* TypeAliasDeclaration */: - case 207 /* EnumDeclaration */: - case 208 /* ModuleDeclaration */: - case 211 /* ImportEqualsDeclaration */: - case 220 /* ExportSpecifier */: - case 216 /* ImportSpecifier */: - case 211 /* ImportEqualsDeclaration */: - case 213 /* ImportClause */: - case 214 /* NamespaceImport */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 148 /* TypeLiteral */: + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: + case 213 /* TypeAliasDeclaration */: + case 214 /* EnumDeclaration */: + case 215 /* ModuleDeclaration */: + case 218 /* ImportEqualsDeclaration */: + case 227 /* ExportSpecifier */: + case 223 /* ImportSpecifier */: + case 218 /* ImportEqualsDeclaration */: + case 220 /* ImportClause */: + case 221 /* NamespaceImport */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 152 /* TypeLiteral */: addDeclaration(node); // fall through - case 137 /* Constructor */: - case 183 /* VariableStatement */: - case 202 /* VariableDeclarationList */: - case 153 /* ObjectBindingPattern */: - case 154 /* ArrayBindingPattern */: - case 209 /* ModuleBlock */: + case 141 /* Constructor */: + case 190 /* VariableStatement */: + case 209 /* VariableDeclarationList */: + case 158 /* ObjectBindingPattern */: + case 159 /* ArrayBindingPattern */: + case 216 /* ModuleBlock */: ts.forEachChild(node, visit); break; - case 182 /* Block */: + case 189 /* Block */: if (ts.isFunctionBlock(node)) { ts.forEachChild(node, visit); } break; - case 131 /* Parameter */: + case 135 /* Parameter */: // Only consider properties defined as constructor parameters if (!(node.flags & 112 /* AccessibilityModifier */)) { break; } // fall through - case 201 /* VariableDeclaration */: - case 155 /* BindingElement */: + case 208 /* VariableDeclaration */: + case 160 /* BindingElement */: if (ts.isBindingPattern(node.name)) { ts.forEachChild(node.name, visit); break; } - case 229 /* EnumMember */: - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: + case 244 /* EnumMember */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: addDeclaration(node); break; - case 218 /* ExportDeclaration */: + case 225 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 212 /* ImportDeclaration */: + case 219 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -38529,7 +40963,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 214 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 221 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -38622,6 +41056,8 @@ var ts; ScriptElementKind.moduleElement = "module"; // class X {} ScriptElementKind.classElement = "class"; + // var x = class X {} + ScriptElementKind.localClassElement = "local class"; // interface Y {} ScriptElementKind.interfaceElement = "interface"; // type T = ... @@ -38672,6 +41108,7 @@ var ts; ScriptElementKindModifier.exportedModifier = "export"; ScriptElementKindModifier.ambientModifier = "declare"; ScriptElementKindModifier.staticModifier = "static"; + ScriptElementKindModifier.abstractModifier = "abstract"; })(ScriptElementKindModifier = ts.ScriptElementKindModifier || (ts.ScriptElementKindModifier = {})); var ClassificationTypeNames = (function () { function ClassificationTypeNames() { @@ -38730,16 +41167,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 165 /* FunctionExpression */) { + if (declaration.kind === 170 /* FunctionExpression */) { return true; } - if (declaration.kind !== 201 /* VariableDeclaration */ && declaration.kind !== 203 /* FunctionDeclaration */) { + if (declaration.kind !== 208 /* VariableDeclaration */ && declaration.kind !== 210 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable for (var parent_9 = declaration.parent; !ts.isFunctionBlock(parent_9); parent_9 = parent_9.parent) { // Reached source file or module block - if (parent_9.kind === 230 /* SourceFile */ || parent_9.kind === 209 /* ModuleBlock */) { + if (parent_9.kind === 245 /* SourceFile */ || parent_9.kind === 216 /* ModuleBlock */) { return false; } } @@ -38751,32 +41188,11 @@ var ts; // Always default to "ScriptTarget.ES5" for the language service return { target: 1 /* ES5 */, - module: 0 /* None */ + module: 0 /* None */, + jsx: 1 /* Preserve */ }; } ts.getDefaultCompilerOptions = getDefaultCompilerOptions; - var OperationCanceledException = (function () { - function OperationCanceledException() { - } - return OperationCanceledException; - })(); - ts.OperationCanceledException = OperationCanceledException; - var CancellationTokenObject = (function () { - function CancellationTokenObject(cancellationToken) { - this.cancellationToken = cancellationToken; - } - CancellationTokenObject.prototype.isCancellationRequested = function () { - return this.cancellationToken && this.cancellationToken.isCancellationRequested(); - }; - CancellationTokenObject.prototype.throwIfCancellationRequested = function () { - if (this.isCancellationRequested()) { - throw new OperationCanceledException(); - } - }; - CancellationTokenObject.None = new CancellationTokenObject(null); - return CancellationTokenObject; - })(); - ts.CancellationTokenObject = CancellationTokenObject; // Cache host information about scrip Should be refreshed // at each language service public entry point, since we don't know when // set of scripts handled by the host changes. @@ -39120,7 +41536,7 @@ var ts; // export * from "mod" // export {a as b} from "mod" while (token !== 1 /* EndOfFileToken */) { - if (token === 85 /* ImportKeyword */) { + if (token === 86 /* ImportKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // import "mod"; @@ -39128,9 +41544,9 @@ var ts; continue; } else { - if (token === 65 /* Identifier */) { + if (token === 66 /* Identifier */) { token = scanner.scan(); - if (token === 126 /* FromKeyword */) { + if (token === 130 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // import d from "mod"; @@ -39138,9 +41554,9 @@ var ts; continue; } } - else if (token === 53 /* EqualsToken */) { + else if (token === 54 /* EqualsToken */) { token = scanner.scan(); - if (token === 120 /* RequireKeyword */) { + if (token === 124 /* RequireKeyword */) { token = scanner.scan(); if (token === 16 /* OpenParenToken */) { token = scanner.scan(); @@ -39169,7 +41585,7 @@ var ts; } if (token === 15 /* CloseBraceToken */) { token = scanner.scan(); - if (token === 126 /* FromKeyword */) { + if (token === 130 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // import {a as A} from "mod"; @@ -39179,13 +41595,13 @@ var ts; } } } - else if (token === 35 /* AsteriskToken */) { + else if (token === 36 /* AsteriskToken */) { token = scanner.scan(); - if (token === 111 /* AsKeyword */) { + if (token === 113 /* AsKeyword */) { token = scanner.scan(); - if (token === 65 /* Identifier */) { + if (token === 66 /* Identifier */) { token = scanner.scan(); - if (token === 126 /* FromKeyword */) { + if (token === 130 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // import * as NS from "mod" @@ -39198,7 +41614,7 @@ var ts; } } } - else if (token === 78 /* ExportKeyword */) { + else if (token === 79 /* ExportKeyword */) { token = scanner.scan(); if (token === 14 /* OpenBraceToken */) { token = scanner.scan(); @@ -39208,7 +41624,7 @@ var ts; } if (token === 15 /* CloseBraceToken */) { token = scanner.scan(); - if (token === 126 /* FromKeyword */) { + if (token === 130 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // export {a as A} from "mod"; @@ -39218,9 +41634,9 @@ var ts; } } } - else if (token === 35 /* AsteriskToken */) { + else if (token === 36 /* AsteriskToken */) { token = scanner.scan(); - if (token === 126 /* FromKeyword */) { + if (token === 130 /* FromKeyword */) { token = scanner.scan(); if (token === 8 /* StringLiteral */) { // export * from "mod" @@ -39243,7 +41659,7 @@ var ts; /// Helpers function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 197 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 204 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -39251,13 +41667,13 @@ var ts; return undefined; } function isJumpStatementTarget(node) { - return node.kind === 65 /* Identifier */ && - (node.parent.kind === 193 /* BreakStatement */ || node.parent.kind === 192 /* ContinueStatement */) && + return node.kind === 66 /* Identifier */ && + (node.parent.kind === 200 /* BreakStatement */ || node.parent.kind === 199 /* ContinueStatement */) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { - return node.kind === 65 /* Identifier */ && - node.parent.kind === 197 /* LabeledStatement */ && + return node.kind === 66 /* Identifier */ && + node.parent.kind === 204 /* LabeledStatement */ && node.parent.label === node; } /** @@ -39265,7 +41681,7 @@ var ts; * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 197 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 204 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -39276,49 +41692,49 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 128 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 132 /* QualifiedName */ && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 158 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 163 /* PropertyAccessExpression */ && node.parent.name === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 160 /* CallExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 165 /* CallExpression */ && node.parent.expression === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 161 /* NewExpression */ && node.parent.expression === node; + return node && node.parent && node.parent.kind === 166 /* NewExpression */ && node.parent.expression === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 208 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 215 /* ModuleDeclaration */ && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { - return node.kind === 65 /* Identifier */ && + return node.kind === 66 /* Identifier */ && ts.isFunctionLike(node.parent) && node.parent.name === node; } /** Returns true if node is a name of an object literal property, e.g. "a" in x = { "a": 1 } */ function isNameOfPropertyAssignment(node) { - return (node.kind === 65 /* Identifier */ || node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) && - (node.parent.kind === 227 /* PropertyAssignment */ || node.parent.kind === 228 /* ShorthandPropertyAssignment */) && node.parent.name === node; + return (node.kind === 66 /* Identifier */ || node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) && + (node.parent.kind === 242 /* PropertyAssignment */ || node.parent.kind === 243 /* ShorthandPropertyAssignment */) && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 8 /* StringLiteral */ || node.kind === 7 /* NumericLiteral */) { switch (node.parent.kind) { - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: - case 227 /* PropertyAssignment */: - case 229 /* EnumMember */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 208 /* ModuleDeclaration */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: + case 242 /* PropertyAssignment */: + case 244 /* EnumMember */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 215 /* ModuleDeclaration */: return node.parent.name === node; - case 159 /* ElementAccessExpression */: + case 164 /* ElementAccessExpression */: return node.parent.argumentExpression === node; } } @@ -39377,7 +41793,7 @@ var ts; })(BreakContinueSearchType || (BreakContinueSearchType = {})); // A cache of completion entries for keywords, these do not change between sessions var keywordCompletions = []; - for (var i = 66 /* FirstKeyword */; i <= 127 /* LastKeyword */; i++) { + for (var i = 67 /* FirstKeyword */; i <= 131 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -39392,17 +41808,17 @@ var ts; return undefined; } switch (node.kind) { - case 230 /* SourceFile */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 203 /* FunctionDeclaration */: - case 165 /* FunctionExpression */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 204 /* ClassDeclaration */: - case 205 /* InterfaceDeclaration */: - case 207 /* EnumDeclaration */: - case 208 /* ModuleDeclaration */: + case 245 /* SourceFile */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 210 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: + case 214 /* EnumDeclaration */: + case 215 /* ModuleDeclaration */: return node; } } @@ -39410,43 +41826,57 @@ var ts; ts.getContainerNode = getContainerNode; /* @internal */ function getNodeKind(node) { switch (node.kind) { - case 208 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; - case 204 /* ClassDeclaration */: return ScriptElementKind.classElement; - case 205 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; - case 206 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; - case 207 /* EnumDeclaration */: return ScriptElementKind.enumElement; - case 201 /* VariableDeclaration */: + case 215 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; + case 211 /* ClassDeclaration */: return ScriptElementKind.classElement; + case 212 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; + case 213 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; + case 214 /* EnumDeclaration */: return ScriptElementKind.enumElement; + case 208 /* VariableDeclaration */: return ts.isConst(node) ? ScriptElementKind.constElement : ts.isLet(node) ? ScriptElementKind.letElement : ScriptElementKind.variableElement; - case 203 /* FunctionDeclaration */: return ScriptElementKind.functionElement; - case 138 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; - case 139 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 210 /* FunctionDeclaration */: return ScriptElementKind.functionElement; + case 142 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; + case 143 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: return ScriptElementKind.memberFunctionElement; - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: return ScriptElementKind.memberVariableElement; - case 142 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; - case 141 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; - case 140 /* CallSignature */: return ScriptElementKind.callSignatureElement; - case 137 /* Constructor */: return ScriptElementKind.constructorImplementationElement; - case 130 /* TypeParameter */: return ScriptElementKind.typeParameterElement; - case 229 /* EnumMember */: return ScriptElementKind.variableElement; - case 131 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; - case 211 /* ImportEqualsDeclaration */: - case 216 /* ImportSpecifier */: - case 213 /* ImportClause */: - case 220 /* ExportSpecifier */: - case 214 /* NamespaceImport */: + case 146 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; + case 145 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; + case 144 /* CallSignature */: return ScriptElementKind.callSignatureElement; + case 141 /* Constructor */: return ScriptElementKind.constructorImplementationElement; + case 134 /* TypeParameter */: return ScriptElementKind.typeParameterElement; + case 244 /* EnumMember */: return ScriptElementKind.variableElement; + case 135 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 218 /* ImportEqualsDeclaration */: + case 223 /* ImportSpecifier */: + case 220 /* ImportClause */: + case 227 /* ExportSpecifier */: + case 221 /* NamespaceImport */: return ScriptElementKind.alias; } return ScriptElementKind.unknown; } ts.getNodeKind = getNodeKind; + var CancellationTokenObject = (function () { + function CancellationTokenObject(cancellationToken) { + this.cancellationToken = cancellationToken; + } + CancellationTokenObject.prototype.isCancellationRequested = function () { + return this.cancellationToken && this.cancellationToken.isCancellationRequested(); + }; + CancellationTokenObject.prototype.throwIfCancellationRequested = function () { + if (this.isCancellationRequested()) { + throw new ts.OperationCanceledException(); + } + }; + return CancellationTokenObject; + })(); function createLanguageService(host, documentRegistry) { if (documentRegistry === void 0) { documentRegistry = createDocumentRegistry(); } var syntaxTreeCache = new SyntaxTreeCache(host); @@ -39621,7 +42051,7 @@ var ts; /// Diagnostics function getSyntacticDiagnostics(fileName) { synchronizeHostData(); - return program.getSyntacticDiagnostics(getValidSourceFile(fileName)); + return program.getSyntacticDiagnostics(getValidSourceFile(fileName), cancellationToken); } /** * getSemanticDiagnostiscs return array of Diagnostics. If '-d' is not enabled, only report semantic errors @@ -39638,12 +42068,12 @@ var ts; } // Only perform the action per file regardless of '-out' flag as LanguageServiceHost is expected to call this function per file. // Therefore only get diagnostics for given file. - var semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile); + var semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile, cancellationToken); if (!program.getCompilerOptions().declaration) { return semanticDiagnostics; } // If '-d' is enabled, check for emitter error. One example of emitter error is export class implements non-export interface - var declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile); + var declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile, cancellationToken); return ts.concatenate(semanticDiagnostics, declarationDiagnostics); } function getJavaScriptSemanticDiagnostics(sourceFile) { @@ -39655,44 +42085,44 @@ var ts; return false; } switch (node.kind) { - case 211 /* ImportEqualsDeclaration */: + case 218 /* ImportEqualsDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return true; - case 217 /* ExportAssignment */: + case 224 /* ExportAssignment */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return true; - case 204 /* ClassDeclaration */: + case 211 /* ClassDeclaration */: var classDeclaration = node; if (checkModifiers(classDeclaration.modifiers) || checkTypeParameters(classDeclaration.typeParameters)) { return true; } break; - case 225 /* HeritageClause */: + case 240 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 102 /* ImplementsKeyword */) { + if (heritageClause.token === 103 /* ImplementsKeyword */) { diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return true; } break; - case 205 /* InterfaceDeclaration */: + case 212 /* InterfaceDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return true; - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return true; - case 206 /* TypeAliasDeclaration */: + case 213 /* TypeAliasDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return true; - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 137 /* Constructor */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 165 /* FunctionExpression */: - case 203 /* FunctionDeclaration */: - case 166 /* ArrowFunction */: - case 203 /* FunctionDeclaration */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 141 /* Constructor */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 170 /* FunctionExpression */: + case 210 /* FunctionDeclaration */: + case 171 /* ArrowFunction */: + case 210 /* FunctionDeclaration */: var functionDeclaration = node; if (checkModifiers(functionDeclaration.modifiers) || checkTypeParameters(functionDeclaration.typeParameters) || @@ -39700,20 +42130,20 @@ var ts; return true; } break; - case 183 /* VariableStatement */: + case 190 /* VariableStatement */: var variableStatement = node; if (checkModifiers(variableStatement.modifiers)) { return true; } break; - case 201 /* VariableDeclaration */: + case 208 /* VariableDeclaration */: var variableDeclaration = node; if (checkTypeAnnotation(variableDeclaration.type)) { return true; } break; - case 160 /* CallExpression */: - case 161 /* NewExpression */: + case 165 /* CallExpression */: + case 166 /* NewExpression */: var expression = node; if (expression.typeArguments && expression.typeArguments.length > 0) { var start = expression.typeArguments.pos; @@ -39721,7 +42151,7 @@ var ts; return true; } break; - case 131 /* Parameter */: + case 135 /* Parameter */: var parameter = node; if (parameter.modifiers) { var start = parameter.modifiers.pos; @@ -39737,17 +42167,17 @@ var ts; return true; } break; - case 134 /* PropertyDeclaration */: + case 138 /* PropertyDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.property_declarations_can_only_be_used_in_a_ts_file)); return true; - case 207 /* EnumDeclaration */: + case 214 /* EnumDeclaration */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return true; - case 163 /* TypeAssertionExpression */: + case 168 /* TypeAssertionExpression */: var typeAssertionExpression = node; diagnostics.push(ts.createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return true; - case 132 /* Decorator */: + case 136 /* Decorator */: diagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.decorators_can_only_be_used_in_a_ts_file)); return true; } @@ -39773,17 +42203,18 @@ var ts; for (var _i = 0; _i < modifiers.length; _i++) { var modifier = modifiers[_i]; switch (modifier.kind) { - case 108 /* PublicKeyword */: - case 106 /* PrivateKeyword */: - case 107 /* ProtectedKeyword */: - case 115 /* DeclareKeyword */: + case 109 /* PublicKeyword */: + case 107 /* PrivateKeyword */: + case 108 /* ProtectedKeyword */: + case 119 /* DeclareKeyword */: diagnostics.push(ts.createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); return true; // These are all legal modifiers. - case 109 /* StaticKeyword */: - case 78 /* ExportKeyword */: - case 70 /* ConstKeyword */: - case 73 /* DefaultKeyword */: + case 110 /* StaticKeyword */: + case 79 /* ExportKeyword */: + case 71 /* ConstKeyword */: + case 74 /* DefaultKeyword */: + case 112 /* AbstractKeyword */: } } } @@ -39792,19 +42223,16 @@ var ts; } function getCompilerOptionsDiagnostics() { synchronizeHostData(); - return program.getOptionsDiagnostics().concat(program.getGlobalDiagnostics()); + return program.getOptionsDiagnostics(cancellationToken).concat(program.getGlobalDiagnostics(cancellationToken)); } - /// Completion - function getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks) { - var displayName = symbol.getName(); + /** + * Get the name to be display in completion from a given symbol. + * + * @return undefined if the name is of external module otherwise a name with striped of any quote + */ + function getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks, location) { + var displayName = ts.getDeclaredName(program.getTypeChecker(), symbol, location); if (displayName) { - // If this is the default export, get the name of the declaration if it exists - if (displayName === "default") { - var localSymbol = ts.getLocalSymbolForExportDefault(symbol); - if (localSymbol && localSymbol.name) { - displayName = symbol.valueDeclaration.localSymbol.name; - } - } var firstCharCode = displayName.charCodeAt(0); // First check of the displayName is not external module; if it is an external module, it is not valid entry if ((symbol.flags & 1536 /* Namespace */) && (firstCharCode === 39 /* singleQuote */ || firstCharCode === 34 /* doubleQuote */)) { @@ -39815,32 +42243,33 @@ var ts; } return getCompletionEntryDisplayName(displayName, target, performCharacterChecks); } - function getCompletionEntryDisplayName(displayName, target, performCharacterChecks) { - if (!displayName) { + /** + * Get a displayName from a given for completion list, performing any necessary quotes stripping + * and checking whether the name is valid identifier name. + */ + function getCompletionEntryDisplayName(name, target, performCharacterChecks) { + if (!name) { return undefined; } - var firstCharCode = displayName.charCodeAt(0); - if (displayName.length >= 2 && - firstCharCode === displayName.charCodeAt(displayName.length - 1) && - (firstCharCode === 39 /* singleQuote */ || firstCharCode === 34 /* doubleQuote */)) { - // If the user entered name for the symbol was quoted, removing the quotes is not enough, as the name could be an - // invalid identifier name. We need to check if whatever was inside the quotes is actually a valid identifier name. - displayName = displayName.substring(1, displayName.length - 1); - } - if (!displayName) { + name = ts.stripQuotes(name); + if (!name) { return undefined; } + // If the user entered name for the symbol was quoted, removing the quotes is not enough, as the name could be an + // invalid identifier name. We need to check if whatever was inside the quotes is actually a valid identifier name. + // e.g "b a" is valid quoted name but when we strip off the quotes, it is invalid. + // We, thus, need to check if whatever was inside the quotes is actually a valid identifier name. if (performCharacterChecks) { - if (!ts.isIdentifierStart(displayName.charCodeAt(0), target)) { + if (!ts.isIdentifierStart(name.charCodeAt(0), target)) { return undefined; } - for (var i = 1, n = displayName.length; i < n; i++) { - if (!ts.isIdentifierPart(displayName.charCodeAt(i), target)) { + for (var i = 1, n = name.length; i < n; i++) { + if (!ts.isIdentifierPart(name.charCodeAt(i), target)) { return undefined; } } } - return ts.unescapeIdentifier(displayName); + return name; } function getCompletionData(fileName, position) { var typeChecker = program.getTypeChecker(); @@ -39871,26 +42300,40 @@ var ts; contextToken = ts.findPrecedingToken(contextToken.getFullStart(), sourceFile); log("getCompletionData: Get previous token 2: " + (new Date().getTime() - start_2)); } - // Check if this is a valid completion location - if (contextToken && isCompletionListBlocker(contextToken)) { - log("Returning an empty list because completion was requested in an invalid position."); - return undefined; - } - // Find the node where completion is requested on, in the case of a completion after - // a dot, it is the member access expression other wise, it is a request for all - // visible symbols in the scope, and the node is the current location. + // Find the node where completion is requested on. + // Also determine whether we are trying to complete with members of that node + // or attributes of a JSX tag. var node = currentToken; var isRightOfDot = false; - if (contextToken && contextToken.kind === 20 /* DotToken */ && contextToken.parent.kind === 158 /* PropertyAccessExpression */) { - node = contextToken.parent.expression; - isRightOfDot = true; - } - else if (contextToken && contextToken.kind === 20 /* DotToken */ && contextToken.parent.kind === 128 /* QualifiedName */) { - node = contextToken.parent.left; - isRightOfDot = true; - } + var isRightOfOpenTag = false; var location = ts.getTouchingPropertyName(sourceFile, position); - var target = program.getCompilerOptions().target; + if (contextToken) { + // Bail out if this is a known invalid completion location + if (isCompletionListBlocker(contextToken)) { + log("Returning an empty list because completion was requested in an invalid position."); + return undefined; + } + var parent_10 = contextToken.parent, kind = contextToken.kind; + if (kind === 20 /* DotToken */) { + if (parent_10.kind === 163 /* PropertyAccessExpression */) { + node = contextToken.parent.expression; + isRightOfDot = true; + } + else if (parent_10.kind === 132 /* QualifiedName */) { + node = contextToken.parent.left; + isRightOfDot = true; + } + else { + // There is nothing that precedes the dot, so this likely just a stray character + // or leading into a '...' token. Just bail out instead. + return undefined; + } + } + else if (kind === 24 /* LessThanToken */ && sourceFile.languageVariant === 1 /* JSX */) { + isRightOfOpenTag = true; + location = contextToken; + } + } var semanticStart = new Date().getTime(); var isMemberCompletion; var isNewIdentifierLocation; @@ -39898,6 +42341,17 @@ var ts; if (isRightOfDot) { getTypeScriptMemberSymbols(); } + else if (isRightOfOpenTag) { + var tagSymbols = typeChecker.getJsxIntrinsicTagNames(); + if (tryGetGlobalSymbols()) { + symbols = tagSymbols.concat(symbols.filter(function (s) { return !!(s.flags & 107455 /* Value */); })); + } + else { + symbols = tagSymbols; + } + isMemberCompletion = true; + isNewIdentifierLocation = false; + } else { // For JavaScript or TypeScript, if we're not after a dot, then just try to get the // global symbols in scope. These results should be valid for either language as @@ -39907,12 +42361,12 @@ var ts; } } log("getCompletionData: Semantic work: " + (new Date().getTime() - semanticStart)); - return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: isRightOfDot }; + return { symbols: symbols, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag) }; function getTypeScriptMemberSymbols() { // Right of dot member completion list isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 65 /* Identifier */ || node.kind === 128 /* QualifiedName */ || node.kind === 158 /* PropertyAccessExpression */) { + if (node.kind === 66 /* Identifier */ || node.kind === 132 /* QualifiedName */ || node.kind === 163 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -39955,80 +42409,68 @@ var ts; } } function tryGetGlobalSymbols() { - var containingObjectLiteral = getContainingObjectLiteralApplicableForCompletion(contextToken); - if (containingObjectLiteral) { - // Object literal expression, look up possible property names from contextual type - isMemberCompletion = true; - isNewIdentifierLocation = true; - var contextualType = typeChecker.getContextualType(containingObjectLiteral); - if (!contextualType) { - return false; - } - var contextualTypeMembers = typeChecker.getPropertiesOfType(contextualType); - if (contextualTypeMembers && contextualTypeMembers.length > 0) { - // Add filtered items to the completion list - symbols = filterContextualMembersList(contextualTypeMembers, containingObjectLiteral.properties); - } + var objectLikeContainer; + var importClause; + var jsxContainer; + if (objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken)) { + return tryGetObjectLikeCompletionSymbols(objectLikeContainer); } - else if (ts.getAncestor(contextToken, 213 /* ImportClause */)) { - // cursor is in import clause + if (importClause = ts.getAncestor(contextToken, 220 /* ImportClause */)) { + // cursor is in an import clause // try to show exported member for imported module - isMemberCompletion = true; - isNewIdentifierLocation = true; - if (showCompletionsInImportsClause(contextToken)) { - var importDeclaration = ts.getAncestor(contextToken, 212 /* ImportDeclaration */); - ts.Debug.assert(importDeclaration !== undefined); - var exports; - if (importDeclaration.moduleSpecifier) { - var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importDeclaration.moduleSpecifier); - if (moduleSpecifierSymbol) { - exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); - } + return tryGetImportClauseCompletionSymbols(importClause); + } + if (jsxContainer = tryGetContainingJsxElement(contextToken)) { + var attrsType; + if ((jsxContainer.kind === 231 /* JsxSelfClosingElement */) || (jsxContainer.kind === 232 /* JsxOpeningElement */)) { + // Cursor is inside a JSX self-closing element or opening element + attrsType = typeChecker.getJsxElementAttributesType(jsxContainer); + if (attrsType) { + symbols = filterJsxAttributes(jsxContainer.attributes, typeChecker.getPropertiesOfType(attrsType)); + isMemberCompletion = true; + isNewIdentifierLocation = false; + return true; } - //let exports = typeInfoResolver.getExportsOfImportDeclaration(importDeclaration); - symbols = exports ? filterModuleExports(exports, importDeclaration) : emptyArray; } } - else { - // Get all entities in the current scope. - isMemberCompletion = false; - isNewIdentifierLocation = isNewIdentifierDefinitionLocation(contextToken); - if (previousToken !== contextToken) { - ts.Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); - } - // We need to find the node that will give us an appropriate scope to begin - // aggregating completion candidates. This is achieved in 'getScopeNode' - // by finding the first node that encompasses a position, accounting for whether a node - // is "complete" to decide whether a position belongs to the node. - // - // However, at the end of an identifier, we are interested in the scope of the identifier - // itself, but fall outside of the identifier. For instance: - // - // xyz => x$ - // - // the cursor is outside of both the 'x' and the arrow function 'xyz => x', - // so 'xyz' is not returned in our results. - // - // We define 'adjustedPosition' so that we may appropriately account for - // being at the end of an identifier. The intention is that if requesting completion - // at the end of an identifier, it should be effectively equivalent to requesting completion - // anywhere inside/at the beginning of the identifier. So in the previous case, the - // 'adjustedPosition' will work as if requesting completion in the following: - // - // xyz => $x - // - // If previousToken !== contextToken, then - // - 'contextToken' was adjusted to the token prior to 'previousToken' - // because we were at the end of an identifier. - // - 'previousToken' is defined. - var adjustedPosition = previousToken !== contextToken ? - previousToken.getStart() : - position; - var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; - /// TODO filter meaning based on the current context - var symbolMeanings = 793056 /* Type */ | 107455 /* Value */ | 1536 /* Namespace */ | 8388608 /* Alias */; - symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); + // Get all entities in the current scope. + isMemberCompletion = false; + isNewIdentifierLocation = isNewIdentifierDefinitionLocation(contextToken); + if (previousToken !== contextToken) { + ts.Debug.assert(!!previousToken, "Expected 'contextToken' to be defined when different from 'previousToken'."); } + // We need to find the node that will give us an appropriate scope to begin + // aggregating completion candidates. This is achieved in 'getScopeNode' + // by finding the first node that encompasses a position, accounting for whether a node + // is "complete" to decide whether a position belongs to the node. + // + // However, at the end of an identifier, we are interested in the scope of the identifier + // itself, but fall outside of the identifier. For instance: + // + // xyz => x$ + // + // the cursor is outside of both the 'x' and the arrow function 'xyz => x', + // so 'xyz' is not returned in our results. + // + // We define 'adjustedPosition' so that we may appropriately account for + // being at the end of an identifier. The intention is that if requesting completion + // at the end of an identifier, it should be effectively equivalent to requesting completion + // anywhere inside/at the beginning of the identifier. So in the previous case, the + // 'adjustedPosition' will work as if requesting completion in the following: + // + // xyz => $x + // + // If previousToken !== contextToken, then + // - 'contextToken' was adjusted to the token prior to 'previousToken' + // because we were at the end of an identifier. + // - 'previousToken' is defined. + var adjustedPosition = previousToken !== contextToken ? + previousToken.getStart() : + position; + var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; + /// TODO filter meaning based on the current context + var symbolMeanings = 793056 /* Type */ | 107455 /* Value */ | 1536 /* Namespace */ | 8388608 /* Alias */; + symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); return true; } /** @@ -40042,20 +42484,20 @@ var ts; } return scope; } - function isCompletionListBlocker(previousToken) { + function isCompletionListBlocker(contextToken) { var start = new Date().getTime(); - var result = isInStringOrRegularExpressionOrTemplateLiteral(previousToken) || - isIdentifierDefinitionLocation(previousToken) || - isRightOfIllegalDot(previousToken); + var result = isInStringOrRegularExpressionOrTemplateLiteral(contextToken) || + isIdentifierDefinitionLocation(contextToken) || + isDotOfNumericLiteral(contextToken); log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - start)); return result; } - function showCompletionsInImportsClause(node) { + function shouldShowCompletionsInImportsClause(node) { if (node) { // import {| // import {a,| if (node.kind === 14 /* OpenBraceToken */ || node.kind === 23 /* CommaToken */) { - return node.parent.kind === 215 /* NamedImports */; + return node.parent.kind === 222 /* NamedImports */; } } return false; @@ -40065,38 +42507,40 @@ var ts; var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { case 23 /* CommaToken */: - return containingNodeKind === 160 /* CallExpression */ // func( a, | - || containingNodeKind === 137 /* Constructor */ // constructor( a, | public, protected, private keywords are allowed here, so show completion - || containingNodeKind === 161 /* NewExpression */ // new C(a, | - || containingNodeKind === 156 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 172 /* BinaryExpression */ // let x = (a, | - || containingNodeKind === 145 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 165 /* CallExpression */ // func( a, | + || containingNodeKind === 141 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 166 /* NewExpression */ // new C(a, | + || containingNodeKind === 161 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 178 /* BinaryExpression */ // let x = (a, | + || containingNodeKind === 149 /* FunctionType */; // var x: (s: string, list| case 16 /* OpenParenToken */: - return containingNodeKind === 160 /* CallExpression */ // func( | - || containingNodeKind === 137 /* Constructor */ // constructor( | - || containingNodeKind === 161 /* NewExpression */ // new C(a| - || containingNodeKind === 164 /* ParenthesizedExpression */ // let x = (a| - || containingNodeKind === 152 /* ParenthesizedType */; // function F(pred: (a| this can become an arrow function, where 'a' is the argument + return containingNodeKind === 165 /* CallExpression */ // func( | + || containingNodeKind === 141 /* Constructor */ // constructor( | + || containingNodeKind === 166 /* NewExpression */ // new C(a| + || containingNodeKind === 169 /* ParenthesizedExpression */ // let x = (a| + || containingNodeKind === 157 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 18 /* OpenBracketToken */: - return containingNodeKind === 156 /* ArrayLiteralExpression */; // [ | - case 118 /* ModuleKeyword */: // module | - case 119 /* NamespaceKeyword */: + return containingNodeKind === 161 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 146 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 133 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 122 /* ModuleKeyword */: // module | + case 123 /* NamespaceKeyword */: return true; case 20 /* DotToken */: - return containingNodeKind === 208 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 215 /* ModuleDeclaration */; // module A.| case 14 /* OpenBraceToken */: - return containingNodeKind === 204 /* ClassDeclaration */; // class A{ | - case 53 /* EqualsToken */: - return containingNodeKind === 201 /* VariableDeclaration */ // let x = a| - || containingNodeKind === 172 /* BinaryExpression */; // x = a| + return containingNodeKind === 211 /* ClassDeclaration */; // class A{ | + case 54 /* EqualsToken */: + return containingNodeKind === 208 /* VariableDeclaration */ // let x = a| + || containingNodeKind === 178 /* BinaryExpression */; // x = a| case 11 /* TemplateHead */: - return containingNodeKind === 174 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 180 /* TemplateExpression */; // `aa ${| case 12 /* TemplateMiddle */: - return containingNodeKind === 180 /* TemplateSpan */; // `aa ${10} dd ${| - case 108 /* PublicKeyword */: - case 106 /* PrivateKeyword */: - case 107 /* ProtectedKeyword */: - return containingNodeKind === 134 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 187 /* TemplateSpan */; // `aa ${10} dd ${| + case 109 /* PublicKeyword */: + case 107 /* PrivateKeyword */: + case 108 /* ProtectedKeyword */: + return containingNodeKind === 138 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (previousToken.getText()) { @@ -40108,12 +42552,12 @@ var ts; } return false; } - function isInStringOrRegularExpressionOrTemplateLiteral(previousToken) { - if (previousToken.kind === 8 /* StringLiteral */ - || previousToken.kind === 9 /* RegularExpressionLiteral */ - || ts.isTemplateLiteralKind(previousToken.kind)) { - var start_3 = previousToken.getStart(); - var end = previousToken.getEnd(); + function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { + if (contextToken.kind === 8 /* StringLiteral */ + || contextToken.kind === 9 /* RegularExpressionLiteral */ + || ts.isTemplateLiteralKind(contextToken.kind)) { + var start_3 = contextToken.getStart(); + var end = contextToken.getEnd(); // To be "in" one of these literals, the position has to be: // 1. entirely within the token text. // 2. at the end position of an unterminated token. @@ -40122,21 +42566,118 @@ var ts; return true; } if (position === end) { - return !!previousToken.isUnterminated || - previousToken.kind === 9 /* RegularExpressionLiteral */; + return !!contextToken.isUnterminated + || contextToken.kind === 9 /* RegularExpressionLiteral */; } } return false; } - function getContainingObjectLiteralApplicableForCompletion(previousToken) { - // The locations in an object literal expression that are applicable for completion are property name definition locations. - if (previousToken) { - var parent_10 = previousToken.parent; - switch (previousToken.kind) { + /** + * Aggregates relevant symbols for completion in object literals and object binding patterns. + * Relevant symbols are stored in the captured 'symbols' variable. + * + * @returns true if 'symbols' was successfully populated; false otherwise. + */ + function tryGetObjectLikeCompletionSymbols(objectLikeContainer) { + // We're looking up possible property names from contextual/inferred/declared type. + isMemberCompletion = true; + var typeForObject; + var existingMembers; + if (objectLikeContainer.kind === 162 /* ObjectLiteralExpression */) { + // We are completing on contextual types, but may also include properties + // other than those within the declared type. + isNewIdentifierLocation = true; + typeForObject = typeChecker.getContextualType(objectLikeContainer); + existingMembers = objectLikeContainer.properties; + } + else if (objectLikeContainer.kind === 158 /* ObjectBindingPattern */) { + // We are *only* completing on properties from the type being destructured. + isNewIdentifierLocation = false; + typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); + existingMembers = objectLikeContainer.elements; + } + else { + ts.Debug.fail("Expected object literal or binding pattern, got " + objectLikeContainer.kind); + } + if (!typeForObject) { + return false; + } + var typeMembers = typeChecker.getPropertiesOfType(typeForObject); + if (typeMembers && typeMembers.length > 0) { + // Add filtered items to the completion list + symbols = filterObjectMembersList(typeMembers, existingMembers); + } + return true; + } + /** + * Aggregates relevant symbols for completion in import clauses; for instance, + * + * import { $ } from "moduleName"; + * + * Relevant symbols are stored in the captured 'symbols' variable. + * + * @returns true if 'symbols' was successfully populated; false otherwise. + */ + function tryGetImportClauseCompletionSymbols(importClause) { + // cursor is in import clause + // try to show exported member for imported module + if (shouldShowCompletionsInImportsClause(contextToken)) { + isMemberCompletion = true; + isNewIdentifierLocation = false; + var importDeclaration = importClause.parent; + ts.Debug.assert(importDeclaration !== undefined && importDeclaration.kind === 219 /* ImportDeclaration */); + var exports; + var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(importDeclaration.moduleSpecifier); + if (moduleSpecifierSymbol) { + exports = typeChecker.getExportsOfModule(moduleSpecifierSymbol); + } + //let exports = typeInfoResolver.getExportsOfImportDeclaration(importDeclaration); + symbols = exports ? filterModuleExports(exports, importDeclaration) : emptyArray; + } + else { + isMemberCompletion = false; + isNewIdentifierLocation = true; + } + return true; + } + /** + * Returns the immediate owning object literal or binding pattern of a context token, + * on the condition that one exists and that the context implies completion should be given. + */ + function tryGetObjectLikeCompletionContainer(contextToken) { + if (contextToken) { + switch (contextToken.kind) { case 14 /* OpenBraceToken */: // let x = { | case 23 /* CommaToken */: - if (parent_10 && parent_10.kind === 157 /* ObjectLiteralExpression */) { - return parent_10; + var parent_11 = contextToken.parent; + if (parent_11 && (parent_11.kind === 162 /* ObjectLiteralExpression */ || parent_11.kind === 158 /* ObjectBindingPattern */)) { + return parent_11; + } + break; + } + } + return undefined; + } + function tryGetContainingJsxElement(contextToken) { + if (contextToken) { + var parent_12 = contextToken.parent; + switch (contextToken.kind) { + case 25 /* LessThanSlashToken */: + case 37 /* SlashToken */: + case 66 /* Identifier */: + if (parent_12 && (parent_12.kind === 231 /* JsxSelfClosingElement */ || parent_12.kind === 232 /* JsxOpeningElement */)) { + return parent_12; + } + break; + case 15 /* CloseBraceToken */: + // The context token is the closing } of an attribute, which means + // its parent is a JsxExpression, whose parent is a JsxAttribute, + // whose parent is a JsxOpeningLikeElement + if (parent_12 && + parent_12.kind === 237 /* JsxExpression */ && + parent_12.parent && + parent_12.parent.kind === 235 /* JsxAttribute */) { + return parent_12.parent.parent; } break; } @@ -40145,103 +42686,98 @@ var ts; } function isFunction(kind) { switch (kind) { - case 165 /* FunctionExpression */: - case 166 /* ArrowFunction */: - case 203 /* FunctionDeclaration */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 140 /* CallSignature */: - case 141 /* ConstructSignature */: - case 142 /* IndexSignature */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: + case 210 /* FunctionDeclaration */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 144 /* CallSignature */: + case 145 /* ConstructSignature */: + case 146 /* IndexSignature */: return true; } return false; } - function isIdentifierDefinitionLocation(previousToken) { - if (previousToken) { - var containingNodeKind = previousToken.parent.kind; - switch (previousToken.kind) { - case 23 /* CommaToken */: - return containingNodeKind === 201 /* VariableDeclaration */ || - containingNodeKind === 202 /* VariableDeclarationList */ || - containingNodeKind === 183 /* VariableStatement */ || - containingNodeKind === 207 /* EnumDeclaration */ || - isFunction(containingNodeKind) || - containingNodeKind === 204 /* ClassDeclaration */ || - containingNodeKind === 203 /* FunctionDeclaration */ || - containingNodeKind === 205 /* InterfaceDeclaration */ || - containingNodeKind === 154 /* ArrayBindingPattern */ || - containingNodeKind === 153 /* ObjectBindingPattern */; // function func({ x, y| - case 20 /* DotToken */: - return containingNodeKind === 154 /* ArrayBindingPattern */; // var [.| - case 51 /* ColonToken */: - return containingNodeKind === 155 /* BindingElement */; // var {x :html| - case 18 /* OpenBracketToken */: - return containingNodeKind === 154 /* ArrayBindingPattern */; // var [x| - case 16 /* OpenParenToken */: - return containingNodeKind === 226 /* CatchClause */ || - isFunction(containingNodeKind); - case 14 /* OpenBraceToken */: - return containingNodeKind === 207 /* EnumDeclaration */ || - containingNodeKind === 205 /* InterfaceDeclaration */ || - containingNodeKind === 148 /* TypeLiteral */ || - containingNodeKind === 153 /* ObjectBindingPattern */; // function func({ x| - case 22 /* SemicolonToken */: - return containingNodeKind === 133 /* PropertySignature */ && - previousToken.parent && previousToken.parent.parent && - (previousToken.parent.parent.kind === 205 /* InterfaceDeclaration */ || - previousToken.parent.parent.kind === 148 /* TypeLiteral */); // let x : { a; | - case 24 /* LessThanToken */: - return containingNodeKind === 204 /* ClassDeclaration */ || - containingNodeKind === 203 /* FunctionDeclaration */ || - containingNodeKind === 205 /* InterfaceDeclaration */ || - isFunction(containingNodeKind); - case 109 /* StaticKeyword */: - return containingNodeKind === 134 /* PropertyDeclaration */; - case 21 /* DotDotDotToken */: - return containingNodeKind === 131 /* Parameter */ || - containingNodeKind === 137 /* Constructor */ || - (previousToken.parent && previousToken.parent.parent && - previousToken.parent.parent.kind === 154 /* ArrayBindingPattern */); // var [...z| - case 108 /* PublicKeyword */: - case 106 /* PrivateKeyword */: - case 107 /* ProtectedKeyword */: - return containingNodeKind === 131 /* Parameter */; - case 69 /* ClassKeyword */: - case 77 /* EnumKeyword */: - case 103 /* InterfaceKeyword */: - case 83 /* FunctionKeyword */: - case 98 /* VarKeyword */: - case 116 /* GetKeyword */: - case 122 /* SetKeyword */: - case 85 /* ImportKeyword */: - case 104 /* LetKeyword */: - case 70 /* ConstKeyword */: - case 110 /* YieldKeyword */: - case 125 /* TypeKeyword */: - return true; - } - // Previous token may have been a keyword that was converted to an identifier. - switch (previousToken.getText()) { - case "class": - case "interface": - case "enum": - case "function": - case "var": - case "static": - case "let": - case "const": - case "yield": - return true; - } + function isIdentifierDefinitionLocation(contextToken) { + var containingNodeKind = contextToken.parent.kind; + switch (contextToken.kind) { + case 23 /* CommaToken */: + return containingNodeKind === 208 /* VariableDeclaration */ || + containingNodeKind === 209 /* VariableDeclarationList */ || + containingNodeKind === 190 /* VariableStatement */ || + containingNodeKind === 214 /* EnumDeclaration */ || + isFunction(containingNodeKind) || + containingNodeKind === 211 /* ClassDeclaration */ || + containingNodeKind === 210 /* FunctionDeclaration */ || + containingNodeKind === 212 /* InterfaceDeclaration */ || + containingNodeKind === 159 /* ArrayBindingPattern */; // var [x, y| + case 20 /* DotToken */: + return containingNodeKind === 159 /* ArrayBindingPattern */; // var [.| + case 52 /* ColonToken */: + return containingNodeKind === 160 /* BindingElement */; // var {x :html| + case 18 /* OpenBracketToken */: + return containingNodeKind === 159 /* ArrayBindingPattern */; // var [x| + case 16 /* OpenParenToken */: + return containingNodeKind === 241 /* CatchClause */ || + isFunction(containingNodeKind); + case 14 /* OpenBraceToken */: + return containingNodeKind === 214 /* EnumDeclaration */ || + containingNodeKind === 212 /* InterfaceDeclaration */ || + containingNodeKind === 152 /* TypeLiteral */; // let x : { | + case 22 /* SemicolonToken */: + return containingNodeKind === 137 /* PropertySignature */ && + contextToken.parent && contextToken.parent.parent && + (contextToken.parent.parent.kind === 212 /* InterfaceDeclaration */ || + contextToken.parent.parent.kind === 152 /* TypeLiteral */); // let x : { a; | + case 24 /* LessThanToken */: + return containingNodeKind === 211 /* ClassDeclaration */ || + containingNodeKind === 210 /* FunctionDeclaration */ || + containingNodeKind === 212 /* InterfaceDeclaration */ || + isFunction(containingNodeKind); + case 110 /* StaticKeyword */: + return containingNodeKind === 138 /* PropertyDeclaration */; + case 21 /* DotDotDotToken */: + return containingNodeKind === 135 /* Parameter */ || + (contextToken.parent && contextToken.parent.parent && + contextToken.parent.parent.kind === 159 /* ArrayBindingPattern */); // var [...z| + case 109 /* PublicKeyword */: + case 107 /* PrivateKeyword */: + case 108 /* ProtectedKeyword */: + return containingNodeKind === 135 /* Parameter */; + case 70 /* ClassKeyword */: + case 78 /* EnumKeyword */: + case 104 /* InterfaceKeyword */: + case 84 /* FunctionKeyword */: + case 99 /* VarKeyword */: + case 120 /* GetKeyword */: + case 126 /* SetKeyword */: + case 86 /* ImportKeyword */: + case 105 /* LetKeyword */: + case 71 /* ConstKeyword */: + case 111 /* YieldKeyword */: + case 129 /* TypeKeyword */: + return true; + } + // Previous token may have been a keyword that was converted to an identifier. + switch (contextToken.getText()) { + case "class": + case "interface": + case "enum": + case "function": + case "var": + case "static": + case "let": + case "const": + case "yield": + return true; } return false; } - function isRightOfIllegalDot(previousToken) { - if (previousToken && previousToken.kind === 7 /* NumericLiteral */) { - var text = previousToken.getFullText(); + function isDotOfNumericLiteral(contextToken) { + if (contextToken.kind === 7 /* NumericLiteral */) { + var text = contextToken.getFullText(); return text.charAt(text.length - 1) === "."; } return false; @@ -40252,8 +42788,12 @@ var ts; return exports; } if (importDeclaration.importClause.namedBindings && - importDeclaration.importClause.namedBindings.kind === 215 /* NamedImports */) { + importDeclaration.importClause.namedBindings.kind === 222 /* NamedImports */) { ts.forEach(importDeclaration.importClause.namedBindings.elements, function (el) { + // If this is the current item we are editing right now, do not filter it out + if (el.getStart() <= position && position <= el.getEnd()) { + return; + } var name = el.propertyName || el.name; exisingImports[name.text] = true; }); @@ -40263,23 +42803,35 @@ var ts; } return ts.filter(exports, function (e) { return !ts.lookUp(exisingImports, e.name); }); } - function filterContextualMembersList(contextualMemberSymbols, existingMembers) { + function filterObjectMembersList(contextualMemberSymbols, existingMembers) { if (!existingMembers || existingMembers.length === 0) { return contextualMemberSymbols; } var existingMemberNames = {}; - ts.forEach(existingMembers, function (m) { - if (m.kind !== 227 /* PropertyAssignment */ && m.kind !== 228 /* ShorthandPropertyAssignment */) { - // Ignore omitted expressions for missing members in the object literal - return; + for (var _i = 0; _i < existingMembers.length; _i++) { + var m = existingMembers[_i]; + // Ignore omitted expressions for missing members + if (m.kind !== 242 /* PropertyAssignment */ && + m.kind !== 243 /* ShorthandPropertyAssignment */ && + m.kind !== 160 /* BindingElement */) { + continue; } + // If this is the current item we are editing right now, do not filter it out if (m.getStart() <= position && position <= m.getEnd()) { - // If this is the current item we are editing right now, do not filter it out - return; + continue; } - // TODO(jfreeman): Account for computed property name - existingMemberNames[m.name.text] = true; - }); + var existingName = void 0; + if (m.kind === 160 /* BindingElement */ && m.propertyName) { + existingName = m.propertyName.text; + } + else { + // TODO(jfreeman): Account for computed property name + // NOTE: if one only performs this step when m.name is an identifier, + // things like '__proto__' are not filtered out. + existingName = m.name.text; + } + existingMemberNames[existingName] = true; + } var filteredMembers = []; ts.forEach(contextualMemberSymbols, function (s) { if (!existingMemberNames[s.name]) { @@ -40288,6 +42840,27 @@ var ts; }); return filteredMembers; } + function filterJsxAttributes(attributes, symbols) { + var seenNames = {}; + for (var _i = 0; _i < attributes.length; _i++) { + var attr = attributes[_i]; + // If this is the current item we are editing right now, do not filter it out + if (attr.getStart() <= position && position <= attr.getEnd()) { + continue; + } + if (attr.kind === 235 /* JsxAttribute */) { + seenNames[attr.name.text] = true; + } + } + var result = []; + for (var _a = 0; _a < symbols.length; _a++) { + var sym = symbols[_a]; + if (!seenNames[sym.name]) { + result.push(sym); + } + } + return result; + } } function getCompletionsAtPosition(fileName, position) { synchronizeHostData(); @@ -40319,10 +42892,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_27 in nameTable) { - if (!allNames[name_27]) { - allNames[name_27] = name_27; - var displayName = getCompletionEntryDisplayName(name_27, target, true); + for (var name_31 in nameTable) { + if (!allNames[name_31]) { + allNames[name_31] = name_31; + var displayName = getCompletionEntryDisplayName(name_31, target, true); if (displayName) { var entry = { name: displayName, @@ -40341,7 +42914,7 @@ var ts; // Try to get a valid display name for this symbol, if we could not find one, then ignore it. // We would like to only show things that can be added after a dot, so for instance numeric properties can // not be accessed with a dot (a.1 <- invalid) - var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, true); + var displayName = getCompletionEntryDisplayNameForSymbol(symbol, program.getCompilerOptions().target, true, location); if (!displayName) { return undefined; } @@ -40391,15 +42964,15 @@ var ts; // We don't need to perform character checks here because we're only comparing the // name against 'entryName' (which is known to be good), not building a new // completion entry. - var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target, false) === entryName ? s : undefined; }); + var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, target, false, location_2) === entryName ? s : undefined; }); if (symbol) { - var displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location_2, location_2, 7 /* All */); + var _a = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location_2, location_2, 7 /* All */), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; return { name: entryName, - kind: displayPartsDocumentationsAndSymbolKind.symbolKind, kindModifiers: getSymbolModifiers(symbol), - displayParts: displayPartsDocumentationsAndSymbolKind.displayParts, - documentation: displayPartsDocumentationsAndSymbolKind.documentation + kind: symbolKind, + displayParts: displayParts, + documentation: documentation }; } } @@ -40420,7 +42993,8 @@ var ts; function getSymbolKind(symbol, location) { var flags = symbol.getFlags(); if (flags & 32 /* Class */) - return ScriptElementKind.classElement; + return ts.getDeclarationOfKind(symbol, 183 /* ClassExpression */) ? + ScriptElementKind.localClassElement : ScriptElementKind.classElement; if (flags & 384 /* Enum */) return ScriptElementKind.enumElement; if (flags & 524288 /* TypeAlias */) @@ -40473,7 +43047,7 @@ var ts; if (flags & 16384 /* Constructor */) return ScriptElementKind.constructorImplementationElement; if (flags & 4 /* Property */) { - if (flags & 268435456 /* UnionProperty */) { + if (flags & 268435456 /* SyntheticProperty */) { // If union property is result of union of non method (property/accessors/variables), it is labeled as property var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { var rootSymbolFlags = rootSymbol.getFlags(); @@ -40521,7 +43095,7 @@ var ts; var signature; type = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 158 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 163 /* PropertyAccessExpression */) { var right = location.parent.name; // Either the location is on the right of a property access, or on the left and the right is missing if (right === location || (right && right.getFullWidth() === 0)) { @@ -40530,7 +43104,7 @@ var ts; } // try get the call/construct signature from the type if it matches var callExpression; - if (location.kind === 160 /* CallExpression */ || location.kind === 161 /* NewExpression */) { + if (location.kind === 165 /* CallExpression */ || location.kind === 166 /* NewExpression */) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -40543,7 +43117,7 @@ var ts; // Use the first candidate: signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 161 /* NewExpression */ || callExpression.expression.kind === 91 /* SuperKeyword */; + var useConstructSignatures = callExpression.kind === 166 /* NewExpression */ || callExpression.expression.kind === 92 /* SuperKeyword */; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target || signature)) { // Get the first signature if there @@ -40560,7 +43134,7 @@ var ts; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(88 /* NewKeyword */)); + displayParts.push(ts.keywordPart(89 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -40576,14 +43150,14 @@ var ts; case ScriptElementKind.parameterElement: case ScriptElementKind.localVariableElement: // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(51 /* ColonToken */)); + displayParts.push(ts.punctuationPart(52 /* ColonToken */)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(88 /* NewKeyword */)); + displayParts.push(ts.keywordPart(89 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - if (!(type.flags & 32768 /* Anonymous */)) { - displayParts.push.apply(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, undefined, 1 /* WriteTypeParametersOrArguments */)); + if (!(type.flags & 65536 /* Anonymous */)) { + ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, undefined, 1 /* WriteTypeParametersOrArguments */)); } addSignatureDisplayParts(signature, allSignatures, 8 /* WriteArrowStyleSignature */); break; @@ -40595,24 +43169,24 @@ var ts; } } else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 114 /* ConstructorKeyword */ && location.parent.kind === 137 /* Constructor */)) { + (location.kind === 118 /* ConstructorKeyword */ && location.parent.kind === 141 /* Constructor */)) { // get the signature from the declaration and write it var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 137 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 141 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 137 /* Constructor */) { + if (functionDeclaration.kind === 141 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 140 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 144 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -40621,43 +43195,52 @@ var ts; } } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo) { - displayParts.push(ts.keywordPart(69 /* ClassKeyword */)); + if (ts.getDeclarationOfKind(symbol, 183 /* ClassExpression */)) { + // Special case for class expressions because we would like to indicate that + // the class name is local to the class body (similar to function expression) + // (local class) class + pushTypePart(ScriptElementKind.localClassElement); + } + else { + // Class declaration has name which is not local. + displayParts.push(ts.keywordPart(70 /* ClassKeyword */)); + } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(103 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(104 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & 524288 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(125 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(129 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(53 /* EqualsToken */)); + displayParts.push(ts.operatorPart(54 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push.apply(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); + ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); } if (symbolFlags & 384 /* Enum */) { addNewLineIfDisplayPartsExist(); if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(70 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(71 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(77 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(78 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 208 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 65 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 119 /* NamespaceKeyword */ : 118 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 215 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 66 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 123 /* NamespaceKeyword */ : 122 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -40669,7 +43252,7 @@ var ts; displayParts.push(ts.spacePart()); addFullSymbolName(symbol); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(86 /* InKeyword */)); + displayParts.push(ts.keywordPart(87 /* InKeyword */)); displayParts.push(ts.spacePart()); if (symbol.parent) { // Class/Interface type parameter @@ -40678,26 +43261,26 @@ var ts; } else { // Method/function type parameter - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 130 /* TypeParameter */).parent; + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 134 /* TypeParameter */).parent; var signature = typeChecker.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 141 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(88 /* NewKeyword */)); + if (signatureDeclaration.kind === 145 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(89 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (signatureDeclaration.kind !== 140 /* CallSignature */ && signatureDeclaration.name) { + else if (signatureDeclaration.kind !== 144 /* CallSignature */ && signatureDeclaration.name) { addFullSymbolName(signatureDeclaration.symbol); } - displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } } if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 229 /* EnumMember */) { + if (declaration.kind === 244 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(53 /* EqualsToken */)); + displayParts.push(ts.operatorPart(54 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(constantValue.toString(), SymbolDisplayPartKind.numericLiteral)); } @@ -40705,17 +43288,17 @@ var ts; } if (symbolFlags & 8388608 /* Alias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(85 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(86 /* ImportKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 211 /* ImportEqualsDeclaration */) { + if (declaration.kind === 218 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(53 /* EqualsToken */)); + displayParts.push(ts.operatorPart(54 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(120 /* RequireKeyword */)); + displayParts.push(ts.keywordPart(124 /* RequireKeyword */)); displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(17 /* CloseParenToken */)); @@ -40724,7 +43307,7 @@ var ts; var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(53 /* EqualsToken */)); + displayParts.push(ts.operatorPart(54 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -40741,17 +43324,17 @@ var ts; if (symbolKind === ScriptElementKind.memberVariableElement || symbolFlags & 3 /* Variable */ || symbolKind === ScriptElementKind.localVariableElement) { - displayParts.push(ts.punctuationPart(51 /* ColonToken */)); + displayParts.push(ts.punctuationPart(52 /* ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplay(type, writer, enclosingDeclaration); }); - displayParts.push.apply(displayParts, typeParameterParts); + ts.addRange(displayParts, typeParameterParts); } else { - displayParts.push.apply(displayParts, ts.typeToDisplayParts(typeChecker, type, enclosingDeclaration)); + ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, type, enclosingDeclaration)); } } else if (symbolFlags & 16 /* Function */ || @@ -40780,7 +43363,7 @@ var ts; } function addFullSymbolName(symbol, enclosingDeclaration) { var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbol, enclosingDeclaration || sourceFile, undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */); - displayParts.push.apply(displayParts, fullSymbolDisplayParts); + ts.addRange(displayParts, fullSymbolDisplayParts); } function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { addNewLineIfDisplayPartsExist(); @@ -40807,11 +43390,11 @@ var ts; } } function addSignatureDisplayParts(signature, allSignatures, flags) { - displayParts.push.apply(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); + ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); displayParts.push(ts.punctuationPart(16 /* OpenParenToken */)); - displayParts.push(ts.operatorPart(33 /* PlusToken */)); + displayParts.push(ts.operatorPart(34 /* PlusToken */)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); @@ -40823,7 +43406,7 @@ var ts; var typeParameterParts = ts.mapToDisplayParts(function (writer) { typeChecker.getSymbolDisplayBuilder().buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration); }); - displayParts.push.apply(displayParts, typeParameterParts); + ts.addRange(displayParts, typeParameterParts); } } function getQuickInfoAtPosition(fileName, position) { @@ -40841,11 +43424,11 @@ var ts; if (!symbol) { // Try getting just type at this position and show switch (node.kind) { - case 65 /* Identifier */: - case 158 /* PropertyAccessExpression */: - case 128 /* QualifiedName */: - case 93 /* ThisKeyword */: - case 91 /* SuperKeyword */: + case 66 /* Identifier */: + case 163 /* PropertyAccessExpression */: + case 132 /* QualifiedName */: + case 94 /* ThisKeyword */: + case 92 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type = typeChecker.getTypeAtLocation(node); if (type) { @@ -40898,10 +43481,10 @@ var ts; function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class - if (isNewExpressionTarget(location) || location.kind === 114 /* ConstructorKeyword */) { + if (isNewExpressionTarget(location) || location.kind === 118 /* ConstructorKeyword */) { if (symbol.flags & 32 /* Class */) { var classDeclaration = symbol.getDeclarations()[0]; - ts.Debug.assert(classDeclaration && classDeclaration.kind === 204 /* ClassDeclaration */); + ts.Debug.assert(classDeclaration && classDeclaration.kind === 211 /* ClassDeclaration */); return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result); } } @@ -40917,8 +43500,8 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 137 /* Constructor */) || - (!selectConstructors && (d.kind === 203 /* FunctionDeclaration */ || d.kind === 136 /* MethodDeclaration */ || d.kind === 135 /* MethodSignature */))) { + if ((selectConstructors && d.kind === 141 /* Constructor */) || + (!selectConstructors && (d.kind === 210 /* FunctionDeclaration */ || d.kind === 140 /* MethodDeclaration */ || d.kind === 139 /* MethodSignature */))) { declarations.push(d); if (d.body) definition = d; @@ -40978,7 +43561,7 @@ var ts; // to jump to the implementation directly. if (symbol.flags & 8388608 /* Alias */) { var declaration = symbol.declarations[0]; - if (node.kind === 65 /* Identifier */ && node.parent === declaration) { + if (node.kind === 66 /* Identifier */ && node.parent === declaration) { symbol = typeChecker.getAliasedSymbol(symbol); } } @@ -40987,7 +43570,7 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 228 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 243 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -41061,12 +43644,12 @@ var ts; }; } function getSemanticDocumentHighlights(node) { - if (node.kind === 65 /* Identifier */ || - node.kind === 93 /* ThisKeyword */ || - node.kind === 91 /* SuperKeyword */ || + if (node.kind === 66 /* Identifier */ || + node.kind === 94 /* ThisKeyword */ || + node.kind === 92 /* SuperKeyword */ || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { - var referencedSymbols = getReferencedSymbolsForNodes(node, sourceFilesToSearch, false, false); + var referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, false, false); return convertReferencedSymbols(referencedSymbols); } return undefined; @@ -41114,76 +43697,76 @@ var ts; function getHighlightSpans(node) { if (node) { switch (node.kind) { - case 84 /* IfKeyword */: - case 76 /* ElseKeyword */: - if (hasKind(node.parent, 186 /* IfStatement */)) { + case 85 /* IfKeyword */: + case 77 /* ElseKeyword */: + if (hasKind(node.parent, 193 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; - case 90 /* ReturnKeyword */: - if (hasKind(node.parent, 194 /* ReturnStatement */)) { + case 91 /* ReturnKeyword */: + if (hasKind(node.parent, 201 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; - case 94 /* ThrowKeyword */: - if (hasKind(node.parent, 198 /* ThrowStatement */)) { + case 95 /* ThrowKeyword */: + if (hasKind(node.parent, 205 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; - case 68 /* CatchKeyword */: - if (hasKind(parent(parent(node)), 199 /* TryStatement */)) { + case 69 /* CatchKeyword */: + if (hasKind(parent(parent(node)), 206 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; - case 96 /* TryKeyword */: - case 81 /* FinallyKeyword */: - if (hasKind(parent(node), 199 /* TryStatement */)) { + case 97 /* TryKeyword */: + case 82 /* FinallyKeyword */: + if (hasKind(parent(node), 206 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent); } break; - case 92 /* SwitchKeyword */: - if (hasKind(node.parent, 196 /* SwitchStatement */)) { + case 93 /* SwitchKeyword */: + if (hasKind(node.parent, 203 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; - case 67 /* CaseKeyword */: - case 73 /* DefaultKeyword */: - if (hasKind(parent(parent(parent(node))), 196 /* SwitchStatement */)) { + case 68 /* CaseKeyword */: + case 74 /* DefaultKeyword */: + if (hasKind(parent(parent(parent(node))), 203 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent.parent); } break; - case 66 /* BreakKeyword */: - case 71 /* ContinueKeyword */: - if (hasKind(node.parent, 193 /* BreakStatement */) || hasKind(node.parent, 192 /* ContinueStatement */)) { + case 67 /* BreakKeyword */: + case 72 /* ContinueKeyword */: + if (hasKind(node.parent, 200 /* BreakStatement */) || hasKind(node.parent, 199 /* ContinueStatement */)) { return getBreakOrContinueStatementOccurences(node.parent); } break; - case 82 /* ForKeyword */: - if (hasKind(node.parent, 189 /* ForStatement */) || - hasKind(node.parent, 190 /* ForInStatement */) || - hasKind(node.parent, 191 /* ForOfStatement */)) { + case 83 /* ForKeyword */: + if (hasKind(node.parent, 196 /* ForStatement */) || + hasKind(node.parent, 197 /* ForInStatement */) || + hasKind(node.parent, 198 /* ForOfStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 100 /* WhileKeyword */: - case 75 /* DoKeyword */: - if (hasKind(node.parent, 188 /* WhileStatement */) || hasKind(node.parent, 187 /* DoStatement */)) { + case 101 /* WhileKeyword */: + case 76 /* DoKeyword */: + if (hasKind(node.parent, 195 /* WhileStatement */) || hasKind(node.parent, 194 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 114 /* ConstructorKeyword */: - if (hasKind(node.parent, 137 /* Constructor */)) { + case 118 /* ConstructorKeyword */: + if (hasKind(node.parent, 141 /* Constructor */)) { return getConstructorOccurrences(node.parent); } break; - case 116 /* GetKeyword */: - case 122 /* SetKeyword */: - if (hasKind(node.parent, 138 /* GetAccessor */) || hasKind(node.parent, 139 /* SetAccessor */)) { + case 120 /* GetKeyword */: + case 126 /* SetKeyword */: + if (hasKind(node.parent, 142 /* GetAccessor */) || hasKind(node.parent, 143 /* SetAccessor */)) { return getGetAndSetOccurrences(node.parent); } default: if (ts.isModifier(node.kind) && node.parent && - (ts.isDeclaration(node.parent) || node.parent.kind === 183 /* VariableStatement */)) { + (ts.isDeclaration(node.parent) || node.parent.kind === 190 /* VariableStatement */)) { return getModifierOccurrences(node.kind, node.parent); } } @@ -41199,10 +43782,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 198 /* ThrowStatement */) { + if (node.kind === 205 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 199 /* TryStatement */) { + else if (node.kind === 206 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchClause) { aggregate(tryStatement.catchClause); @@ -41230,19 +43813,19 @@ var ts; function getThrowStatementOwner(throwStatement) { var child = throwStatement; while (child.parent) { - var parent_11 = child.parent; - if (ts.isFunctionBlock(parent_11) || parent_11.kind === 230 /* SourceFile */) { - return parent_11; + var parent_13 = child.parent; + if (ts.isFunctionBlock(parent_13) || parent_13.kind === 245 /* SourceFile */) { + return parent_13; } // A throw-statement is only owned by a try-statement if the try-statement has // a catch clause, and if the throw-statement occurs within the try block. - if (parent_11.kind === 199 /* TryStatement */) { - var tryStatement = parent_11; + if (parent_13.kind === 206 /* TryStatement */) { + var tryStatement = parent_13; if (tryStatement.tryBlock === child && tryStatement.catchClause) { return child; } } - child = parent_11; + child = parent_13; } return undefined; } @@ -41251,7 +43834,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 193 /* BreakStatement */ || node.kind === 192 /* ContinueStatement */) { + if (node.kind === 200 /* BreakStatement */ || node.kind === 199 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isFunctionLike(node)) { @@ -41267,16 +43850,16 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node_2 = statement.parent; node_2; node_2 = node_2.parent) { switch (node_2.kind) { - case 196 /* SwitchStatement */: - if (statement.kind === 192 /* ContinueStatement */) { + case 203 /* SwitchStatement */: + if (statement.kind === 199 /* ContinueStatement */) { continue; } // Fall through. - case 189 /* ForStatement */: - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: - case 188 /* WhileStatement */: - case 187 /* DoStatement */: + case 196 /* ForStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: + case 195 /* WhileStatement */: + case 194 /* DoStatement */: if (!statement.label || isLabeledBy(node_2, statement.label.text)) { return node_2; } @@ -41295,18 +43878,18 @@ var ts; var container = declaration.parent; // Make sure we only highlight the keyword when it makes sense to do so. if (ts.isAccessibilityModifier(modifier)) { - if (!(container.kind === 204 /* ClassDeclaration */ || - (declaration.kind === 131 /* Parameter */ && hasKind(container, 137 /* Constructor */)))) { + if (!(container.kind === 211 /* ClassDeclaration */ || + (declaration.kind === 135 /* Parameter */ && hasKind(container, 141 /* Constructor */)))) { return undefined; } } - else if (modifier === 109 /* StaticKeyword */) { - if (container.kind !== 204 /* ClassDeclaration */) { + else if (modifier === 110 /* StaticKeyword */) { + if (container.kind !== 211 /* ClassDeclaration */) { return undefined; } } - else if (modifier === 78 /* ExportKeyword */ || modifier === 115 /* DeclareKeyword */) { - if (!(container.kind === 209 /* ModuleBlock */ || container.kind === 230 /* SourceFile */)) { + else if (modifier === 79 /* ExportKeyword */ || modifier === 119 /* DeclareKeyword */) { + if (!(container.kind === 216 /* ModuleBlock */ || container.kind === 245 /* SourceFile */)) { return undefined; } } @@ -41318,20 +43901,20 @@ var ts; var modifierFlag = getFlagFromModifier(modifier); var nodes; switch (container.kind) { - case 209 /* ModuleBlock */: - case 230 /* SourceFile */: + case 216 /* ModuleBlock */: + case 245 /* SourceFile */: nodes = container.statements; break; - case 137 /* Constructor */: + case 141 /* Constructor */: nodes = container.parameters.concat(container.parent.members); break; - case 204 /* ClassDeclaration */: + case 211 /* ClassDeclaration */: nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. if (modifierFlag & 112 /* AccessibilityModifier */) { var constructor = ts.forEach(container.members, function (member) { - return member.kind === 137 /* Constructor */ && member; + return member.kind === 141 /* Constructor */ && member; }); if (constructor) { nodes = nodes.concat(constructor.parameters); @@ -41349,17 +43932,17 @@ var ts; return ts.map(keywords, getHighlightSpanForNode); function getFlagFromModifier(modifier) { switch (modifier) { - case 108 /* PublicKeyword */: + case 109 /* PublicKeyword */: return 16 /* Public */; - case 106 /* PrivateKeyword */: + case 107 /* PrivateKeyword */: return 32 /* Private */; - case 107 /* ProtectedKeyword */: + case 108 /* ProtectedKeyword */: return 64 /* Protected */; - case 109 /* StaticKeyword */: + case 110 /* StaticKeyword */: return 128 /* Static */; - case 78 /* ExportKeyword */: + case 79 /* ExportKeyword */: return 1 /* Export */; - case 115 /* DeclareKeyword */: + case 119 /* DeclareKeyword */: return 2 /* Ambient */; default: ts.Debug.fail(); @@ -41379,13 +43962,13 @@ var ts; } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 138 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 139 /* SetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 142 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 143 /* SetAccessor */); return ts.map(keywords, getHighlightSpanForNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 116 /* GetKeyword */, 122 /* SetKeyword */); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 120 /* GetKeyword */, 126 /* SetKeyword */); }); } } } @@ -41394,19 +43977,19 @@ var ts; var keywords = []; ts.forEach(declarations, function (declaration) { ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 114 /* ConstructorKeyword */); + return pushKeywordIf(keywords, token, 118 /* ConstructorKeyword */); }); }); return ts.map(keywords, getHighlightSpanForNode); } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 82 /* ForKeyword */, 100 /* WhileKeyword */, 75 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 83 /* ForKeyword */, 101 /* WhileKeyword */, 76 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 187 /* DoStatement */) { + if (loopNode.kind === 194 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 100 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 101 /* WhileKeyword */)) { break; } } @@ -41415,7 +43998,7 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 66 /* BreakKeyword */, 71 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 67 /* BreakKeyword */, 72 /* ContinueKeyword */); } }); return ts.map(keywords, getHighlightSpanForNode); @@ -41424,13 +44007,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 189 /* ForStatement */: - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: - case 187 /* DoStatement */: - case 188 /* WhileStatement */: + case 196 /* ForStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: + case 194 /* DoStatement */: + case 195 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 196 /* SwitchStatement */: + case 203 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -41438,14 +44021,14 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 92 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 93 /* SwitchKeyword */); // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 67 /* CaseKeyword */, 73 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 68 /* CaseKeyword */, 74 /* DefaultKeyword */); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 66 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 67 /* BreakKeyword */); } }); }); @@ -41453,13 +44036,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 96 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 97 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 68 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 69 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 81 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 81 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 82 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 82 /* FinallyKeyword */); } return ts.map(keywords, getHighlightSpanForNode); } @@ -41470,13 +44053,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 94 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 95 /* ThrowKeyword */); }); // If the "owner" is a function, then we equate 'return' and 'throw' statements in their // ability to "jump out" of the function, and include occurrences for both. if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 90 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 91 /* ReturnKeyword */); }); } return ts.map(keywords, getHighlightSpanForNode); @@ -41484,36 +44067,36 @@ var ts; function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); // If we didn't find a containing function with a block body, bail out. - if (!(func && hasKind(func.body, 182 /* Block */))) { + if (!(func && hasKind(func.body, 189 /* Block */))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 90 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 91 /* ReturnKeyword */); }); // Include 'throw' statements that do not occur within a try block. ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 94 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 95 /* ThrowKeyword */); }); return ts.map(keywords, getHighlightSpanForNode); } function getIfElseOccurrences(ifStatement) { var keywords = []; // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 186 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 193 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. while (ifStatement) { var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 84 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 85 /* IfKeyword */); // Generally the 'else' keyword is second-to-last, so we traverse backwards. for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 76 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 77 /* ElseKeyword */)) { break; } } - if (!hasKind(ifStatement.elseStatement, 186 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 193 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -41522,7 +44105,7 @@ var ts; // We'd like to highlight else/ifs together if they are only separated by whitespace // (i.e. the keywords are separated by no comments, no newlines). for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 76 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 77 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombindElseAndIf = true; @@ -41604,7 +44187,7 @@ var ts; if (!node) { return undefined; } - if (node.kind !== 65 /* Identifier */ && + if (node.kind !== 66 /* Identifier */ && // TODO (drosen): This should be enabled in a later release - currently breaks rename. //node.kind !== SyntaxKind.ThisKeyword && //node.kind !== SyntaxKind.SuperKeyword && @@ -41612,10 +44195,10 @@ var ts; !isNameOfExternalModuleImportOrDeclaration(node)) { return undefined; } - ts.Debug.assert(node.kind === 65 /* Identifier */ || node.kind === 7 /* NumericLiteral */ || node.kind === 8 /* StringLiteral */); - return getReferencedSymbolsForNodes(node, program.getSourceFiles(), findInStrings, findInComments); + ts.Debug.assert(node.kind === 66 /* Identifier */ || node.kind === 7 /* NumericLiteral */ || node.kind === 8 /* StringLiteral */); + return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); } - function getReferencedSymbolsForNodes(node, sourceFiles, findInStrings, findInComments) { + function getReferencedSymbolsForNode(node, sourceFiles, findInStrings, findInComments) { var typeChecker = program.getTypeChecker(); // Labels if (isLabelName(node)) { @@ -41630,10 +44213,10 @@ var ts; return getLabelReferencesInNode(node.parent, node); } } - if (node.kind === 93 /* ThisKeyword */) { + if (node.kind === 94 /* ThisKeyword */) { return getReferencesForThisKeyword(node, sourceFiles); } - if (node.kind === 91 /* SuperKeyword */) { + if (node.kind === 92 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } var symbol = typeChecker.getSymbolAtLocation(node); @@ -41643,15 +44226,16 @@ var ts; return undefined; } var declarations = symbol.declarations; - // The symbol was an internal symbol and does not have a declaration e.g.undefined symbol + // The symbol was an internal symbol and does not have a declaration e.g. undefined symbol if (!declarations || !declarations.length) { return undefined; } var result; // Compute the meaning from the location and the symbol it references var searchMeaning = getIntersectingMeaningFromDeclarations(getMeaningFromLocation(node), declarations); - // Get the text to search for, we need to normalize it as external module names will have quote - var declaredName = getDeclaredName(symbol, node); + // Get the text to search for. + // Note: if this is an external module symbol, the name doesn't include quotes. + var declaredName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); // Try to get the smallest valid scope that we can limit our search to; // otherwise we'll need to search globally (i.e. include each file). var scope = getSymbolScope(symbol); @@ -41690,70 +44274,43 @@ var ts; textSpan: ts.createTextSpan(declarations[0].getStart(), 0) }; } - function isImportOrExportSpecifierName(location) { - return location.parent && - (location.parent.kind === 216 /* ImportSpecifier */ || location.parent.kind === 220 /* ExportSpecifier */) && - location.parent.propertyName === location; - } function isImportOrExportSpecifierImportSymbol(symbol) { return (symbol.flags & 8388608 /* Alias */) && ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 216 /* ImportSpecifier */ || declaration.kind === 220 /* ExportSpecifier */; + return declaration.kind === 223 /* ImportSpecifier */ || declaration.kind === 227 /* ExportSpecifier */; }); } - function getDeclaredName(symbol, location) { - // Special case for function expressions, whose names are solely local to their bodies. - var functionExpression = ts.forEach(symbol.declarations, function (d) { return d.kind === 165 /* FunctionExpression */ ? d : undefined; }); - // When a name gets interned into a SourceFile's 'identifiers' Map, - // its name is escaped and stored in the same way its symbol name/identifier - // name should be stored. Function expressions, however, are a special case, - // because despite sometimes having a name, the binder unconditionally binds them - // to a symbol with the name "__function". - var name; - if (functionExpression && functionExpression.name) { - name = functionExpression.name.text; - } - // If this is an export or import specifier it could have been renamed using the as syntax. - // if so we want to search for whatever under the cursor, the symbol is pointing to the alias (name) - // so check for the propertyName. - if (isImportOrExportSpecifierName(location)) { - return location.getText(); - } - name = typeChecker.symbolToString(symbol); - return stripQuotes(name); - } function getInternedName(symbol, location, declarations) { - // If this is an export or import specifier it could have been renamed using the as syntax. - // if so we want to search for whatever under the cursor, the symbol is pointing to the alias (name) - // so check for the propertyName. - if (isImportOrExportSpecifierName(location)) { + // If this is an export or import specifier it could have been renamed using the 'as' syntax. + // If so we want to search for whatever under the cursor. + if (ts.isImportOrExportSpecifierName(location)) { return location.getText(); } - // Special case for function expressions, whose names are solely local to their bodies. - var functionExpression = ts.forEach(declarations, function (d) { return d.kind === 165 /* FunctionExpression */ ? d : undefined; }); - // When a name gets interned into a SourceFile's 'identifiers' Map, - // its name is escaped and stored in the same way its symbol name/identifier - // name should be stored. Function expressions, however, are a special case, - // because despite sometimes having a name, the binder unconditionally binds them - // to a symbol with the name "__function". - var name = functionExpression && functionExpression.name - ? functionExpression.name.text - : symbol.name; - return stripQuotes(name); - } - function stripQuotes(name) { - var length = name.length; - if (length >= 2 && name.charCodeAt(0) === 34 /* doubleQuote */ && name.charCodeAt(length - 1) === 34 /* doubleQuote */) { - return name.substring(1, length - 1); - } - ; - return name; + // Try to get the local symbol if we're dealing with an 'export default' + // since that symbol has the "true" name. + var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); + symbol = localExportDefaultSymbol || symbol; + return ts.stripQuotes(symbol.name); } + /** + * Determines the smallest scope in which a symbol may have named references. + * Note that not every construct has been accounted for. This function can + * probably be improved. + * + * @returns undefined if the scope cannot be determined, implying that + * a reference to a symbol can occur anywhere. + */ function getSymbolScope(symbol) { + // If this is the symbol of a named function expression or named class expression, + // then named references are limited to its own scope. + var valueDeclaration = symbol.valueDeclaration; + if (valueDeclaration && (valueDeclaration.kind === 170 /* FunctionExpression */ || valueDeclaration.kind === 183 /* ClassExpression */)) { + return valueDeclaration; + } // If this is private property or method, the scope is the containing class if (symbol.flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32 /* Private */) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 204 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 211 /* ClassDeclaration */); } } // If the symbol is an import we would like to find it if we are looking for what it imports. @@ -41763,7 +44320,7 @@ var ts; } // if this symbol is visible from its parent container, e.g. exported, then bail out // if symbol correspond to the union property - bail out - if (symbol.parent || (symbol.flags & 268435456 /* UnionProperty */)) { + if (symbol.parent || (symbol.flags & 268435456 /* SyntheticProperty */)) { return undefined; } var scope = undefined; @@ -41779,7 +44336,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (container.kind === 230 /* SourceFile */ && !ts.isExternalModule(container)) { + if (container.kind === 245 /* SourceFile */ && !ts.isExternalModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -41850,7 +44407,7 @@ var ts; if (node) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 65 /* Identifier */: + case 66 /* Identifier */: return node.getWidth() === searchSymbolName.length; case 8 /* StringLiteral */: if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || @@ -41967,13 +44524,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 137 /* Constructor */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 141 /* Constructor */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -41986,7 +44543,7 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 91 /* SuperKeyword */) { + if (!node || node.kind !== 92 /* SuperKeyword */) { return; } var container = ts.getSuperContainer(node, false); @@ -42005,27 +44562,27 @@ var ts; // Whether 'this' occurs in a static context within a class. var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // fall through - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: - case 137 /* Constructor */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: + case 141 /* Constructor */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 230 /* SourceFile */: + case 245 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } // Fall through - case 203 /* FunctionDeclaration */: - case 165 /* FunctionExpression */: + case 210 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: break; // Computed properties in classes are not handled here because references to this are illegal, // so there is no point finding references to them. @@ -42034,7 +44591,7 @@ var ts; } var references = []; var possiblePositions; - if (searchSpaceNode.kind === 230 /* SourceFile */) { + if (searchSpaceNode.kind === 245 /* SourceFile */) { ts.forEach(sourceFiles, function (sourceFile) { possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); @@ -42060,32 +44617,32 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 93 /* ThisKeyword */) { + if (!node || node.kind !== 94 /* ThisKeyword */) { return; } var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { - case 165 /* FunctionExpression */: - case 203 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: + case 210 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 204 /* ClassDeclaration */: + case 211 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128 /* Static */) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 230 /* SourceFile */: - if (container.kind === 230 /* SourceFile */ && !ts.isExternalModule(container)) { + case 245 /* SourceFile */: + if (container.kind === 245 /* SourceFile */ && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -42105,7 +44662,7 @@ var ts; // type to the search set if (isNameOfPropertyAssignment(location)) { ts.forEach(getPropertySymbolsFromContextualType(location), function (contextualSymbol) { - result.push.apply(result, typeChecker.getRootSymbols(contextualSymbol)); + ts.addRange(result, typeChecker.getRootSymbols(contextualSymbol)); }); /* Because in short-hand property assignment, location has two meaning : property name and as value of the property * When we do findAllReference at the position of the short-hand property assignment, we would want to have references to position of @@ -42139,11 +44696,11 @@ var ts; function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { if (symbol && symbol.flags & (32 /* Class */ | 64 /* Interface */)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 204 /* ClassDeclaration */) { + if (declaration.kind === 211 /* ClassDeclaration */) { getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); } - else if (declaration.kind === 205 /* InterfaceDeclaration */) { + else if (declaration.kind === 212 /* InterfaceDeclaration */) { ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); } }); @@ -42204,19 +44761,19 @@ var ts; if (isNameOfPropertyAssignment(node)) { var objectLiteral = node.parent.parent; var contextualType = typeChecker.getContextualType(objectLiteral); - var name_28 = node.text; + var name_32 = node.text; if (contextualType) { if (contextualType.flags & 16384 /* Union */) { // This is a union type, first see if the property we are looking for is a union property (i.e. exists in all types) // if not, search the constituent types for the property - var unionProperty = contextualType.getProperty(name_28); + var unionProperty = contextualType.getProperty(name_32); if (unionProperty) { return [unionProperty]; } else { var result_4 = []; ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name_28); + var symbol = t.getProperty(name_32); if (symbol) { result_4.push(symbol); } @@ -42225,7 +44782,7 @@ var ts; } } else { - var symbol_1 = contextualType.getProperty(name_28); + var symbol_1 = contextualType.getProperty(name_32); if (symbol_1) { return [symbol_1]; } @@ -42278,17 +44835,17 @@ var ts; } /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ function isWriteAccess(node) { - if (node.kind === 65 /* Identifier */ && ts.isDeclarationName(node)) { + if (node.kind === 66 /* Identifier */ && ts.isDeclarationName(node)) { return true; } var parent = node.parent; if (parent) { - if (parent.kind === 171 /* PostfixUnaryExpression */ || parent.kind === 170 /* PrefixUnaryExpression */) { + if (parent.kind === 177 /* PostfixUnaryExpression */ || parent.kind === 176 /* PrefixUnaryExpression */) { return true; } - else if (parent.kind === 172 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 178 /* BinaryExpression */ && parent.left === node) { var operator = parent.operatorToken.kind; - return 53 /* FirstAssignment */ <= operator && operator <= 64 /* LastAssignment */; + return 54 /* FirstAssignment */ <= operator && operator <= 65 /* LastAssignment */; } } return false; @@ -42312,7 +44869,7 @@ var ts; text: data }); } - var emitOutput = program.emit(sourceFile, writeFile); + var emitOutput = program.emit(sourceFile, writeFile, cancellationToken); return { outputFiles: outputFiles, emitSkipped: emitOutput.emitSkipped @@ -42320,33 +44877,33 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 131 /* Parameter */: - case 201 /* VariableDeclaration */: - case 155 /* BindingElement */: - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: - case 227 /* PropertyAssignment */: - case 228 /* ShorthandPropertyAssignment */: - case 229 /* EnumMember */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 137 /* Constructor */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 203 /* FunctionDeclaration */: - case 165 /* FunctionExpression */: - case 166 /* ArrowFunction */: - case 226 /* CatchClause */: + case 135 /* Parameter */: + case 208 /* VariableDeclaration */: + case 160 /* BindingElement */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: + case 242 /* PropertyAssignment */: + case 243 /* ShorthandPropertyAssignment */: + case 244 /* EnumMember */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 141 /* Constructor */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 210 /* FunctionDeclaration */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: + case 241 /* CatchClause */: return 1 /* Value */; - case 130 /* TypeParameter */: - case 205 /* InterfaceDeclaration */: - case 206 /* TypeAliasDeclaration */: - case 148 /* TypeLiteral */: + case 134 /* TypeParameter */: + case 212 /* InterfaceDeclaration */: + case 213 /* TypeAliasDeclaration */: + case 152 /* TypeLiteral */: return 2 /* Type */; - case 204 /* ClassDeclaration */: - case 207 /* EnumDeclaration */: + case 211 /* ClassDeclaration */: + case 214 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: if (node.name.kind === 8 /* StringLiteral */) { return 4 /* Namespace */ | 1 /* Value */; } @@ -42356,15 +44913,15 @@ var ts; else { return 4 /* Namespace */; } - case 215 /* NamedImports */: - case 216 /* ImportSpecifier */: - case 211 /* ImportEqualsDeclaration */: - case 212 /* ImportDeclaration */: - case 217 /* ExportAssignment */: - case 218 /* ExportDeclaration */: + case 222 /* NamedImports */: + case 223 /* ImportSpecifier */: + case 218 /* ImportEqualsDeclaration */: + case 219 /* ImportDeclaration */: + case 224 /* ExportAssignment */: + case 225 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 230 /* SourceFile */: + case 245 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; @@ -42374,8 +44931,8 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 144 /* TypeReference */ || - (node.parent.kind === 179 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); + return node.parent.kind === 148 /* TypeReference */ || + (node.parent.kind === 185 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)); } function isNamespaceReference(node) { return isQualifiedNameNamespaceReference(node) || isPropertyAccessNamespaceReference(node); @@ -42383,50 +44940,50 @@ var ts; function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 158 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 158 /* PropertyAccessExpression */) { + if (root.parent.kind === 163 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 163 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 179 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 225 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 185 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 240 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 204 /* ClassDeclaration */ && root.parent.parent.token === 102 /* ImplementsKeyword */) || - (decl.kind === 205 /* InterfaceDeclaration */ && root.parent.parent.token === 79 /* ExtendsKeyword */); + return (decl.kind === 211 /* ClassDeclaration */ && root.parent.parent.token === 103 /* ImplementsKeyword */) || + (decl.kind === 212 /* InterfaceDeclaration */ && root.parent.parent.token === 80 /* ExtendsKeyword */); } return false; } function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 128 /* QualifiedName */) { - while (root.parent && root.parent.kind === 128 /* QualifiedName */) { + if (root.parent.kind === 132 /* QualifiedName */) { + while (root.parent && root.parent.kind === 132 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 144 /* TypeReference */ && !isLastClause; + return root.parent.kind === 148 /* TypeReference */ && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 128 /* QualifiedName */) { + while (node.parent.kind === 132 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; } function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 65 /* Identifier */); + ts.Debug.assert(node.kind === 66 /* Identifier */); // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (node.parent.kind === 128 /* QualifiedName */ && + if (node.parent.kind === 132 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 211 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 218 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function getMeaningFromLocation(node) { - if (node.parent.kind === 217 /* ExportAssignment */) { + if (node.parent.kind === 224 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -42466,15 +45023,15 @@ var ts; return; } switch (node.kind) { - case 158 /* PropertyAccessExpression */: - case 128 /* QualifiedName */: + case 163 /* PropertyAccessExpression */: + case 132 /* QualifiedName */: case 8 /* StringLiteral */: - case 80 /* FalseKeyword */: - case 95 /* TrueKeyword */: - case 89 /* NullKeyword */: - case 91 /* SuperKeyword */: - case 93 /* ThisKeyword */: - case 65 /* Identifier */: + case 81 /* FalseKeyword */: + case 96 /* TrueKeyword */: + case 90 /* NullKeyword */: + case 92 /* SuperKeyword */: + case 94 /* ThisKeyword */: + case 66 /* Identifier */: break; // Cant create the text span default: @@ -42490,7 +45047,7 @@ var ts; // If this is name of a module declarations, check if this is right side of dotted module name // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of // Then this name is name from dotted module - if (nodeForStartPos.parent.parent.kind === 208 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 215 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -42519,6 +45076,25 @@ var ts; function getSemanticClassifications(fileName, span) { return convertClassifications(getEncodedSemanticClassifications(fileName, span)); } + function checkForClassificationCancellation(kind) { + // We don't want to actually call back into our host on every node to find out if we've + // been canceled. That would be an enormous amount of chattyness, along with the all + // the overhead of marshalling the data to/from the host. So instead we pick a few + // reasonable node kinds to bother checking on. These node kinds represent high level + // constructs that we would expect to see commonly, but just at a far less frequent + // interval. + // + // For example, in checker.ts (around 750k) we only have around 600 of these constructs. + // That means we're calling back into the host around every 1.2k of the file we process. + // Lib.d.ts has similar numbers. + switch (kind) { + case 215 /* ModuleDeclaration */: + case 211 /* ClassDeclaration */: + case 212 /* InterfaceDeclaration */: + case 210 /* FunctionDeclaration */: + cancellationToken.throwIfCancellationRequested(); + } + } function getEncodedSemanticClassifications(fileName, span) { synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); @@ -42569,7 +45145,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 208 /* ModuleDeclaration */ && + return declaration.kind === 215 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } @@ -42577,7 +45153,9 @@ var ts; function processNode(node) { // Only walk into nodes that intersect the requested span. if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { - if (node.kind === 65 /* Identifier */ && !ts.nodeIsMissing(node)) { + var kind = node.kind; + checkForClassificationCancellation(kind); + if (kind === 66 /* Identifier */ && !ts.nodeIsMissing(node)) { var identifier = node; // Only bother calling into the typechecker if this is an identifier that // could possibly resolve to a type name. This makes classification run @@ -42638,8 +45216,8 @@ var ts; var spanStart = span.start; var spanLength = span.length; // Make a scanner we can get trivia from. - var triviaScanner = ts.createScanner(2 /* Latest */, false, sourceFile.text); - var mergeConflictScanner = ts.createScanner(2 /* Latest */, false, sourceFile.text); + var triviaScanner = ts.createScanner(2 /* Latest */, false, sourceFile.languageVariant, sourceFile.text); + var mergeConflictScanner = ts.createScanner(2 /* Latest */, false, sourceFile.languageVariant, sourceFile.text); var result = []; processElement(sourceFile); return { spans: result, endOfLineState: 0 /* None */ }; @@ -42722,16 +45300,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); pos = tag.tagName.end; switch (tag.kind) { - case 249 /* JSDocParameterTag */: + case 264 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 252 /* JSDocTemplateTag */: + case 267 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); break; - case 251 /* JSDocTypeTag */: + case 266 /* JSDocTypeTag */: processElement(tag.typeExpression); break; - case 250 /* JSDocReturnTag */: + case 265 /* JSDocReturnTag */: processElement(tag.typeExpression); break; } @@ -42811,7 +45389,7 @@ var ts; } // Special case < and > If they appear in a generic context they are punctuation, // not operators. - if (tokenKind === 24 /* LessThanToken */ || tokenKind === 25 /* GreaterThanToken */) { + if (tokenKind === 24 /* LessThanToken */ || tokenKind === 26 /* GreaterThanToken */) { // If the node owning the token has a type argument list or type parameter list, then // we can effectively assume that a '<' and '>' belong to those lists. if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { @@ -42820,18 +45398,18 @@ var ts; } if (ts.isPunctuation(tokenKind)) { if (token) { - if (tokenKind === 53 /* EqualsToken */) { + if (tokenKind === 54 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 201 /* VariableDeclaration */ || - token.parent.kind === 134 /* PropertyDeclaration */ || - token.parent.kind === 131 /* Parameter */) { + if (token.parent.kind === 208 /* VariableDeclaration */ || + token.parent.kind === 138 /* PropertyDeclaration */ || + token.parent.kind === 135 /* Parameter */) { return 5 /* operator */; } } - if (token.parent.kind === 172 /* BinaryExpression */ || - token.parent.kind === 170 /* PrefixUnaryExpression */ || - token.parent.kind === 171 /* PostfixUnaryExpression */ || - token.parent.kind === 173 /* ConditionalExpression */) { + if (token.parent.kind === 178 /* BinaryExpression */ || + token.parent.kind === 176 /* PrefixUnaryExpression */ || + token.parent.kind === 177 /* PostfixUnaryExpression */ || + token.parent.kind === 179 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -42851,35 +45429,35 @@ var ts; // TODO (drosen): we should *also* get another classification type for these literals. return 6 /* stringLiteral */; } - else if (tokenKind === 65 /* Identifier */) { + else if (tokenKind === 66 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 204 /* ClassDeclaration */: + case 211 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 130 /* TypeParameter */: + case 134 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 205 /* InterfaceDeclaration */: + case 212 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 207 /* EnumDeclaration */: + case 214 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 131 /* Parameter */: + case 135 /* Parameter */: if (token.parent.name === token) { return 17 /* parameterName */; } @@ -42895,6 +45473,7 @@ var ts; } // Ignore nodes that don't intersect the original span to classify. if (ts.decodedTextSpanIntersectsWith(spanStart, spanLength, element.pos, element.getFullWidth())) { + checkForClassificationCancellation(element.kind); var children = element.getChildren(sourceFile); for (var i = 0, n = children.length; i < n; i++) { var child = children[i]; @@ -42947,11 +45526,11 @@ var ts; case 14 /* OpenBraceToken */: return 15 /* CloseBraceToken */; case 16 /* OpenParenToken */: return 17 /* CloseParenToken */; case 18 /* OpenBracketToken */: return 19 /* CloseBracketToken */; - case 24 /* LessThanToken */: return 25 /* GreaterThanToken */; + case 24 /* LessThanToken */: return 26 /* GreaterThanToken */; case 15 /* CloseBraceToken */: return 14 /* OpenBraceToken */; case 17 /* CloseParenToken */: return 16 /* OpenParenToken */; case 19 /* CloseBracketToken */: return 18 /* OpenBracketToken */; - case 25 /* GreaterThanToken */: return 24 /* LessThanToken */; + case 26 /* GreaterThanToken */: return 24 /* LessThanToken */; } return undefined; } @@ -43116,7 +45695,7 @@ var ts; var typeChecker = program.getTypeChecker(); var node = ts.getTouchingWord(sourceFile, position); // Can only rename an identifier. - if (node && node.kind === 65 /* Identifier */) { + if (node && node.kind === 66 /* Identifier */) { var symbol = typeChecker.getSymbolAtLocation(node); // Only allow a symbol to be renamed if it actually has at least one declaration. if (symbol) { @@ -43128,17 +45707,19 @@ var ts; for (var _i = 0; _i < declarations.length; _i++) { var current = declarations[_i]; var sourceFile_2 = current.getSourceFile(); + var canonicalName = getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)); if (sourceFile_2 && getCanonicalFileName(ts.normalizePath(sourceFile_2.fileName)) === getCanonicalFileName(ts.normalizePath(defaultLibFileName))) { return getRenameInfoError(ts.getLocaleSpecificMessage(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library.key)); } } } + var displayName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); var kind = getSymbolKind(symbol, node); if (kind) { return { canRename: true, localizedErrorMessage: undefined, - displayName: symbol.name, + displayName: displayName, fullDisplayName: typeChecker.getFullyQualifiedName(symbol), kind: kind, kindModifiers: getSymbolModifiers(symbol), @@ -43214,7 +45795,7 @@ var ts; sourceFile.nameTable = nameTable; function walk(node) { switch (node.kind) { - case 65 /* Identifier */: + case 66 /* Identifier */: nameTable[node.text] = node.text; break; case 8 /* StringLiteral */: @@ -43224,7 +45805,7 @@ var ts; // then we want 'something' to be in the name table. Similarly, if we have // "a['propname']" then we want to store "propname" in the name table. if (ts.isDeclarationName(node) || - node.parent.kind === 222 /* ExternalModuleReference */ || + node.parent.kind === 229 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node)) { nameTable[node.text] = node.text; } @@ -43237,7 +45818,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 159 /* ElementAccessExpression */ && + node.parent.kind === 164 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /// Classifier @@ -43248,18 +45829,18 @@ var ts; /// we have a series of divide operator. this list allows us to be more accurate by ruling out /// locations where a regexp cannot exist. var noRegexTable = []; - noRegexTable[65 /* Identifier */] = true; + noRegexTable[66 /* Identifier */] = true; noRegexTable[8 /* StringLiteral */] = true; noRegexTable[7 /* NumericLiteral */] = true; noRegexTable[9 /* RegularExpressionLiteral */] = true; - noRegexTable[93 /* ThisKeyword */] = true; - noRegexTable[38 /* PlusPlusToken */] = true; - noRegexTable[39 /* MinusMinusToken */] = true; + noRegexTable[94 /* ThisKeyword */] = true; + noRegexTable[39 /* PlusPlusToken */] = true; + noRegexTable[40 /* MinusMinusToken */] = true; noRegexTable[17 /* CloseParenToken */] = true; noRegexTable[19 /* CloseBracketToken */] = true; noRegexTable[15 /* CloseBraceToken */] = true; - noRegexTable[95 /* TrueKeyword */] = true; - noRegexTable[80 /* FalseKeyword */] = true; + noRegexTable[96 /* TrueKeyword */] = true; + noRegexTable[81 /* FalseKeyword */] = true; // Just a stack of TemplateHeads and OpenCurlyBraces, used to perform rudimentary (inexact) // classification on template strings. Because of the context free nature of templates, // the only precise way to classify a template portion would be by propagating the stack across @@ -43284,10 +45865,10 @@ var ts; /** Returns true if 'keyword2' can legally follow 'keyword1' in any language construct. */ function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { - if (keyword2 === 116 /* GetKeyword */ || - keyword2 === 122 /* SetKeyword */ || - keyword2 === 114 /* ConstructorKeyword */ || - keyword2 === 109 /* StaticKeyword */) { + if (keyword2 === 120 /* GetKeyword */ || + keyword2 === 126 /* SetKeyword */ || + keyword2 === 118 /* ConstructorKeyword */ || + keyword2 === 110 /* StaticKeyword */) { // Allow things like "public get", "public constructor" and "public static". // These are all legal. return true; @@ -43417,42 +45998,42 @@ var ts; do { token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 36 /* SlashToken */ || token === 57 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { + if ((token === 37 /* SlashToken */ || token === 58 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { if (scanner.reScanSlashToken() === 9 /* RegularExpressionLiteral */) { token = 9 /* RegularExpressionLiteral */; } } else if (lastNonTriviaToken === 20 /* DotToken */ && isKeyword(token)) { - token = 65 /* Identifier */; + token = 66 /* Identifier */; } else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { // We have two keywords in a row. Only treat the second as a keyword if // it's a sequence that could legally occur in the language. Otherwise // treat it as an identifier. This way, if someone writes "private var" // we recognize that 'var' is actually an identifier here. - token = 65 /* Identifier */; + token = 66 /* Identifier */; } - else if (lastNonTriviaToken === 65 /* Identifier */ && + else if (lastNonTriviaToken === 66 /* Identifier */ && token === 24 /* LessThanToken */) { // Could be the start of something generic. Keep track of that by bumping // up the current count of generic contexts we may be in. angleBracketStack++; } - else if (token === 25 /* GreaterThanToken */ && angleBracketStack > 0) { + else if (token === 26 /* GreaterThanToken */ && angleBracketStack > 0) { // If we think we're currently in something generic, then mark that that // generic entity is complete. angleBracketStack--; } - else if (token === 112 /* AnyKeyword */ || - token === 123 /* StringKeyword */ || - token === 121 /* NumberKeyword */ || - token === 113 /* BooleanKeyword */ || - token === 124 /* SymbolKeyword */) { + else if (token === 114 /* AnyKeyword */ || + token === 127 /* StringKeyword */ || + token === 125 /* NumberKeyword */ || + token === 117 /* BooleanKeyword */ || + token === 128 /* SymbolKeyword */) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, // causing a noisy experience for the user. - token = 65 /* Identifier */; + token = 66 /* Identifier */; } } else if (token === 11 /* TemplateHead */) { @@ -43563,41 +46144,41 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 35 /* AsteriskToken */: - case 36 /* SlashToken */: - case 37 /* PercentToken */: - case 33 /* PlusToken */: - case 34 /* MinusToken */: - case 40 /* LessThanLessThanToken */: - case 41 /* GreaterThanGreaterThanToken */: - case 42 /* GreaterThanGreaterThanGreaterThanToken */: + case 36 /* AsteriskToken */: + case 37 /* SlashToken */: + case 38 /* PercentToken */: + case 34 /* PlusToken */: + case 35 /* MinusToken */: + case 41 /* LessThanLessThanToken */: + case 42 /* GreaterThanGreaterThanToken */: + case 43 /* GreaterThanGreaterThanGreaterThanToken */: case 24 /* LessThanToken */: - case 25 /* GreaterThanToken */: - case 26 /* LessThanEqualsToken */: - case 27 /* GreaterThanEqualsToken */: - case 87 /* InstanceOfKeyword */: - case 86 /* InKeyword */: - case 28 /* EqualsEqualsToken */: - case 29 /* ExclamationEqualsToken */: - case 30 /* EqualsEqualsEqualsToken */: - case 31 /* ExclamationEqualsEqualsToken */: - case 43 /* AmpersandToken */: - case 45 /* CaretToken */: - case 44 /* BarToken */: - case 48 /* AmpersandAmpersandToken */: - case 49 /* BarBarToken */: - case 63 /* BarEqualsToken */: - case 62 /* AmpersandEqualsToken */: - case 64 /* CaretEqualsToken */: - case 59 /* LessThanLessThanEqualsToken */: - case 60 /* GreaterThanGreaterThanEqualsToken */: - case 61 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 54 /* PlusEqualsToken */: - case 55 /* MinusEqualsToken */: - case 56 /* AsteriskEqualsToken */: - case 57 /* SlashEqualsToken */: - case 58 /* PercentEqualsToken */: - case 53 /* EqualsToken */: + case 26 /* GreaterThanToken */: + case 27 /* LessThanEqualsToken */: + case 28 /* GreaterThanEqualsToken */: + case 88 /* InstanceOfKeyword */: + case 87 /* InKeyword */: + case 29 /* EqualsEqualsToken */: + case 30 /* ExclamationEqualsToken */: + case 31 /* EqualsEqualsEqualsToken */: + case 32 /* ExclamationEqualsEqualsToken */: + case 44 /* AmpersandToken */: + case 46 /* CaretToken */: + case 45 /* BarToken */: + case 49 /* AmpersandAmpersandToken */: + case 50 /* BarBarToken */: + case 64 /* BarEqualsToken */: + case 63 /* AmpersandEqualsToken */: + case 65 /* CaretEqualsToken */: + case 60 /* LessThanLessThanEqualsToken */: + case 61 /* GreaterThanGreaterThanEqualsToken */: + case 62 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 55 /* PlusEqualsToken */: + case 56 /* MinusEqualsToken */: + case 57 /* AsteriskEqualsToken */: + case 58 /* SlashEqualsToken */: + case 59 /* PercentEqualsToken */: + case 54 /* EqualsToken */: case 23 /* CommaToken */: return true; default: @@ -43606,19 +46187,19 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 33 /* PlusToken */: - case 34 /* MinusToken */: - case 47 /* TildeToken */: - case 46 /* ExclamationToken */: - case 38 /* PlusPlusToken */: - case 39 /* MinusMinusToken */: + case 34 /* PlusToken */: + case 35 /* MinusToken */: + case 48 /* TildeToken */: + case 47 /* ExclamationToken */: + case 39 /* PlusPlusToken */: + case 40 /* MinusMinusToken */: return true; default: return false; } } function isKeyword(token) { - return token >= 66 /* FirstKeyword */ && token <= 127 /* LastKeyword */; + return token >= 67 /* FirstKeyword */ && token <= 131 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { @@ -43627,7 +46208,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 14 /* FirstPunctuation */ && token <= 64 /* LastPunctuation */) { + else if (token >= 14 /* FirstPunctuation */ && token <= 65 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { @@ -43644,7 +46225,7 @@ var ts; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 65 /* Identifier */: + case 66 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -43659,7 +46240,7 @@ var ts; } ts.createClassifier = createClassifier; /** - * Get the path of the default library file (lib.d.ts) as distributed with the typescript + * Get the path of the default library files (lib.d.ts) as distributed with the typescript * node package. * The functionality is not supported if the ts module is consumed outside of a node module. */ @@ -43676,10 +46257,10 @@ var ts; getNodeConstructor: function (kind) { function Node() { } - var proto = kind === 230 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); + var proto = kind === 245 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); proto.kind = kind; - proto.pos = 0; - proto.end = 0; + proto.pos = -1; + proto.end = -1; proto.flags = 0; proto.parent = undefined; Node.prototype = proto; @@ -43705,7 +46286,7 @@ var ts; */ function spanInSourceFileAtLocation(sourceFile, position) { // Cannot set breakpoint in dts file - if (sourceFile.flags & 2048 /* DeclarationFile */) { + if (sourceFile.flags & 8192 /* DeclarationFile */) { return undefined; } var tokenAtLocation = ts.getTokenAtPosition(sourceFile, position); @@ -43746,125 +46327,125 @@ var ts; function spanInNode(node) { if (node) { if (ts.isExpression(node)) { - if (node.parent.kind === 187 /* DoStatement */) { + if (node.parent.kind === 194 /* DoStatement */) { // Set span as if on while keyword return spanInPreviousNode(node); } - if (node.parent.kind === 189 /* ForStatement */) { + if (node.parent.kind === 196 /* ForStatement */) { // For now lets set the span on this expression, fix it later return textSpan(node); } - if (node.parent.kind === 172 /* BinaryExpression */ && node.parent.operatorToken.kind === 23 /* CommaToken */) { + if (node.parent.kind === 178 /* BinaryExpression */ && node.parent.operatorToken.kind === 23 /* CommaToken */) { // if this is comma expression, the breakpoint is possible in this expression return textSpan(node); } - if (node.parent.kind === 166 /* ArrowFunction */ && node.parent.body === node) { + if (node.parent.kind === 171 /* ArrowFunction */ && node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); } } switch (node.kind) { - case 183 /* VariableStatement */: + case 190 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 201 /* VariableDeclaration */: - case 134 /* PropertyDeclaration */: - case 133 /* PropertySignature */: + case 208 /* VariableDeclaration */: + case 138 /* PropertyDeclaration */: + case 137 /* PropertySignature */: return spanInVariableDeclaration(node); - case 131 /* Parameter */: + case 135 /* Parameter */: return spanInParameterDeclaration(node); - case 203 /* FunctionDeclaration */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 137 /* Constructor */: - case 165 /* FunctionExpression */: - case 166 /* ArrowFunction */: + case 210 /* FunctionDeclaration */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 141 /* Constructor */: + case 170 /* FunctionExpression */: + case 171 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 182 /* Block */: + case 189 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // Fall through - case 209 /* ModuleBlock */: + case 216 /* ModuleBlock */: return spanInBlock(node); - case 226 /* CatchClause */: + case 241 /* CatchClause */: return spanInBlock(node.block); - case 185 /* ExpressionStatement */: + case 192 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 194 /* ReturnStatement */: + case 201 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 188 /* WhileStatement */: + case 195 /* WhileStatement */: // Span on while(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 187 /* DoStatement */: + case 194 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 200 /* DebuggerStatement */: + case 207 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 186 /* IfStatement */: + case 193 /* IfStatement */: // set on if(..) span return textSpan(node, ts.findNextToken(node.expression, node)); - case 197 /* LabeledStatement */: + case 204 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 193 /* BreakStatement */: - case 192 /* ContinueStatement */: + case 200 /* BreakStatement */: + case 199 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 189 /* ForStatement */: + case 196 /* ForStatement */: return spanInForStatement(node); - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: // span on for (a in ...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 196 /* SwitchStatement */: + case 203 /* SwitchStatement */: // span on switch(...) return textSpan(node, ts.findNextToken(node.expression, node)); - case 223 /* CaseClause */: - case 224 /* DefaultClause */: + case 238 /* CaseClause */: + case 239 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 199 /* TryStatement */: + case 206 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 198 /* ThrowStatement */: + case 205 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 217 /* ExportAssignment */: + case 224 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 211 /* ImportEqualsDeclaration */: + case 218 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 212 /* ImportDeclaration */: + case 219 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 218 /* ExportDeclaration */: + case 225 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 204 /* ClassDeclaration */: - case 207 /* EnumDeclaration */: - case 229 /* EnumMember */: - case 160 /* CallExpression */: - case 161 /* NewExpression */: + case 211 /* ClassDeclaration */: + case 214 /* EnumDeclaration */: + case 244 /* EnumMember */: + case 165 /* CallExpression */: + case 166 /* NewExpression */: // span on complete node return textSpan(node); - case 195 /* WithStatement */: + case 202 /* WithStatement */: // span in statement return spanInNode(node.statement); // No breakpoint in interface, type alias - case 205 /* InterfaceDeclaration */: - case 206 /* TypeAliasDeclaration */: + case 212 /* InterfaceDeclaration */: + case 213 /* TypeAliasDeclaration */: return undefined; // Tokens: case 22 /* SemicolonToken */: @@ -43880,25 +46461,25 @@ var ts; return spanInOpenParenToken(node); case 17 /* CloseParenToken */: return spanInCloseParenToken(node); - case 51 /* ColonToken */: + case 52 /* ColonToken */: return spanInColonToken(node); - case 25 /* GreaterThanToken */: + case 26 /* GreaterThanToken */: case 24 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 100 /* WhileKeyword */: + case 101 /* WhileKeyword */: return spanInWhileKeyword(node); - case 76 /* ElseKeyword */: - case 68 /* CatchKeyword */: - case 81 /* FinallyKeyword */: + case 77 /* ElseKeyword */: + case 69 /* CatchKeyword */: + case 82 /* FinallyKeyword */: return spanInNextNode(node); default: // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 227 /* PropertyAssignment */ && node.parent.name === node) { + if (node.parent.kind === 242 /* PropertyAssignment */ && node.parent.name === node) { return spanInNode(node.parent.initializer); } // Breakpoint in type assertion goes to its operand - if (node.parent.kind === 163 /* TypeAssertionExpression */ && node.parent.type === node) { + if (node.parent.kind === 168 /* TypeAssertionExpression */ && node.parent.type === node) { return spanInNode(node.parent.expression); } // return type of function go to previous token @@ -43911,12 +46492,12 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 190 /* ForInStatement */ || - variableDeclaration.parent.parent.kind === 191 /* ForOfStatement */) { + if (variableDeclaration.parent.parent.kind === 197 /* ForInStatement */ || + variableDeclaration.parent.parent.kind === 198 /* ForOfStatement */) { return spanInNode(variableDeclaration.parent.parent); } - var isParentVariableStatement = variableDeclaration.parent.parent.kind === 183 /* VariableStatement */; - var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 189 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); + var isParentVariableStatement = variableDeclaration.parent.parent.kind === 190 /* VariableStatement */; + var isDeclarationOfForStatement = variableDeclaration.parent.parent.kind === 196 /* ForStatement */ && ts.contains(variableDeclaration.parent.parent.initializer.declarations, variableDeclaration); var declarations = isParentVariableStatement ? variableDeclaration.parent.parent.declarationList.declarations : isDeclarationOfForStatement @@ -43970,7 +46551,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return !!(functionDeclaration.flags & 1 /* Export */) || - (functionDeclaration.parent.kind === 204 /* ClassDeclaration */ && functionDeclaration.kind !== 137 /* Constructor */); + (functionDeclaration.parent.kind === 211 /* ClassDeclaration */ && functionDeclaration.kind !== 141 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -43993,18 +46574,18 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 208 /* ModuleDeclaration */: + case 215 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } // Set on parent if on same line otherwise on first statement - case 188 /* WhileStatement */: - case 186 /* IfStatement */: - case 190 /* ForInStatement */: - case 191 /* ForOfStatement */: + case 195 /* WhileStatement */: + case 193 /* IfStatement */: + case 197 /* ForInStatement */: + case 198 /* ForOfStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 189 /* ForStatement */: + case 196 /* ForStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement @@ -44012,7 +46593,7 @@ var ts; } function spanInForStatement(forStatement) { if (forStatement.initializer) { - if (forStatement.initializer.kind === 202 /* VariableDeclarationList */) { + if (forStatement.initializer.kind === 209 /* VariableDeclarationList */) { var variableDeclarationList = forStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -44032,13 +46613,13 @@ var ts; // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 207 /* EnumDeclaration */: + case 214 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 204 /* ClassDeclaration */: + case 211 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 210 /* CaseBlock */: + case 217 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -44046,25 +46627,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 209 /* ModuleBlock */: + case 216 /* ModuleBlock */: // If this is not instantiated module block no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 207 /* EnumDeclaration */: - case 204 /* ClassDeclaration */: + case 214 /* EnumDeclaration */: + case 211 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 182 /* Block */: + case 189 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // fall through. - case 226 /* CatchClause */: + case 241 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); ; - case 210 /* CaseBlock */: + case 217 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -44078,7 +46659,7 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 187 /* DoStatement */) { + if (node.parent.kind === 194 /* DoStatement */) { // Go to while keyword and do action instead return spanInPreviousNode(node); } @@ -44088,17 +46669,17 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 165 /* FunctionExpression */: - case 203 /* FunctionDeclaration */: - case 166 /* ArrowFunction */: - case 136 /* MethodDeclaration */: - case 135 /* MethodSignature */: - case 138 /* GetAccessor */: - case 139 /* SetAccessor */: - case 137 /* Constructor */: - case 188 /* WhileStatement */: - case 187 /* DoStatement */: - case 189 /* ForStatement */: + case 170 /* FunctionExpression */: + case 210 /* FunctionDeclaration */: + case 171 /* ArrowFunction */: + case 140 /* MethodDeclaration */: + case 139 /* MethodSignature */: + case 142 /* GetAccessor */: + case 143 /* SetAccessor */: + case 141 /* Constructor */: + case 195 /* WhileStatement */: + case 194 /* DoStatement */: + case 196 /* ForStatement */: return spanInPreviousNode(node); // Default to parent node default: @@ -44109,19 +46690,19 @@ var ts; } function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration - if (ts.isFunctionLike(node.parent) || node.parent.kind === 227 /* PropertyAssignment */) { + if (ts.isFunctionLike(node.parent) || node.parent.kind === 242 /* PropertyAssignment */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 163 /* TypeAssertionExpression */) { + if (node.parent.kind === 168 /* TypeAssertionExpression */) { return spanInNode(node.parent.expression); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 187 /* DoStatement */) { + if (node.parent.kind === 194 /* DoStatement */) { // Set span on while expression return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); } @@ -44249,7 +46830,8 @@ var ts; } }; LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { - return this.shimHost.getCancellationToken(); + var hostCancellationToken = this.shimHost.getCancellationToken(); + return new ThrottledCancellationToken(hostCancellationToken); }; LanguageServiceShimHostAdapter.prototype.getCurrentDirectory = function () { return this.shimHost.getCurrentDirectory(); @@ -44267,6 +46849,27 @@ var ts; return LanguageServiceShimHostAdapter; })(); ts.LanguageServiceShimHostAdapter = LanguageServiceShimHostAdapter; + /** A cancellation that throttles calls to the host */ + var ThrottledCancellationToken = (function () { + function ThrottledCancellationToken(hostCancellationToken) { + this.hostCancellationToken = hostCancellationToken; + // Store when we last tried to cancel. Checking cancellation can be expensive (as we have + // to marshall over to the host layer). So we only bother actually checking once enough + // time has passed. + this.lastCancellationCheckTime = 0; + } + ThrottledCancellationToken.prototype.isCancellationRequested = function () { + var time = Date.now(); + var duration = Math.abs(time - this.lastCancellationCheckTime); + if (duration > 10) { + // Check no more than once every 10 ms. + this.lastCancellationCheckTime = time; + return this.hostCancellationToken.isCancellationRequested(); + } + return false; + }; + return ThrottledCancellationToken; + })(); var CoreServicesShimHostAdapter = (function () { function CoreServicesShimHostAdapter(shimHost) { this.shimHost = shimHost; diff --git a/package.json b/package.json index 82ab734d6f1..70ada6fef15 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "chai": "latest", "browserify": "latest", "istanbul": "latest", + "mocha-fivemat-progress-reporter": "latest", "tslint": "latest" }, "scripts": { diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f5676653553..f8bafa7a38f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -876,7 +876,7 @@ namespace ts { } // Resolves a qualified name and any involved aliases - function resolveEntityName(name: EntityName | Expression, meaning: SymbolFlags): Symbol { + function resolveEntityName(name: EntityName | Expression, meaning: SymbolFlags, ignoreErrors?: boolean): Symbol { if (nodeIsMissing(name)) { return undefined; } @@ -885,7 +885,7 @@ namespace ts { if (name.kind === SyntaxKind.Identifier) { let message = meaning === SymbolFlags.Namespace ? Diagnostics.Cannot_find_namespace_0 : Diagnostics.Cannot_find_name_0; - symbol = resolveName(name, (name).text, meaning, message, name); + symbol = resolveName(name, (name).text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } @@ -894,13 +894,15 @@ namespace ts { let left = name.kind === SyntaxKind.QualifiedName ? (name).left : (name).expression; let right = name.kind === SyntaxKind.QualifiedName ? (name).right : (name).name; - let namespace = resolveEntityName(left, SymbolFlags.Namespace); + let namespace = resolveEntityName(left, SymbolFlags.Namespace, ignoreErrors); if (!namespace || namespace === unknownSymbol || nodeIsMissing(right)) { return undefined; } symbol = getSymbol(getExportsOfSymbol(namespace), right.text, meaning); if (!symbol) { - error(right, Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(namespace), declarationNameToString(right)); + if (!ignoreErrors) { + error(right, Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(namespace), declarationNameToString(right)); + } return undefined; } } @@ -2486,10 +2488,6 @@ namespace ts { return links.type; } - function getSetAccessorTypeAnnotationNode(accessor: AccessorDeclaration): TypeNode { - return accessor && accessor.parameters.length > 0 && accessor.parameters[0].type; - } - function getAnnotatedAccessorType(accessor: AccessorDeclaration): Type { if (accessor) { if (accessor.kind === SyntaxKind.GetAccessor) { @@ -3381,6 +3379,15 @@ namespace ts { return getSignaturesOfStructuredType(getApparentType(type), kind); } + function typeHasConstructSignatures(type: Type): boolean { + let apparentType = getApparentType(type); + if (apparentType.flags & (TypeFlags.ObjectType | TypeFlags.Union)) { + let resolved = resolveStructuredTypeMembers(type); + return resolved.constructSignatures.length > 0; + } + return false; + } + function typeHasCallOrConstructSignatures(type: Type): boolean { let apparentType = getApparentType(type); if (apparentType.flags & TypeFlags.StructuredType) { @@ -3936,7 +3943,7 @@ namespace ts { let id = getTypeListId(elementTypes); let type = tupleTypes[id]; if (!type) { - type = tupleTypes[id] = createObjectType(TypeFlags.Tuple); + type = tupleTypes[id] = createObjectType(TypeFlags.Tuple | getWideningFlagsOfTypes(elementTypes)); type.elementTypes = elementTypes; } return type; @@ -4896,9 +4903,38 @@ namespace ts { let targetSignatures = getSignaturesOfType(target, kind); let result = Ternary.True; let saveErrorInfo = errorInfo; + + // Because the "abstractness" of a class is the same across all construct signatures + // (internally we are checking the corresponding declaration), it is enough to perform + // the check and report an error once over all pairs of source and target construct signatures. + let sourceSig = sourceSignatures[0]; + // Note that in an extends-clause, targetSignatures is stripped, so the check never proceeds. + let targetSig = targetSignatures[0]; + + if (sourceSig && targetSig) { + let sourceErasedSignature = getErasedSignature(sourceSig); + let targetErasedSignature = getErasedSignature(targetSig); + + let sourceReturnType = sourceErasedSignature && getReturnTypeOfSignature(sourceErasedSignature); + let targetReturnType = targetErasedSignature && getReturnTypeOfSignature(targetErasedSignature); + + let sourceReturnDecl = sourceReturnType && sourceReturnType.symbol && getDeclarationOfKind(sourceReturnType.symbol, SyntaxKind.ClassDeclaration); + let targetReturnDecl = targetReturnType && targetReturnType.symbol && getDeclarationOfKind(targetReturnType.symbol, SyntaxKind.ClassDeclaration); + let sourceIsAbstract = sourceReturnDecl && sourceReturnDecl.flags & NodeFlags.Abstract; + let targetIsAbstract = targetReturnDecl && targetReturnDecl.flags & NodeFlags.Abstract; + + if (sourceIsAbstract && !targetIsAbstract) { + if (reportErrors) { + reportError(Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type); + } + return Ternary.False; + } + } + outer: for (let t of targetSignatures) { if (!t.hasStringLiterals || target.flags & TypeFlags.FromSignature) { let localErrors = reportErrors; + let checkedAbstractAssignability = false; for (let s of sourceSignatures) { if (!s.hasStringLiterals || source.flags & TypeFlags.FromSignature) { let related = signatureRelatedTo(s, t, localErrors); @@ -5005,10 +5041,11 @@ namespace ts { return Ternary.False; } - let t = getReturnTypeOfSignature(target); - if (t === voidType) return result; - let s = getReturnTypeOfSignature(source); - return result & isRelatedTo(s, t, reportErrors); + let targetReturnType = getReturnTypeOfSignature(target); + if (targetReturnType === voidType) return result; + let sourceReturnType = getReturnTypeOfSignature(source); + + return result & isRelatedTo(sourceReturnType, targetReturnType, reportErrors); } function signaturesIdenticalTo(source: Type, target: Type, kind: SignatureKind): Ternary { @@ -5262,8 +5299,8 @@ namespace ts { * Check if a Type was written as a tuple type literal. * Prefer using isTupleLikeType() unless the use of `elementTypes` is required. */ - function isTupleType(type: Type): boolean { - return (type.flags & TypeFlags.Tuple) && !!(type).elementTypes; + function isTupleType(type: Type): type is TupleType { + return !!(type.flags & TypeFlags.Tuple); } function getWidenedTypeOfObjectLiteral(type: Type): Type { @@ -5304,26 +5341,45 @@ namespace ts { if (isArrayType(type)) { return createArrayType(getWidenedType((type).typeArguments[0])); } + if (isTupleType(type)) { + return createTupleType(map(type.elementTypes, getWidenedType)); + } } return type; } + /** + * Reports implicit any errors that occur as a result of widening 'null' and 'undefined' + * to 'any'. A call to reportWideningErrorsInType is normally accompanied by a call to + * getWidenedType. But in some cases getWidenedType is called without reporting errors + * (type argument inference is an example). + * + * The return value indicates whether an error was in fact reported. The particular circumstances + * are on a best effort basis. Currently, if the null or undefined that causes widening is inside + * an object literal property (arbitrarily deeply), this function reports an error. If no error is + * reported, reportImplicitAnyError is a suitable fallback to report a general error. + */ function reportWideningErrorsInType(type: Type): boolean { + let errorReported = false; if (type.flags & TypeFlags.Union) { - let errorReported = false; - forEach((type).types, t => { + for (let t of (type).types) { if (reportWideningErrorsInType(t)) { errorReported = true; } - }); - return errorReported; + } } if (isArrayType(type)) { return reportWideningErrorsInType((type).typeArguments[0]); } + if (isTupleType(type)) { + for (let t of type.elementTypes) { + if (reportWideningErrorsInType(t)) { + errorReported = true; + } + } + } if (type.flags & TypeFlags.ObjectLiteral) { - let errorReported = false; - forEach(getPropertiesOfObjectType(type), p => { + for (let p of getPropertiesOfObjectType(type)) { let t = getTypeOfSymbol(p); if (t.flags & TypeFlags.ContainsUndefinedOrNull) { if (!reportWideningErrorsInType(t)) { @@ -5331,10 +5387,9 @@ namespace ts { } errorReported = true; } - }); - return errorReported; + } } - return false; + return errorReported; } function reportImplicitAnyError(declaration: Declaration, type: Type) { @@ -5501,30 +5556,33 @@ namespace ts { inferFromTypes(sourceType, target); } } - else if (source.flags & TypeFlags.ObjectType && (target.flags & (TypeFlags.Reference | TypeFlags.Tuple) || - (target.flags & TypeFlags.Anonymous) && target.symbol && target.symbol.flags & (SymbolFlags.Method | SymbolFlags.TypeLiteral | SymbolFlags.Class))) { - // If source is an object type, and target is a type reference, a tuple type, the type of a method, or a type literal, infer from members - if (isInProcess(source, target)) { - return; - } - if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { - return; - } + else { + source = getApparentType(source); + if (source.flags & TypeFlags.ObjectType && (target.flags & (TypeFlags.Reference | TypeFlags.Tuple) || + (target.flags & TypeFlags.Anonymous) && target.symbol && target.symbol.flags & (SymbolFlags.Method | SymbolFlags.TypeLiteral | SymbolFlags.Class))) { + // If source is an object type, and target is a type reference, a tuple type, the type of a method, or a type literal, infer from members + if (isInProcess(source, target)) { + return; + } + if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { + return; + } - if (depth === 0) { - sourceStack = []; - targetStack = []; + if (depth === 0) { + sourceStack = []; + targetStack = []; + } + sourceStack[depth] = source; + targetStack[depth] = target; + depth++; + inferFromProperties(source, target); + inferFromSignatures(source, target, SignatureKind.Call); + inferFromSignatures(source, target, SignatureKind.Construct); + inferFromIndexTypes(source, target, IndexKind.String, IndexKind.String); + inferFromIndexTypes(source, target, IndexKind.Number, IndexKind.Number); + inferFromIndexTypes(source, target, IndexKind.String, IndexKind.Number); + depth--; } - sourceStack[depth] = source; - targetStack[depth] = target; - depth++; - inferFromProperties(source, target); - inferFromSignatures(source, target, SignatureKind.Call); - inferFromSignatures(source, target, SignatureKind.Construct); - inferFromIndexTypes(source, target, IndexKind.String, IndexKind.String); - inferFromIndexTypes(source, target, IndexKind.Number, IndexKind.Number); - inferFromIndexTypes(source, target, IndexKind.String, IndexKind.Number); - depth--; } } @@ -6765,7 +6823,7 @@ namespace ts { let restArrayType = checkExpression((e).expression, contextualMapper); let restElementType = getIndexTypeOfType(restArrayType, IndexKind.Number) || (languageVersion >= ScriptTarget.ES6 ? getElementTypeOfIterable(restArrayType, /*errorNode*/ undefined) : undefined); - if (restElementType) { + if (restElementType) { elementTypes.push(restElementType); } } @@ -6924,7 +6982,6 @@ namespace ts { } } - function checkJsxSelfClosingElement(node: JsxSelfClosingElement) { checkJsxOpeningLikeElement(node); return jsxElementType || anyType; @@ -8012,8 +8069,8 @@ namespace ts { return args; } - - /** + + /** * Returns the effective argument count for a node that works like a function invocation. * If 'node' is a Decorator, the number of arguments is derived from the decoration * target and the signature: @@ -8090,11 +8147,11 @@ namespace ts { let classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } - + // fall-through case SyntaxKind.PropertyDeclaration: - case SyntaxKind.MethodDeclaration: + case SyntaxKind.MethodDeclaration: case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: // For a property or method decorator, the `target` is the @@ -8137,14 +8194,14 @@ namespace ts { // For a constructor parameter decorator, the `propertyKey` will be `undefined`. return anyType; } - + // For a non-constructor parameter decorator, the `propertyKey` will be either // a string or a symbol, based on the name of the parameter's containing method. // fall-through case SyntaxKind.PropertyDeclaration: - case SyntaxKind.MethodDeclaration: + case SyntaxKind.MethodDeclaration: case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: // The `propertyKey` for a property or method decorator will be a @@ -8172,8 +8229,8 @@ namespace ts { return unknownType; } - - default: + + default: Debug.fail("Unsupported decorator target."); return unknownType; } @@ -10981,13 +11038,10 @@ namespace ts { // as if it were an expression so that we can emit the type in a value position when we // serialize the type metadata. if (node && node.kind === SyntaxKind.TypeReference) { - let type = getTypeFromTypeNode(node); - let shouldCheckIfUnknownType = type === unknownType && compilerOptions.isolatedModules; - if (!type || (!shouldCheckIfUnknownType && type.flags & (TypeFlags.Intrinsic | TypeFlags.NumberLike | TypeFlags.StringLike))) { - return; - } - if (shouldCheckIfUnknownType || type.symbol.valueDeclaration) { - checkExpression((node).typeName); + let root = getFirstIdentifier((node).typeName); + let rootSymbol = resolveName(root, root.text, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + if (rootSymbol && rootSymbol.flags & SymbolFlags.Alias && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))) { + markAliasSymbolAsReferenced(rootSymbol); } } } @@ -11459,19 +11513,19 @@ namespace ts { forEach(node.declarationList.declarations, checkSourceElement); } - function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node: Node) { + function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node: Node) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression if (node.modifiers && node.parent.kind === SyntaxKind.ObjectLiteralExpression){ if (isAsyncFunctionLike(node)) { if (node.modifiers.length > 1) { - return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here); + return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here); } } else { return grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here); } } - } + } function checkExpressionStatement(node: ExpressionStatement) { // Grammar checking @@ -12812,7 +12866,7 @@ namespace ts { Debug.assert(node.kind === SyntaxKind.Identifier); return node; } - + function checkExternalImportOrExportDeclaration(node: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration): boolean { let moduleName = getExternalModuleName(node); if (!nodeIsMissing(moduleName) && moduleName.kind !== SyntaxKind.StringLiteral) { @@ -13958,205 +14012,54 @@ namespace ts { return undefined; } - /** Serializes an EntityName (with substitutions) to an appropriate JS constructor value. Used by the __metadata decorator. */ - function serializeEntityName(node: EntityName, fallbackPath?: string[]): string { - if (node.kind === SyntaxKind.Identifier) { - // TODO(ron.buckton): The getExpressionNameSubstitution function has been removed, but calling it - // here has no effect anyway as an identifier in a type name is not an expression. - // var substitution = getExpressionNameSubstitution(node, getGeneratedNameForNode); - // var text = substitution || (node).text; - let text = (node).text; - if (fallbackPath) { - fallbackPath.push(text); - } - else { - return text; - } + function isFunctionType(type: Type): boolean { + return type.flags & TypeFlags.ObjectType && getSignaturesOfType(type, SignatureKind.Call).length > 0; + } + + function getTypeReferenceSerializationKind(node: TypeReferenceNode): TypeReferenceSerializationKind { + // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. + let symbol = resolveEntityName(node.typeName, SymbolFlags.Value, /*ignoreErrors*/ true); + let constructorType = symbol ? getTypeOfSymbol(symbol) : undefined; + if (constructorType && isConstructorType(constructorType)) { + return TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue; + } + + let type = getTypeFromTypeNode(node); + if (type === unknownType) { + return TypeReferenceSerializationKind.Unknown; + } + else if (type.flags & TypeFlags.Any) { + return TypeReferenceSerializationKind.ObjectType; + } + else if (allConstituentTypesHaveKind(type, TypeFlags.Void)) { + return TypeReferenceSerializationKind.VoidType; + } + else if (allConstituentTypesHaveKind(type, TypeFlags.Boolean)) { + return TypeReferenceSerializationKind.BooleanType; + } + else if (allConstituentTypesHaveKind(type, TypeFlags.NumberLike)) { + return TypeReferenceSerializationKind.NumberLikeType; + } + else if (allConstituentTypesHaveKind(type, TypeFlags.StringLike)) { + return TypeReferenceSerializationKind.StringLikeType; + } + else if (allConstituentTypesHaveKind(type, TypeFlags.Tuple)) { + return TypeReferenceSerializationKind.ArrayLikeType; + } + else if (allConstituentTypesHaveKind(type, TypeFlags.ESSymbol)) { + return TypeReferenceSerializationKind.ESSymbolType; + } + else if (isFunctionType(type)) { + return TypeReferenceSerializationKind.TypeWithCallSignature; + } + else if (isArrayType(type)) { + return TypeReferenceSerializationKind.ArrayLikeType; } else { - let left = serializeEntityName((node).left, fallbackPath); - let right = serializeEntityName((node).right, fallbackPath); - if (!fallbackPath) { - return left + "." + right; - } + return TypeReferenceSerializationKind.ObjectType; } } - /** Serializes a TypeReferenceNode to an appropriate JS constructor value. Used by the __metadata decorator. */ - function serializeTypeReferenceNode(node: TypeReferenceNode): string | string[] { - // serialization of a TypeReferenceNode uses the following rules: - // - // * The serialized type of a TypeReference that is `void` is "void 0". - // * The serialized type of a TypeReference that is a `boolean` is "Boolean". - // * The serialized type of a TypeReference that is an enum or `number` is "Number". - // * The serialized type of a TypeReference that is a string literal or `string` is "String". - // * The serialized type of a TypeReference that is a tuple is "Array". - // * The serialized type of a TypeReference that is a `symbol` is "Symbol". - // * The serialized type of a TypeReference with a value declaration is its entity name. - // * The serialized type of a TypeReference with a call or construct signature is "Function". - // * The serialized type of any other type is "Object". - let type = getTypeFromTypeNode(node); - if (type.flags & TypeFlags.Void) { - return "void 0"; - } - else if (type.flags & TypeFlags.Boolean) { - return "Boolean"; - } - else if (type.flags & TypeFlags.NumberLike) { - return "Number"; - } - else if (type.flags & TypeFlags.StringLike) { - return "String"; - } - else if (type.flags & TypeFlags.Tuple) { - return "Array"; - } - else if (type.flags & TypeFlags.ESSymbol) { - return "Symbol"; - } - else if (type === unknownType) { - let fallbackPath: string[] = []; - serializeEntityName(node.typeName, fallbackPath); - return fallbackPath; - } - else if (type.symbol && type.symbol.valueDeclaration) { - return serializeEntityName(node.typeName); - } - else if (typeHasCallOrConstructSignatures(type)) { - return "Function"; - } - - return "Object"; - } - - /** Serializes a TypeNode to an appropriate JS constructor value. Used by the __metadata decorator. */ - function serializeTypeNode(node: TypeNode | LiteralExpression): string | string[] { - // serialization of a TypeNode uses the following rules: - // - // * The serialized type of `void` is "void 0" (undefined). - // * The serialized type of a parenthesized type is the serialized type of its nested type. - // * The serialized type of a Function or Constructor type is "Function". - // * The serialized type of an Array or Tuple type is "Array". - // * The serialized type of `boolean` is "Boolean". - // * The serialized type of `string` or a string-literal type is "String". - // * The serialized type of a type reference is handled by `serializeTypeReferenceNode`. - // * The serialized type of any other type node is "Object". - if (node) { - switch (node.kind) { - case SyntaxKind.VoidKeyword: - return "void 0"; - case SyntaxKind.ParenthesizedType: - return serializeTypeNode((node).type); - case SyntaxKind.FunctionType: - case SyntaxKind.ConstructorType: - return "Function"; - case SyntaxKind.ArrayType: - case SyntaxKind.TupleType: - return "Array"; - case SyntaxKind.BooleanKeyword: - return "Boolean"; - case SyntaxKind.StringKeyword: - case SyntaxKind.StringLiteral: - return "String"; - case SyntaxKind.NumberKeyword: - return "Number"; - case SyntaxKind.TypeReference: - return serializeTypeReferenceNode(node); - case SyntaxKind.TypeQuery: - case SyntaxKind.TypeLiteral: - case SyntaxKind.UnionType: - case SyntaxKind.IntersectionType: - case SyntaxKind.AnyKeyword: - break; - default: - Debug.fail("Cannot serialize unexpected type node."); - break; - } - } - - return "Object"; - } - - /** Serializes the type of a declaration to an appropriate JS constructor value. Used by the __metadata decorator for a class member. */ - function serializeTypeOfNode(node: Node): string | string[] { - // serialization of the type of a declaration uses the following rules: - // - // * The serialized type of a ClassDeclaration is "Function" - // * The serialized type of a ParameterDeclaration is the serialized type of its type annotation. - // * The serialized type of a PropertyDeclaration is the serialized type of its type annotation. - // * The serialized type of an AccessorDeclaration is the serialized type of the return type annotation of its getter or parameter type annotation of its setter. - // * The serialized type of any other FunctionLikeDeclaration is "Function". - // * The serialized type of any other node is "void 0". - // - // For rules on serializing type annotations, see `serializeTypeNode`. - switch (node.kind) { - case SyntaxKind.ClassDeclaration: return "Function"; - case SyntaxKind.PropertyDeclaration: return serializeTypeNode((node).type); - case SyntaxKind.Parameter: return serializeTypeNode((node).type); - case SyntaxKind.GetAccessor: return serializeTypeNode((node).type); - case SyntaxKind.SetAccessor: return serializeTypeNode(getSetAccessorTypeAnnotationNode(node)); - } - if (isFunctionLike(node)) { - return "Function"; - } - return "void 0"; - } - - /** Serializes the parameter types of a function or the constructor of a class. Used by the __metadata decorator for a method or set accessor. */ - function serializeParameterTypesOfNode(node: Node): (string | string[])[] { - // serialization of parameter types uses the following rules: - // - // * If the declaration is a class, the parameters of the first constructor with a body are used. - // * If the declaration is function-like and has a body, the parameters of the function are used. - // - // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. - if (node) { - let valueDeclaration: FunctionLikeDeclaration; - if (node.kind === SyntaxKind.ClassDeclaration) { - valueDeclaration = getFirstConstructorWithBody(node); - } - else if (isFunctionLike(node) && nodeIsPresent((node).body)) { - valueDeclaration = node; - } - if (valueDeclaration) { - let result: (string | string[])[]; - let parameters = valueDeclaration.parameters; - let parameterCount = parameters.length; - if (parameterCount > 0) { - result = new Array(parameterCount); - for (let i = 0; i < parameterCount; i++) { - if (parameters[i].dotDotDotToken) { - let parameterType = parameters[i].type; - if (parameterType.kind === SyntaxKind.ArrayType) { - parameterType = (parameterType).elementType; - } - else if (parameterType.kind === SyntaxKind.TypeReference && (parameterType).typeArguments && (parameterType).typeArguments.length === 1) { - parameterType = (parameterType).typeArguments[0]; - } - else { - parameterType = undefined; - } - result[i] = serializeTypeNode(parameterType); - } - else { - result[i] = serializeTypeOfNode(parameters[i]); - } - } - return result; - } - } - } - return emptyArray; - } - - /** Serializes the return type of function. Used by the __metadata decorator for a method. */ - function serializeReturnTypeOfNode(node: Node): string | string[] { - if (node && isFunctionLike(node)) { - return serializeTypeNode((node).type); - } - return "void 0"; - } - function writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter) { // Get type of the symbol if this is the valid symbol otherwise get type at location let symbol = getSymbolOfNode(declaration); @@ -14254,9 +14157,7 @@ namespace ts { collectLinkedAliases, getBlockScopedVariableId, getReferencedValueDeclaration, - serializeTypeOfNode, - serializeParameterTypesOfNode, - serializeReturnTypeOfNode, + getTypeReferenceSerializationKind, }; } @@ -14516,7 +14417,7 @@ namespace ts { } flags |= NodeFlags.Ambient; lastDeclare = modifier; - break; + break; case SyntaxKind.AbstractKeyword: if (flags & NodeFlags.Abstract) { @@ -14552,7 +14453,7 @@ namespace ts { } flags |= NodeFlags.Async; lastAsync = modifier; - break; + break; } } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index a17f8857590..a0a95d47c8c 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -407,7 +407,7 @@ namespace ts { Classes_containing_abstract_methods_must_be_marked_abstract: { code: 2514, category: DiagnosticCategory.Error, key: "Classes containing abstract methods must be marked abstract." }, Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: 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: DiagnosticCategory.Error, key: "All declarations of an abstract method must be consecutive." }, - Constructor_objects_of_abstract_type_cannot_be_assigned_to_constructor_objects_of_non_abstract_type: { code: 2517, category: DiagnosticCategory.Error, key: "Constructor objects of abstract type cannot be assigned to constructor objects of non-abstract type" }, + Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { code: 2517, category: 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: 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: 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: DiagnosticCategory.Error, key: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 94be4f53c97..acf4e74ae9f 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1617,7 +1617,7 @@ "category": "Error", "code": 2516 }, - "Constructor objects of abstract type cannot be assigned to constructor objects of non-abstract type": { + "Cannot assign an abstract constructor type to a non-abstract constructor type.": { "category": "Error", "code":2517 }, diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index fce95c59ae8..c3c85abce21 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2015,13 +2015,52 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi emit(node.name); decreaseIndentIf(indentedBeforeDot, indentedAfterDot); } - + function emitQualifiedName(node: QualifiedName) { emit(node.left); write("."); emit(node.right); } + function emitQualifiedNameAsExpression(node: QualifiedName, useFallback: boolean) { + if (node.left.kind === SyntaxKind.Identifier) { + emitEntityNameAsExpression(node.left, useFallback); + } + else if (useFallback) { + let temp = createAndRecordTempVariable(TempFlags.Auto); + write("("); + emitNodeWithoutSourceMap(temp); + write(" = "); + emitEntityNameAsExpression(node.left, /*useFallback*/ true); + write(") && "); + emitNodeWithoutSourceMap(temp); + } + else { + emitEntityNameAsExpression(node.left, /*useFallback*/ false); + } + + write("."); + emitNodeWithoutSourceMap(node.right); + } + + function emitEntityNameAsExpression(node: EntityName, useFallback: boolean) { + switch (node.kind) { + case SyntaxKind.Identifier: + if (useFallback) { + write("typeof "); + emitExpressionIdentifier(node); + write(" !== 'undefined' && "); + } + + emitExpressionIdentifier(node); + break; + + case SyntaxKind.QualifiedName: + emitQualifiedNameAsExpression(node, useFallback); + break; + } + } + function emitIndexedAccess(node: ElementAccessExpression) { if (tryEmitConstantValue(node)) { return; @@ -4640,83 +4679,267 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi } return false; } + + /** Serializes the type of a declaration to an appropriate JS constructor value. Used by the __metadata decorator for a class member. */ + function emitSerializedTypeOfNode(node: Node) { + // serialization of the type of a declaration uses the following rules: + // + // * The serialized type of a ClassDeclaration is "Function" + // * The serialized type of a ParameterDeclaration is the serialized type of its type annotation. + // * The serialized type of a PropertyDeclaration is the serialized type of its type annotation. + // * The serialized type of an AccessorDeclaration is the serialized type of the return type annotation of its getter or parameter type annotation of its setter. + // * The serialized type of any other FunctionLikeDeclaration is "Function". + // * The serialized type of any other node is "void 0". + // + // For rules on serializing type annotations, see `serializeTypeNode`. + switch (node.kind) { + case SyntaxKind.ClassDeclaration: + write("Function"); + return; + + case SyntaxKind.PropertyDeclaration: + emitSerializedTypeNode((node).type); + return; + + case SyntaxKind.Parameter: + emitSerializedTypeNode((node).type); + return; + + case SyntaxKind.GetAccessor: + emitSerializedTypeNode((node).type); + return; + + case SyntaxKind.SetAccessor: + emitSerializedTypeNode(getSetAccessorTypeAnnotationNode(node)); + return; + + } + + if (isFunctionLike(node)) { + write("Function"); + return; + } + + write("void 0"); + } + + function emitSerializedTypeNode(node: TypeNode) { + switch (node.kind) { + case SyntaxKind.VoidKeyword: + write("void 0"); + return; + case SyntaxKind.ParenthesizedType: + emitSerializedTypeNode((node).type); + return; + + case SyntaxKind.FunctionType: + case SyntaxKind.ConstructorType: + write("Function"); + return; + + case SyntaxKind.ArrayType: + case SyntaxKind.TupleType: + write("Array"); + return; + + case SyntaxKind.TypePredicate: + case SyntaxKind.BooleanKeyword: + write("Boolean"); + return; + + case SyntaxKind.StringKeyword: + case SyntaxKind.StringLiteral: + write("String"); + return; + + case SyntaxKind.NumberKeyword: + write("Number"); + return; + + case SyntaxKind.SymbolKeyword: + write("Symbol"); + return; + + case SyntaxKind.TypeReference: + emitSerializedTypeReferenceNode(node); + return; + + case SyntaxKind.TypeQuery: + case SyntaxKind.TypeLiteral: + case SyntaxKind.UnionType: + case SyntaxKind.IntersectionType: + case SyntaxKind.AnyKeyword: + break; + + default: + Debug.fail("Cannot serialize unexpected type node."); + break; + } + + write("Object"); + } + + /** Serializes a TypeReferenceNode to an appropriate JS constructor value. Used by the __metadata decorator. */ + function emitSerializedTypeReferenceNode(node: TypeReferenceNode) { + let typeName = node.typeName; + let result = resolver.getTypeReferenceSerializationKind(node); + switch (result) { + case TypeReferenceSerializationKind.Unknown: + let temp = createAndRecordTempVariable(TempFlags.Auto); + write("(typeof ("); + emitNodeWithoutSourceMap(temp); + write(" = ") + emitEntityNameAsExpression(typeName, /*useFallback*/ true); + write(") === 'function' && "); + emitNodeWithoutSourceMap(temp); + write(") || Object"); + break; + + case TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue: + emitEntityNameAsExpression(typeName, /*useFallback*/ false); + break; + + case TypeReferenceSerializationKind.VoidType: + write("void 0"); + break; + + case TypeReferenceSerializationKind.BooleanType: + write("Boolean"); + break; + + case TypeReferenceSerializationKind.NumberLikeType: + write("Number"); + break; + + case TypeReferenceSerializationKind.StringLikeType: + write("String"); + break; + + case TypeReferenceSerializationKind.ArrayLikeType: + write("Array"); + break; + + case TypeReferenceSerializationKind.ESSymbolType: + if (languageVersion < ScriptTarget.ES6) { + write("typeof Symbol === 'function' ? Symbol : Object"); + } + else { + write("Symbol"); + } + break; + + case TypeReferenceSerializationKind.TypeWithCallSignature: + write("Function"); + break; + + case TypeReferenceSerializationKind.ObjectType: + write("Object"); + break; + } + } + + /** Serializes the parameter types of a function or the constructor of a class. Used by the __metadata decorator for a method or set accessor. */ + function emitSerializedParameterTypesOfNode(node: Node) { + // serialization of parameter types uses the following rules: + // + // * If the declaration is a class, the parameters of the first constructor with a body are used. + // * If the declaration is function-like and has a body, the parameters of the function are used. + // + // For the rules on serializing the type of each parameter declaration, see `serializeTypeOfDeclaration`. + if (node) { + var valueDeclaration: FunctionLikeDeclaration; + if (node.kind === SyntaxKind.ClassDeclaration) { + valueDeclaration = getFirstConstructorWithBody(node); + } + else if (isFunctionLike(node) && 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 === SyntaxKind.ArrayType) { + parameterType = (parameterType).elementType; + } + else if (parameterType.kind === SyntaxKind.TypeReference && (parameterType).typeArguments && (parameterType).typeArguments.length === 1) { + parameterType = (parameterType).typeArguments[0]; + } + else { + parameterType = undefined; + } + + emitSerializedTypeNode(parameterType); + } + else { + emitSerializedTypeOfNode(parameters[i]); + } + } + } + } + } + } + + /** Serializes the return type of function. Used by the __metadata decorator for a method. */ + function emitSerializedReturnTypeOfNode(node: Node): string | string[] { + if (node && isFunctionLike(node)) { + emitSerializedTypeNode((node).type); + return; + } + + write("void 0"); + } + + function emitSerializedTypeMetadata(node: Declaration, writeComma: boolean): number { // This method emits the serialized type metadata for a decorator target. // The caller should have already tested whether the node has decorators. let argumentsWritten = 0; if (compilerOptions.emitDecoratorMetadata) { if (shouldEmitTypeMetadata(node)) { - let serializedType = resolver.serializeTypeOfNode(node); - if (serializedType) { - if (writeComma) { - write(", "); - } - writeLine(); - write("__metadata('design:type', "); - emitSerializedType(node, serializedType); - write(")"); - argumentsWritten++; + if (writeComma) { + write(", "); } + writeLine(); + write("__metadata('design:type', "); + emitSerializedTypeOfNode(node); + write(")"); + argumentsWritten++; } if (shouldEmitParamTypesMetadata(node)) { - let serializedTypes = resolver.serializeParameterTypesOfNode(node); - if (serializedTypes) { - if (writeComma || argumentsWritten) { - write(", "); - } - writeLine(); - write("__metadata('design:paramtypes', ["); - for (var i = 0; i < serializedTypes.length; ++i) { - if (i > 0) { - write(", "); - } - emitSerializedType(node, serializedTypes[i]); - } - write("])"); - argumentsWritten++; + if (writeComma || argumentsWritten) { + write(", "); } + writeLine(); + write("__metadata('design:paramtypes', ["); + emitSerializedParameterTypesOfNode(node); + write("])"); + argumentsWritten++; } if (shouldEmitReturnTypeMetadata(node)) { - let serializedType = resolver.serializeReturnTypeOfNode(node); - if (serializedType) { - if (writeComma || argumentsWritten) { - write(", "); - } - writeLine(); - write("__metadata('design:returntype', "); - emitSerializedType(node, serializedType); - write(")"); - argumentsWritten++; + if (writeComma || argumentsWritten) { + write(", "); } + + writeLine(); + write("__metadata('design:returntype', "); + emitSerializedReturnTypeOfNode(node); + write(")"); + argumentsWritten++; } } + return argumentsWritten; } - - function serializeTypeNameSegment(location: Node, path: string[], index: number): string { - switch (index) { - case 0: - return `typeof ${path[index]} !== 'undefined' && ${path[index]}`; - case 1: - return `${serializeTypeNameSegment(location, path, index - 1) }.${path[index]}`; - default: - let temp = createAndRecordTempVariable(TempFlags.Auto).text; - return `(${temp} = ${serializeTypeNameSegment(location, path, index - 1) }) && ${temp}.${path[index]}`; - } - } - - function emitSerializedType(location: Node, name: string | string[]): void { - if (typeof name === "string") { - write(name); - return; - } - else { - Debug.assert(name.length > 0, "Invalid serialized type name"); - write(`(${serializeTypeNameSegment(location, name, name.length - 1) }) || Object`); - } - } - + function emitInterfaceDeclaration(node: InterfaceDeclaration) { emitOnlyPinnedOrTripleSlashComments(node); } @@ -5823,6 +6046,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi Debug.assert(!exportFunctionForFile); // make sure that name of 'exports' function does not conflict with existing identifiers exportFunctionForFile = makeUniqueName("exports"); + writeLine(); write("System.register("); if (node.moduleName) { write(`"${node.moduleName}", `); diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 443c1c4789c..228b9516de1 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -29,6 +29,9 @@ namespace ts { declare var process: any; declare var global: any; declare var __filename: string; + declare var Buffer: { + new (str: string, encoding ?: string): any; + } declare class Enumerator { public atEnd(): boolean; @@ -267,10 +270,17 @@ namespace ts { args: process.argv.slice(2), newLine: _os.EOL, useCaseSensitiveFileNames: useCaseSensitiveFileNames, - write(s: string): void { + write(s: string): void { + var buffer = new Buffer(s, 'utf8'); + var offset: number = 0; + var toWrite: number = buffer.length; + var written = 0; // 1 is a standard descriptor for stdout - _fs.writeSync(1, s); - }, + while ((written = _fs.writeSync(1, buffer, offset, toWrite)) < toWrite) { + offset += written; + toWrite -= written; + } + }, readFile, writeFile, watchFile: (fileName, callback) => { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index b7b1c3c0b5d..205f9237033 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1846,6 +1846,27 @@ namespace ts { export interface SymbolAccessiblityResult extends SymbolVisibilityResult { errorModuleName?: string; // If the symbol is not visible from module, module's name } + + /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator + * metadata */ + /* @internal */ + export enum TypeReferenceSerializationKind { + Unknown, // The TypeReferenceNode could not be resolved. The type name + // should be emitted using a safe fallback. + TypeWithConstructSignatureAndValue, // The TypeReferenceNode resolves to a type with a constructor + // function that can be reached at runtime (e.g. a `class` + // declaration or a `var` declaration for the static side + // of a type, such as the global `Promise` type in lib.d.ts). + VoidType, // The TypeReferenceNode resolves to a Void-like type. + NumberLikeType, // The TypeReferenceNode resolves to a Number-like type. + StringLikeType, // The TypeReferenceNode resolves to a String-like type. + BooleanType, // The TypeReferenceNode resolves to a Boolean-like type. + ArrayLikeType, // The TypeReferenceNode resolves to an Array-like type. + ESSymbolType, // The TypeReferenceNode resolves to the ESSymbol type. + TypeWithCallSignature, // The TypeReferenceNode resolves to a Function type or a type + // with call signatures. + ObjectType, // The TypeReferenceNode resolves to any other type. + } /* @internal */ export interface EmitResolver { @@ -1870,9 +1891,7 @@ namespace ts { getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; getBlockScopedVariableId(node: Identifier): number; getReferencedValueDeclaration(reference: Identifier): Declaration; - serializeTypeOfNode(node: Node): string | string[]; - serializeParameterTypesOfNode(node: Node): (string | string[])[]; - serializeReturnTypeOfNode(node: Node): string | string[]; + getTypeReferenceSerializationKind(node: TypeReferenceNode): TypeReferenceSerializationKind; } export const enum SymbolFlags { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 89a694719e4..87d01cc0c07 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1687,6 +1687,10 @@ namespace ts { }); } + export function getSetAccessorTypeAnnotationNode(accessor: AccessorDeclaration): TypeNode { + return accessor && accessor.parameters.length > 0 && accessor.parameters[0].type; + } + export function shouldEmitToOwnFile(sourceFile: SourceFile, compilerOptions: CompilerOptions): boolean { if (!isDeclarationFile(sourceFile)) { if ((isExternalModule(sourceFile) || !compilerOptions.out)) { diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index 1b399e1b706..b1d43302372 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -10,6 +10,7 @@ const enum CompilerTestType { class CompilerBaselineRunner extends RunnerBase { private basePath = 'tests/cases'; + private testSuiteName: string; private errors: boolean; private emit: boolean; private decl: boolean; @@ -24,43 +25,43 @@ class CompilerBaselineRunner extends RunnerBase { this.decl = true; this.output = true; if (testType === CompilerTestType.Conformance) { - this.basePath += '/conformance'; + this.testSuiteName = 'conformance'; } else if (testType === CompilerTestType.Regressions) { - this.basePath += '/compiler'; + this.testSuiteName = 'compiler'; } else if (testType === CompilerTestType.Test262) { - this.basePath += '/test262'; + this.testSuiteName = 'test262'; } else { - this.basePath += '/compiler'; // default to this for historical reasons + this.testSuiteName = 'compiler'; // default to this for historical reasons } + this.basePath += '/' + this.testSuiteName; } public checkTestCodeOutput(fileName: string) { describe('compiler tests for ' + fileName, () => { // Mocha holds onto the closure environment of the describe callback even after the test is done. // Everything declared here should be cleared out in the "after" callback. - var justName: string; - var content: string; - var testCaseContent: { settings: Harness.TestCaseParser.CompilerSetting[]; testUnitData: Harness.TestCaseParser.TestUnitData[]; } + let justName: string; + let content: string; + let testCaseContent: { settings: Harness.TestCaseParser.CompilerSetting[]; testUnitData: Harness.TestCaseParser.TestUnitData[]; }; - var units: Harness.TestCaseParser.TestUnitData[]; - var tcSettings: Harness.TestCaseParser.CompilerSetting[]; - var createNewInstance: boolean; + let units: Harness.TestCaseParser.TestUnitData[]; + let tcSettings: Harness.TestCaseParser.CompilerSetting[]; - var lastUnit: Harness.TestCaseParser.TestUnitData; - var rootDir: string; + let lastUnit: Harness.TestCaseParser.TestUnitData; + let rootDir: string; - var result: Harness.Compiler.CompilerResult; - var program: ts.Program; - var options: ts.CompilerOptions; + let result: Harness.Compiler.CompilerResult; + let program: ts.Program; + let options: ts.CompilerOptions; // equivalent to the files that will be passed on the command line - var toBeCompiled: { unitName: string; content: string }[]; + let toBeCompiled: { unitName: string; content: string }[]; // equivalent to other files on the file system not directly passed to the compiler (ie things that are referenced by other files) - var otherFiles: { unitName: string; content: string }[]; - var harnessCompiler: Harness.Compiler.HarnessCompiler; + let otherFiles: { unitName: string; content: string }[]; + let harnessCompiler: Harness.Compiler.HarnessCompiler; - var createNewInstance = false; + let createNewInstance = false; before(() => { justName = fileName.replace(/^.*[\\\/]/, ''); // strips the fileName from the path. @@ -100,10 +101,10 @@ class CompilerBaselineRunner extends RunnerBase { }); beforeEach(() => { - /* The compiler doesn't handle certain flags flipping during a single compilation setting. Tests on these flags will need + /* The compiler doesn't handle certain flags flipping during a single compilation setting. Tests on these flags will need a fresh compiler instance for themselves and then create a fresh one for the next test. Would be nice to get dev fixes eventually to remove this limitation. */ - for (var i = 0; i < tcSettings.length; ++i) { + for (let i = 0; i < tcSettings.length; ++i) { // noImplicitAny is passed to getCompiler, but target is just passed in the settings blob to setCompilerSettings if (!createNewInstance && (tcSettings[i].flag == "noimplicitany" || tcSettings[i].flag === 'target')) { harnessCompiler = Harness.Compiler.getCompiler(); @@ -160,7 +161,7 @@ class CompilerBaselineRunner extends RunnerBase { it('Correct sourcemap content for ' + fileName, () => { if (options.sourceMap || options.inlineSourceMap) { Harness.Baseline.runBaseline('Correct sourcemap content for ' + fileName, justName.replace(/\.tsx?$/, '.sourcemap.txt'), () => { - var record = result.getSourceMapRecord(); + let record = result.getSourceMapRecord(); if (options.noEmitOnError && result.errors.length !== 0 && record === undefined) { // Because of the noEmitOnError option no files are created. We need to return null because baselining isn't required. return null; @@ -178,18 +179,18 @@ class CompilerBaselineRunner extends RunnerBase { // check js output Harness.Baseline.runBaseline('Correct JS output for ' + fileName, justName.replace(/\.tsx?/, '.js'), () => { - var tsCode = ''; - var tsSources = otherFiles.concat(toBeCompiled); + let tsCode = ''; + let tsSources = otherFiles.concat(toBeCompiled); if (tsSources.length > 1) { tsCode += '//// [' + fileName + '] ////\r\n\r\n'; } - for (var i = 0; i < tsSources.length; i++) { + for (let i = 0; i < tsSources.length; i++) { tsCode += '//// [' + Harness.Path.getFileName(tsSources[i].unitName) + ']\r\n'; tsCode += tsSources[i].content + (i < (tsSources.length - 1) ? '\r\n' : ''); } - var jsCode = ''; - for (var i = 0; i < result.files.length; i++) { + let jsCode = ''; + for (let i = 0; i < result.files.length; i++) { jsCode += '//// [' + Harness.Path.getFileName(result.files[i].fileName) + ']\r\n'; jsCode += getByteOrderMarkText(result.files[i]); jsCode += result.files[i].code; @@ -197,14 +198,14 @@ class CompilerBaselineRunner extends RunnerBase { if (result.declFilesCode.length > 0) { jsCode += '\r\n\r\n'; - for (var i = 0; i < result.declFilesCode.length; i++) { + for (let i = 0; i < result.declFilesCode.length; i++) { jsCode += '//// [' + Harness.Path.getFileName(result.declFilesCode[i].fileName) + ']\r\n'; jsCode += getByteOrderMarkText(result.declFilesCode[i]); jsCode += result.declFilesCode[i].code; } } - var declFileCompilationResult = harnessCompiler.compileDeclarationFiles(toBeCompiled, otherFiles, result, function (settings) { + let declFileCompilationResult = harnessCompiler.compileDeclarationFiles(toBeCompiled, otherFiles, result, function (settings) { harnessCompiler.setCompilerSettings(tcSettings); }, options); @@ -242,8 +243,8 @@ class CompilerBaselineRunner extends RunnerBase { return null; } - var sourceMapCode = ''; - for (var i = 0; i < result.sourceMaps.length; i++) { + let sourceMapCode = ''; + for (let i = 0; i < result.sourceMaps.length; i++) { sourceMapCode += '//// [' + Harness.Path.getFileName(result.sourceMaps[i].fileName) + ']\r\n'; sourceMapCode += getByteOrderMarkText(result.sourceMaps[i]); sourceMapCode += result.sourceMaps[i].code; @@ -261,19 +262,19 @@ class CompilerBaselineRunner extends RunnerBase { // NEWTODO: Type baselines if (result.errors.length === 0) { - // The full walker simulates the types that you would get from doing a full + // The full walker simulates the types that you would get from doing a full // compile. The pull walker simulates the types you get when you just do // a type query for a random node (like how the LS would do it). Most of the // time, these will be the same. However, occasionally, they can be different. // Specifically, when the compiler internally depends on symbol IDs to order - // things, then we may see different results because symbols can be created in a + // things, then we may see different results because symbols can be created in a // different order with 'pull' operations, and thus can produce slightly differing // output. // // For example, with a full type check, we may see a type outputed as: number | string // But with a pull type check, we may see it as: string | number // - // These types are equivalent, but depend on what order the compiler observed + // These types are equivalent, but depend on what order the compiler observed // certain parts of the program. let allFiles = toBeCompiled.concat(otherFiles).filter(file => !!program.getSourceFile(file.unitName)); @@ -291,7 +292,7 @@ class CompilerBaselineRunner extends RunnerBase { // Produce baselines. The first gives the types for all expressions. // The second gives symbols for all identifiers. - var e1: Error, e2: Error; + let e1: Error, e2: Error; try { checkBaseLines(/*isSymbolBaseLine:*/ false); } @@ -333,20 +334,20 @@ class CompilerBaselineRunner extends RunnerBase { let typeMap: { [fileName: string]: { [lineNum: number]: string[]; } } = {}; allFiles.forEach(file => { - var codeLines = file.content.split('\n'); + let codeLines = file.content.split('\n'); typeWriterResults[file.unitName].forEach(result => { if (isSymbolBaseline && !result.symbol) { return; } - var typeOrSymbolString = isSymbolBaseline ? result.symbol : result.type; - var formattedLine = result.sourceText.replace(/\r?\n/g, "") + " : " + typeOrSymbolString; + let typeOrSymbolString = isSymbolBaseline ? result.symbol : result.type; + let formattedLine = result.sourceText.replace(/\r?\n/g, "") + " : " + typeOrSymbolString; if (!typeMap[file.unitName]) { typeMap[file.unitName] = {}; } - var typeInfo = [formattedLine]; - var existingTypeInfo = typeMap[file.unitName][result.line]; + let typeInfo = [formattedLine]; + let existingTypeInfo = typeMap[file.unitName][result.line]; if (existingTypeInfo) { typeInfo = existingTypeInfo.concat(typeInfo); } @@ -354,11 +355,11 @@ class CompilerBaselineRunner extends RunnerBase { }); typeLines.push('=== ' + file.unitName + ' ===\r\n'); - for (var i = 0; i < codeLines.length; i++) { - var currentCodeLine = codeLines[i]; + for (let i = 0; i < codeLines.length; i++) { + let currentCodeLine = codeLines[i]; typeLines.push(currentCodeLine + '\r\n'); if (typeMap[file.unitName]) { - var typeInfo = typeMap[file.unitName][i]; + let typeInfo = typeMap[file.unitName][i]; if (typeInfo) { typeInfo.forEach(ty => { typeLines.push('>' + ty + '\r\n'); @@ -384,25 +385,27 @@ class CompilerBaselineRunner extends RunnerBase { } public initializeTests() { - describe("Setup compiler for compiler baselines", () => { - var harnessCompiler = Harness.Compiler.getCompiler(); - this.parseOptions(); - }); - - // this will set up a series of describe/it blocks to run between the setup and cleanup phases - if (this.tests.length === 0) { - var testFiles = this.enumerateFiles(this.basePath, /\.tsx?$/, { recursive: true }); - testFiles.forEach(fn => { - fn = fn.replace(/\\/g, "/"); - this.checkTestCodeOutput(fn); + describe(this.testSuiteName + ' tests', () => { + describe("Setup compiler for compiler baselines", () => { + let harnessCompiler = Harness.Compiler.getCompiler(); + this.parseOptions(); }); - } - else { - this.tests.forEach(test => this.checkTestCodeOutput(test)); - } - describe("Cleanup after compiler baselines", () => { - var harnessCompiler = Harness.Compiler.getCompiler(); + // this will set up a series of describe/it blocks to run between the setup and cleanup phases + if (this.tests.length === 0) { + let testFiles = this.enumerateFiles(this.basePath, /\.tsx?$/, { recursive: true }); + testFiles.forEach(fn => { + fn = fn.replace(/\\/g, "/"); + this.checkTestCodeOutput(fn); + }); + } + else { + this.tests.forEach(test => this.checkTestCodeOutput(test)); + } + + describe("Cleanup after compiler baselines", () => { + let harnessCompiler = Harness.Compiler.getCompiler(); + }); }); } @@ -413,8 +416,8 @@ class CompilerBaselineRunner extends RunnerBase { this.decl = false; this.output = false; - var opts = this.options.split(','); - for (var i = 0; i < opts.length; i++) { + let opts = this.options.split(','); + for (let i = 0; i < opts.length; i++) { switch (opts[i]) { case 'error': this.errors = true; @@ -434,4 +437,4 @@ class CompilerBaselineRunner extends RunnerBase { } } } -} \ No newline at end of file +} diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index c374f8add60..06a680a2224 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1,6 +1,6 @@ // // 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 @@ -100,7 +100,7 @@ module FourSlash { end: number; } - var entityMap: ts.Map = { + let entityMap: ts.Map = { '&': '&', '"': '"', "'": ''', @@ -116,7 +116,7 @@ module FourSlash { // Name of testcase metadata including ts.CompilerOptions properties that will be used by globalOptions // To add additional option, add property into the testOptMetadataNames, refer the property in either globalMetadataNames or fileMetadataNames // Add cases into convertGlobalOptionsToCompilationsSettings function for the compiler to acknowledge such option from meta data - var metadataOptionNames = { + let metadataOptionNames = { baselineFile: 'BaselineFile', declaration: 'declaration', emitThisFile: 'emitThisFile', // This flag is used for testing getEmitOutput feature. It allows test-cases to indicate what file to be output in multiple files project @@ -132,15 +132,15 @@ module FourSlash { }; // List of allowed metadata names - var fileMetadataNames = [metadataOptionNames.fileName, metadataOptionNames.emitThisFile, metadataOptionNames.resolveReference]; - var globalMetadataNames = [metadataOptionNames.allowNonTsExtensions, metadataOptionNames.baselineFile, metadataOptionNames.declaration, + let fileMetadataNames = [metadataOptionNames.fileName, metadataOptionNames.emitThisFile, metadataOptionNames.resolveReference]; + let globalMetadataNames = [metadataOptionNames.allowNonTsExtensions, metadataOptionNames.baselineFile, metadataOptionNames.declaration, metadataOptionNames.mapRoot, metadataOptionNames.module, metadataOptionNames.out, - metadataOptionNames.outDir, metadataOptionNames.sourceMap, metadataOptionNames.sourceRoot] + metadataOptionNames.outDir, metadataOptionNames.sourceMap, metadataOptionNames.sourceRoot]; function convertGlobalOptionsToCompilerOptions(globalOptions: { [idx: string]: string }): ts.CompilerOptions { - var settings: ts.CompilerOptions = { target: ts.ScriptTarget.ES5 }; + let settings: ts.CompilerOptions = { target: ts.ScriptTarget.ES5 }; // Convert all property in globalOptions into ts.CompilationSettings - for (var prop in globalOptions) { + for (let prop in globalOptions) { if (globalOptions.hasOwnProperty(prop)) { switch (prop) { case metadataOptionNames.allowNonTsExtensions: @@ -185,14 +185,14 @@ module FourSlash { return settings; } - export var currentTestState: TestState = null; + export let currentTestState: TestState = null; function assertionMessage(msg: string) { return "\nMarker: " + currentTestState.lastKnownMarker + "\nChecking: " + msg + "\n\n"; } export class TestCancellationToken implements ts.HostCancellationToken { // 0 - cancelled - // >0 - not cancelled + // >0 - not cancelled // <0 - not cancelled and value denotes number of isCancellationRequested after which token become cancelled private static NotCanceled: number = -1; private numberOfCallsBeforeCancellation: number = TestCancellationToken.NotCanceled; @@ -271,11 +271,11 @@ module FourSlash { private taoInvalidReason: string = null; private inputFiles: ts.Map = {}; // Map between inputFile's fileName and its content for easily looking up when resolving references - + // Add input file which has matched file name with the given reference-file path. // This is necessary when resolveReference flag is specified private addMatchedInputFile(referenceFilePath: string) { - var inputFile = this.inputFiles[referenceFilePath]; + let inputFile = this.inputFiles[referenceFilePath]; if (inputFile && !Harness.isLibraryFile(referenceFilePath)) { this.languageServiceAdapterHost.addScript(referenceFilePath, inputFile); } @@ -297,13 +297,13 @@ module FourSlash { constructor(private basePath: string, private testType: FourSlashTestType, public testData: FourSlashData) { // Create a new Services Adapter this.cancellationToken = new TestCancellationToken(); - var compilationOptions = convertGlobalOptionsToCompilerOptions(this.testData.globalOptions); - var languageServiceAdapter = this.getLanguageServiceAdapter(testType, this.cancellationToken, compilationOptions); + let compilationOptions = convertGlobalOptionsToCompilerOptions(this.testData.globalOptions); + let languageServiceAdapter = this.getLanguageServiceAdapter(testType, this.cancellationToken, compilationOptions); this.languageServiceAdapterHost = languageServiceAdapter.getHost(); this.languageService = languageServiceAdapter.getLanguageService(); // Initialize the language service with all the scripts - var startResolveFileRef: FourSlashFile; + let startResolveFileRef: FourSlashFile; ts.forEach(testData.files, file => { // Create map between fileName and its content for easily looking up when resolveReference flag is specified @@ -320,14 +320,14 @@ module FourSlash { // Add the entry-point file itself into the languageServiceShimHost this.languageServiceAdapterHost.addScript(startResolveFileRef.fileName, startResolveFileRef.content); - var resolvedResult = languageServiceAdapter.getPreProcessedFileInfo(startResolveFileRef.fileName, startResolveFileRef.content); - var referencedFiles: ts.FileReference[] = resolvedResult.referencedFiles; - var importedFiles: ts.FileReference[] = resolvedResult.importedFiles; + let resolvedResult = languageServiceAdapter.getPreProcessedFileInfo(startResolveFileRef.fileName, startResolveFileRef.content); + let referencedFiles: ts.FileReference[] = resolvedResult.referencedFiles; + let importedFiles: ts.FileReference[] = resolvedResult.importedFiles; // Add triple reference files into language-service host ts.forEach(referencedFiles, referenceFile => { // Fourslash insert tests/cases/fourslash into inputFile.unitName so we will properly append the same base directory to refFile path - var referenceFilePath = this.basePath + '/' + referenceFile.fileName; + let referenceFilePath = this.basePath + '/' + referenceFile.fileName; this.addMatchedInputFile(referenceFilePath); }); @@ -335,7 +335,7 @@ module FourSlash { ts.forEach(importedFiles, importedFile => { // Fourslash insert tests/cases/fourslash into inputFile.unitName and import statement doesn't require ".ts" // so convert them before making appropriate comparison - var importedFilePath = this.basePath + '/' + importedFile.fileName + ".ts"; + let importedFilePath = this.basePath + '/' + importedFile.fileName + ".ts"; this.addMatchedInputFile(importedFilePath); }); @@ -370,8 +370,8 @@ module FourSlash { }; this.testData.files.forEach(file => { - var fileName = file.fileName.replace(Harness.IO.directoryName(file.fileName), '').substr(1); - var fileNameWithoutExtension = fileName.substr(0, fileName.lastIndexOf(".")); + let fileName = file.fileName.replace(Harness.IO.directoryName(file.fileName), '').substr(1); + let fileNameWithoutExtension = fileName.substr(0, fileName.lastIndexOf(".")); this.scenarioActions.push(''); }); @@ -380,18 +380,18 @@ module FourSlash { } private getFileContent(fileName: string): string { - var script = this.languageServiceAdapterHost.getScriptInfo(fileName); + let script = this.languageServiceAdapterHost.getScriptInfo(fileName); return script.content; } // Entry points from fourslash.ts public goToMarker(name = '') { - var marker = this.getMarkerByName(name); + let marker = this.getMarkerByName(name); if (this.activeFile.fileName !== marker.fileName) { this.openFile(marker.fileName); } - var content = this.getFileContent(marker.fileName); + let content = this.getFileContent(marker.fileName); if (marker.position === -1 || marker.position > content.length) { throw new Error('Marker "' + name + '" has been invalidated by unrecoverable edits to the file.'); } @@ -402,8 +402,8 @@ module FourSlash { public goToPosition(pos: number) { this.currentCaretPosition = pos; - var lineStarts = ts.computeLineStarts(this.getFileContent(this.activeFile.fileName)); - var lineCharPos = ts.computeLineAndCharacterOfPosition(lineStarts, pos); + let lineStarts = ts.computeLineStarts(this.getFileContent(this.activeFile.fileName)); + let lineCharPos = ts.computeLineAndCharacterOfPosition(lineStarts, pos); this.scenarioActions.push(``); } @@ -421,24 +421,24 @@ module FourSlash { public openFile(index: number): void; public openFile(name: string): void; public openFile(indexOrName: any) { - var fileToOpen: FourSlashFile = this.findFile(indexOrName); + let fileToOpen: FourSlashFile = this.findFile(indexOrName); fileToOpen.fileName = ts.normalizeSlashes(fileToOpen.fileName); this.activeFile = fileToOpen; - var fileName = fileToOpen.fileName.replace(Harness.IO.directoryName(fileToOpen.fileName), '').substr(1); + let fileName = fileToOpen.fileName.replace(Harness.IO.directoryName(fileToOpen.fileName), '').substr(1); this.scenarioActions.push(''); - + // Let the host know that this file is now open this.languageServiceAdapterHost.openFile(fileToOpen.fileName); } public verifyErrorExistsBetweenMarkers(startMarkerName: string, endMarkerName: string, negative: boolean) { - var startMarker = this.getMarkerByName(startMarkerName); - var endMarker = this.getMarkerByName(endMarkerName); - var predicate = function (errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) { + let startMarker = this.getMarkerByName(startMarkerName); + let endMarker = this.getMarkerByName(endMarkerName); + let predicate = function (errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) { return ((errorMinChar === startPos) && (errorLimChar === endPos)) ? true : false; }; - var exists = this.anyErrorInRange(predicate, startMarker, endMarker); + let exists = this.anyErrorInRange(predicate, startMarker, endMarker); this.taoInvalidReason = 'verifyErrorExistsBetweenMarkers NYI'; @@ -458,10 +458,10 @@ module FourSlash { } private getDiagnostics(fileName: string): ts.Diagnostic[] { - var syntacticErrors = this.languageService.getSyntacticDiagnostics(fileName); - var semanticErrors = this.languageService.getSemanticDiagnostics(fileName); + let syntacticErrors = this.languageService.getSyntacticDiagnostics(fileName); + let semanticErrors = this.languageService.getSemanticDiagnostics(fileName); - var diagnostics: ts.Diagnostic[] = []; + let diagnostics: ts.Diagnostic[] = []; diagnostics.push.apply(diagnostics, syntacticErrors); diagnostics.push.apply(diagnostics, semanticErrors); @@ -469,10 +469,10 @@ module FourSlash { } private getAllDiagnostics(): ts.Diagnostic[] { - var diagnostics: ts.Diagnostic[] = []; + let diagnostics: ts.Diagnostic[] = []; - var fileNames = this.languageServiceAdapterHost.getFilenames(); - for (var i = 0, n = fileNames.length; i < n; i++) { + let fileNames = this.languageServiceAdapterHost.getFilenames(); + for (let i = 0, n = fileNames.length; i < n; i++) { diagnostics.push.apply(this.getDiagnostics(fileNames[i])); } @@ -480,8 +480,8 @@ module FourSlash { } public verifyErrorExistsAfterMarker(markerName: string, negative: boolean, after: boolean) { - var marker: Marker = this.getMarkerByName(markerName); - var predicate: (errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) => boolean; + let marker: Marker = this.getMarkerByName(markerName); + let predicate: (errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) => boolean; if (after) { predicate = function (errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) { @@ -495,8 +495,8 @@ module FourSlash { this.taoInvalidReason = 'verifyErrorExistsAfterMarker NYI'; - var exists = this.anyErrorInRange(predicate, marker); - var diagnostics = this.getAllDiagnostics(); + let exists = this.anyErrorInRange(predicate, marker); + let diagnostics = this.getAllDiagnostics(); if (exists !== negative) { this.printErrorLog(negative, diagnostics); @@ -506,12 +506,13 @@ module FourSlash { private anyErrorInRange(predicate: (errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) => boolean, startMarker: Marker, endMarker?: Marker) { - var errors = this.getDiagnostics(startMarker.fileName); - var exists = false; + let errors = this.getDiagnostics(startMarker.fileName); + let exists = false; - var startPos = startMarker.position; + let startPos = startMarker.position; + let endPos: number = undefined; if (endMarker !== undefined) { - var endPos = endMarker.position; + endPos = endMarker.position; } errors.forEach(function (error: ts.Diagnostic) { @@ -538,40 +539,40 @@ module FourSlash { } public verifyNumberOfErrorsInCurrentFile(expected: number) { - var errors = this.getDiagnostics(this.activeFile.fileName); - var actual = errors.length; + let errors = this.getDiagnostics(this.activeFile.fileName); + let actual = errors.length; this.scenarioActions.push(''); if (actual !== expected) { this.printErrorLog(false, errors); - var errorMsg = "Actual number of errors (" + actual + ") does not match expected number (" + expected + ")"; + let errorMsg = "Actual number of errors (" + actual + ") does not match expected number (" + expected + ")"; Harness.IO.log(errorMsg); this.raiseError(errorMsg); } } public verifyEval(expr: string, value: any) { - var emit = this.languageService.getEmitOutput(this.activeFile.fileName); + let emit = this.languageService.getEmitOutput(this.activeFile.fileName); if (emit.outputFiles.length !== 1) { throw new Error("Expected exactly one output from emit of " + this.activeFile.fileName); } this.taoInvalidReason = 'verifyEval impossible'; - var evaluation = new Function(emit.outputFiles[0].text + ';\r\nreturn (' + expr + ');')(); + let evaluation = new Function(emit.outputFiles[0].text + ';\r\nreturn (' + expr + ');')(); if (evaluation !== value) { this.raiseError('Expected evaluation of expression "' + expr + '" to equal "' + value + '", but got "' + evaluation + '"'); } } public verifyGetEmitOutputForCurrentFile(expected: string): void { - var emit = this.languageService.getEmitOutput(this.activeFile.fileName); + let emit = this.languageService.getEmitOutput(this.activeFile.fileName); if (emit.outputFiles.length !== 1) { throw new Error("Expected exactly one output from emit of " + this.activeFile.fileName); } this.taoInvalidReason = 'verifyGetEmitOutputForCurrentFile impossible'; - var actual = emit.outputFiles[0].text; + let actual = emit.outputFiles[0].text; if (actual !== expected) { this.raiseError("Expected emit output to be '" + expected + "', but got '" + actual + "'"); } @@ -585,7 +586,7 @@ module FourSlash { this.taoInvalidReason = 'verifyMemberListContains only supports the "symbol" parameter'; } - var members = this.getMemberListAtCaret(); + let members = this.getMemberListAtCaret(); if (members) { this.assertItemInCompletionList(members.entries, symbol, text, documentation, kind); } @@ -607,10 +608,10 @@ module FourSlash { this.scenarioActions.push(''); } - var members = this.getMemberListAtCaret(); + let members = this.getMemberListAtCaret(); if (members) { - var match = members.entries.length === expectedCount; + let match = members.entries.length === expectedCount; if ((!match && !negative) || (match && negative)) { this.raiseError("Member list count was " + members.entries.length + ". Expected " + expectedCount); @@ -625,7 +626,7 @@ module FourSlash { this.scenarioActions.push(''); this.scenarioActions.push(''); - var members = this.getMemberListAtCaret(); + let members = this.getMemberListAtCaret(); if (members && members.entries.filter(e => e.name === symbol).length !== 0) { this.raiseError('Member list did contain ' + symbol); } @@ -634,8 +635,8 @@ module FourSlash { public verifyCompletionListItemsCountIsGreaterThan(count: number) { this.taoInvalidReason = 'verifyCompletionListItemsCountIsGreaterThan NYI'; - var completions = this.getCompletionListAtCaret(); - var itemsCount = completions.entries.length; + let completions = this.getCompletionListAtCaret(); + let itemsCount = completions.entries.length; if (itemsCount <= count) { this.raiseError('Expected completion list items count to be greater than ' + count + ', but is actually ' + itemsCount); @@ -649,13 +650,13 @@ module FourSlash { this.scenarioActions.push(''); } - var members = this.getMemberListAtCaret(); + let members = this.getMemberListAtCaret(); if ((!members || members.entries.length === 0) && negative) { this.raiseError("Member list is empty at Caret"); } else if ((members && members.entries.length !== 0) && !negative) { - var errorMsg = "\n" + "Member List contains: [" + members.entries[0].name; - for (var i = 1; i < members.entries.length; i++) { + let errorMsg = "\n" + "Member List contains: [" + members.entries[0].name; + for (let i = 1; i < members.entries.length; i++) { errorMsg += ", " + members.entries[i].name; } errorMsg += "]\n"; @@ -668,13 +669,13 @@ module FourSlash { public verifyCompletionListIsEmpty(negative: boolean) { this.scenarioActions.push(''); - var completions = this.getCompletionListAtCaret(); + let completions = this.getCompletionListAtCaret(); if ((!completions || completions.entries.length === 0) && negative) { this.raiseError("Completion list is empty at Caret"); } else if ((completions && completions.entries.length !== 0) && !negative) { - var errorMsg = "\n" + "Completion List contains: [" + completions.entries[0].name; - for (var i = 1; i < completions.entries.length; i++) { + let errorMsg = "\n" + "Completion List contains: [" + completions.entries[0].name; + for (let i = 1; i < completions.entries.length; i++) { errorMsg += ", " + completions.entries[i].name; } errorMsg += "]\n"; @@ -685,7 +686,7 @@ module FourSlash { } public verifyCompletionListAllowsNewIdentifier(negative: boolean) { - var completions = this.getCompletionListAtCaret(); + let completions = this.getCompletionListAtCaret(); if ((completions && !completions.isNewIdentifierLocation) && !negative) { this.raiseError("Expected builder completion entry"); @@ -695,7 +696,7 @@ module FourSlash { } public verifyCompletionListContains(symbol: string, text?: string, documentation?: string, kind?: string) { - var completions = this.getCompletionListAtCaret(); + let completions = this.getCompletionListAtCaret(); if (completions) { this.assertItemInCompletionList(completions.entries, symbol, text, documentation, kind); } @@ -737,7 +738,7 @@ module FourSlash { this.scenarioActions.push(''); this.scenarioActions.push(''); - var completions = this.getCompletionListAtCaret(); + let completions = this.getCompletionListAtCaret(); if (completions) { let filterCompletions = completions.entries.filter(e => e.name === symbol); filterCompletions = expectedKind ? filterCompletions.filter(e => e.kind === expectedKind) : filterCompletions; @@ -755,7 +756,7 @@ module FourSlash { error += "Expected documentation: " + expectedDocumentation + " to equal: " + ts.displayPartsToString(details.documentation) + "."; } if (expectedKind) { - error += "Expected kind: " + expectedKind + " to equal: " + filterCompletions[0].kind + "." + error += "Expected kind: " + expectedKind + " to equal: " + filterCompletions[0].kind + "."; } this.raiseError(error); } @@ -765,7 +766,7 @@ module FourSlash { public verifyCompletionEntryDetails(entryName: string, expectedText: string, expectedDocumentation?: string, kind?: string) { this.taoInvalidReason = 'verifyCompletionEntryDetails NYI'; - var details = this.getCompletionEntryDetails(entryName); + let details = this.getCompletionEntryDetails(entryName); assert.equal(ts.displayPartsToString(details.displayParts), expectedText, assertionMessage("completion entry details text")); @@ -781,14 +782,14 @@ module FourSlash { public verifyReferencesAtPositionListContains(fileName: string, start: number, end: number, isWriteAccess?: boolean) { this.taoInvalidReason = 'verifyReferencesAtPositionListContains NYI'; - var references = this.getReferencesAtCaret(); + let references = this.getReferencesAtCaret(); if (!references || references.length === 0) { this.raiseError('verifyReferencesAtPositionListContains failed - found 0 references, expected at least one.'); } - for (var i = 0; i < references.length; i++) { - var reference = references[i]; + for (let i = 0; i < references.length; i++) { + let reference = references[i]; if (reference && reference.fileName === fileName && reference.textSpan.start === start && ts.textSpanEnd(reference.textSpan) === end) { if (typeof isWriteAccess !== "undefined" && reference.isWriteAccess !== isWriteAccess) { this.raiseError('verifyReferencesAtPositionListContains failed - item isWriteAccess value does not match, actual: ' + reference.isWriteAccess + ', expected: ' + isWriteAccess + '.'); @@ -797,18 +798,18 @@ module FourSlash { } } - var missingItem = { fileName: fileName, start: start, end: end, isWriteAccess: isWriteAccess }; + let missingItem = { fileName: fileName, start: start, end: end, isWriteAccess: isWriteAccess }; this.raiseError('verifyReferencesAtPositionListContains failed - could not find the item: ' + JSON.stringify(missingItem) + ' in the returned list: (' + JSON.stringify(references) + ')'); } public verifyReferencesCountIs(count: number, localFilesOnly: boolean = true) { this.taoInvalidReason = 'verifyReferences NYI'; - var references = this.getReferencesAtCaret(); - var referencesCount = 0; + let references = this.getReferencesAtCaret(); + let referencesCount = 0; if (localFilesOnly) { - var localFiles = this.testData.files.map(file => file.fileName); + let localFiles = this.testData.files.map(file => file.fileName); // Count only the references in local files. Filter the ones in lib and other files. ts.forEach(references, entry => { if (localFiles.some((fileName) => fileName === entry.fileName)) { @@ -821,7 +822,7 @@ module FourSlash { } if (referencesCount !== count) { - var condition = localFilesOnly ? "excluding libs" : "including libs"; + let condition = localFilesOnly ? "excluding libs" : "including libs"; this.raiseError("Expected references count (" + condition + ") to be " + count + ", but is actually " + referencesCount); } } @@ -847,18 +848,18 @@ module FourSlash { } public getSyntacticDiagnostics(expected: string) { - var diagnostics = this.languageService.getSyntacticDiagnostics(this.activeFile.fileName); + let diagnostics = this.languageService.getSyntacticDiagnostics(this.activeFile.fileName); this.testDiagnostics(expected, diagnostics); } public getSemanticDiagnostics(expected: string) { - var diagnostics = this.languageService.getSemanticDiagnostics(this.activeFile.fileName); + let diagnostics = this.languageService.getSemanticDiagnostics(this.activeFile.fileName); this.testDiagnostics(expected, diagnostics); } private testDiagnostics(expected: string, diagnostics: ts.Diagnostic[]) { - var realized = ts.realizeDiagnostics(diagnostics, "\r\n"); - var actual = JSON.stringify(realized, null, " "); + let realized = ts.realizeDiagnostics(diagnostics, "\r\n"); + let actual = JSON.stringify(realized, null, " "); assert.equal(actual, expected); } @@ -870,9 +871,9 @@ module FourSlash { } }); - var actualQuickInfo = this.languageService.getQuickInfoAtPosition(this.activeFile.fileName, this.currentCaretPosition); - var actualQuickInfoText = actualQuickInfo ? ts.displayPartsToString(actualQuickInfo.displayParts) : ""; - var actualQuickInfoDocumentation = actualQuickInfo ? ts.displayPartsToString(actualQuickInfo.documentation) : ""; + let actualQuickInfo = this.languageService.getQuickInfoAtPosition(this.activeFile.fileName, this.currentCaretPosition); + let actualQuickInfoText = actualQuickInfo ? ts.displayPartsToString(actualQuickInfo.displayParts) : ""; + let actualQuickInfoDocumentation = actualQuickInfo ? ts.displayPartsToString(actualQuickInfo.documentation) : ""; if (negative) { if (expectedText !== undefined) { @@ -900,7 +901,7 @@ module FourSlash { this.scenarioActions.push(''); function getDisplayPartsJson(displayParts: ts.SymbolDisplayPart[]) { - var result = ""; + let result = ""; ts.forEach(displayParts, part => { if (result) { result += ",\n "; @@ -917,7 +918,7 @@ module FourSlash { return result; } - var actualQuickInfo = this.languageService.getQuickInfoAtPosition(this.activeFile.fileName, this.currentCaretPosition); + let actualQuickInfo = this.languageService.getQuickInfoAtPosition(this.activeFile.fileName, this.currentCaretPosition); assert.equal(actualQuickInfo.kind, kind, this.messageAtLastKnownMarker("QuickInfo kind")); assert.equal(actualQuickInfo.kindModifiers, kindModifiers, this.messageAtLastKnownMarker("QuickInfo kindModifiers")); assert.equal(JSON.stringify(actualQuickInfo.textSpan), JSON.stringify(textSpan), this.messageAtLastKnownMarker("QuickInfo textSpan")); @@ -926,12 +927,12 @@ module FourSlash { } public verifyRenameLocations(findInStrings: boolean, findInComments: boolean) { - var renameInfo = this.languageService.getRenameInfo(this.activeFile.fileName, this.currentCaretPosition); + let renameInfo = this.languageService.getRenameInfo(this.activeFile.fileName, this.currentCaretPosition); if (renameInfo.canRename) { - var references = this.languageService.findRenameLocations( + let references = this.languageService.findRenameLocations( this.activeFile.fileName, this.currentCaretPosition, findInStrings, findInComments); - var ranges = this.getRanges(); + let ranges = this.getRanges(); if (!references) { if (ranges.length !== 0) { @@ -947,9 +948,9 @@ module FourSlash { ranges = ranges.sort((r1, r2) => r1.start - r2.start); references = references.sort((r1, r2) => r1.textSpan.start - r2.textSpan.start); - for (var i = 0, n = ranges.length; i < n; i++) { - var reference = references[i]; - var range = ranges[i]; + for (let i = 0, n = ranges.length; i < n; i++) { + let reference = references[i]; + let range = ranges[i]; if (reference.textSpan.start !== range.start || ts.textSpanEnd(reference.textSpan) !== range.end) { @@ -966,7 +967,7 @@ module FourSlash { public verifyQuickInfoExists(negative: boolean) { this.taoInvalidReason = 'verifyQuickInfoExists NYI'; - var actualQuickInfo = this.languageService.getQuickInfoAtPosition(this.activeFile.fileName, this.currentCaretPosition); + let actualQuickInfo = this.languageService.getQuickInfoAtPosition(this.activeFile.fileName, this.currentCaretPosition); if (negative) { if (actualQuickInfo) { this.raiseError('verifyQuickInfoExists failed. Expected quick info NOT to exist'); @@ -982,17 +983,17 @@ module FourSlash { public verifyCurrentSignatureHelpIs(expected: string) { this.taoInvalidReason = 'verifyCurrentSignatureHelpIs NYI'; - var help = this.getActiveSignatureHelpItem(); + let help = this.getActiveSignatureHelpItem(); assert.equal( ts.displayPartsToString(help.prefixDisplayParts) + help.parameters.map(p => ts.displayPartsToString(p.displayParts)).join(ts.displayPartsToString(help.separatorDisplayParts)) + ts.displayPartsToString(help.suffixDisplayParts), expected); } - public verifyCurrentParameterIsVariable(isVariable: boolean) { - this.taoInvalidReason = 'verifyCurrentParameterIsVariable NYI'; + public verifyCurrentParameterIsletiable(isVariable: boolean) { + this.taoInvalidReason = 'verifyCurrentParameterIsletiable NYI'; - var signature = this.getActiveSignatureHelpItem(); + let signature = this.getActiveSignatureHelpItem(); assert.isNotNull(signature); assert.equal(isVariable, signature.isVariadic); } @@ -1000,24 +1001,24 @@ module FourSlash { public verifyCurrentParameterHelpName(name: string) { this.taoInvalidReason = 'verifyCurrentParameterHelpName NYI'; - var activeParameter = this.getActiveParameter(); - var activeParameterName = activeParameter.name; + let activeParameter = this.getActiveParameter(); + let activeParameterName = activeParameter.name; assert.equal(activeParameterName, name); } public verifyCurrentParameterSpanIs(parameter: string) { this.taoInvalidReason = 'verifyCurrentParameterSpanIs NYI'; - var activeSignature = this.getActiveSignatureHelpItem(); - var activeParameter = this.getActiveParameter(); + let activeSignature = this.getActiveSignatureHelpItem(); + let activeParameter = this.getActiveParameter(); assert.equal(ts.displayPartsToString(activeParameter.displayParts), parameter); } public verifyCurrentParameterHelpDocComment(docComment: string) { this.taoInvalidReason = 'verifyCurrentParameterHelpDocComment NYI'; - var activeParameter = this.getActiveParameter(); - var activeParameterDocComment = activeParameter.documentation; + let activeParameter = this.getActiveParameter(); + let activeParameterDocComment = activeParameter.documentation; assert.equal(ts.displayPartsToString(activeParameterDocComment), docComment, assertionMessage("current parameter Help DocComment")); } @@ -1036,7 +1037,7 @@ module FourSlash { public verifyCurrentSignatureHelpDocComment(docComment: string) { this.taoInvalidReason = 'verifyCurrentSignatureHelpDocComment NYI'; - var actualDocComment = this.getActiveSignatureHelpItem().documentation; + let actualDocComment = this.getActiveSignatureHelpItem().documentation; assert.equal(ts.displayPartsToString(actualDocComment), docComment, assertionMessage("current signature help doc comment")); } @@ -1044,22 +1045,22 @@ module FourSlash { this.scenarioActions.push(''); this.scenarioActions.push(''); - var help = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); - var actual = help && help.items ? help.items.length : 0; + let help = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); + let actual = help && help.items ? help.items.length : 0; assert.equal(actual, expected); } public verifySignatureHelpArgumentCount(expected: number) { this.taoInvalidReason = 'verifySignatureHelpArgumentCount NYI'; - var signatureHelpItems = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); - var actual = signatureHelpItems.argumentCount; + let signatureHelpItems = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); + let actual = signatureHelpItems.argumentCount; assert.equal(actual, expected); } public verifySignatureHelpPresent(shouldBePresent = true) { this.taoInvalidReason = 'verifySignatureHelpPresent NYI'; - var actual = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); + let actual = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); if (shouldBePresent) { if (!actual) { this.raiseError("Expected signature help to be present, but it wasn't"); @@ -1078,7 +1079,7 @@ module FourSlash { } public verifyRenameInfoSucceeded(displayName?: string, fullDisplayName?: string, kind?: string, kindModifiers?: string) { - var renameInfo = this.languageService.getRenameInfo(this.activeFile.fileName, this.currentCaretPosition); + let renameInfo = this.languageService.getRenameInfo(this.activeFile.fileName, this.currentCaretPosition); if (!renameInfo.canRename) { this.raiseError("Rename did not succeed"); } @@ -1092,7 +1093,7 @@ module FourSlash { this.raiseError("Expected a single range to be selected in the test file."); } - var expectedRange = this.getRanges()[0]; + let expectedRange = this.getRanges()[0]; if (renameInfo.triggerSpan.start !== expectedRange.start || ts.textSpanEnd(renameInfo.triggerSpan) !== expectedRange.end) { this.raiseError("Expected triggerSpan [" + expectedRange.start + "," + expectedRange.end + "). Got [" + @@ -1101,7 +1102,7 @@ module FourSlash { } public verifyRenameInfoFailed(message?: string) { - var renameInfo = this.languageService.getRenameInfo(this.activeFile.fileName, this.currentCaretPosition); + let renameInfo = this.languageService.getRenameInfo(this.activeFile.fileName, this.currentCaretPosition); if (renameInfo.canRename) { this.raiseError("Rename was expected to fail"); } @@ -1110,26 +1111,26 @@ module FourSlash { } private getActiveSignatureHelpItem() { - var help = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); - var index = help.selectedItemIndex; + let help = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); + let index = help.selectedItemIndex; return help.items[index]; } private getActiveParameter(): ts.SignatureHelpParameter { - var help = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); - var item = help.items[help.selectedItemIndex]; - var currentParam = help.argumentIndex; + let help = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); + let item = help.items[help.selectedItemIndex]; + let currentParam = help.argumentIndex; return item.parameters[currentParam]; } private alignmentForExtraInfo = 50; private spanInfoToString(pos: number, spanInfo: ts.TextSpan, prefixString: string) { - var resultString = "SpanInfo: " + JSON.stringify(spanInfo); + let resultString = "SpanInfo: " + JSON.stringify(spanInfo); if (spanInfo) { - var spanString = this.activeFile.content.substr(spanInfo.start, spanInfo.length); - var spanLineMap = ts.computeLineStarts(spanString); - for (var i = 0; i < spanLineMap.length; i++) { + let spanString = this.activeFile.content.substr(spanInfo.start, spanInfo.length); + let spanLineMap = ts.computeLineStarts(spanString); + for (let i = 0; i < spanLineMap.length; i++) { if (!i) { resultString += "\n"; } @@ -1142,19 +1143,20 @@ module FourSlash { } private baselineCurrentFileLocations(getSpanAtPos: (pos: number) => ts.TextSpan): string { - var fileLineMap = ts.computeLineStarts(this.activeFile.content); - var nextLine = 0; - var resultString = ""; - var currentLine: string; - var previousSpanInfo: string; - var startColumn: number; - var length: number; - var prefixString = " >"; + let fileLineMap = ts.computeLineStarts(this.activeFile.content); + let nextLine = 0; + let resultString = ""; + let currentLine: string; + let previousSpanInfo: string; + let startColumn: number; + let length: number; + let prefixString = " >"; - var addSpanInfoString = () => { + let pos = 0; + let addSpanInfoString = () => { if (previousSpanInfo) { resultString += currentLine; - var thisLineMarker = repeatString(startColumn, " ") + repeatString(length, "~"); + let thisLineMarker = repeatString(startColumn, " ") + repeatString(length, "~"); thisLineMarker += repeatString(this.alignmentForExtraInfo - thisLineMarker.length - prefixString.length + 1, " "); resultString += thisLineMarker; resultString += "=> Pos: (" + (pos - length) + " to " + (pos - 1) + ") "; @@ -1163,7 +1165,7 @@ module FourSlash { } }; - for (var pos = 0; pos < this.activeFile.content.length; pos++) { + for (; pos < this.activeFile.content.length; pos++) { if (pos === 0 || pos === fileLineMap[nextLine]) { nextLine++; addSpanInfoString(); @@ -1174,7 +1176,7 @@ module FourSlash { startColumn = 0; length = 0; } - var spanInfo = this.spanInfoToString(pos, getSpanAtPos(pos), prefixString); + let spanInfo = this.spanInfoToString(pos, getSpanAtPos(pos), prefixString); if (previousSpanInfo && previousSpanInfo !== spanInfo) { addSpanInfoString(); previousSpanInfo = spanInfo; @@ -1190,8 +1192,8 @@ module FourSlash { return resultString; function repeatString(count: number, char: string) { - var result = ""; - for (var i = 0; i < count; i++) { + let result = ""; + for (let i = 0; i < count; i++) { result += char; } return result; @@ -1218,11 +1220,11 @@ module FourSlash { public baselineGetEmitOutput() { this.taoInvalidReason = 'baselineGetEmitOutput impossible'; // Find file to be emitted - var emitFiles: FourSlashFile[] = []; // List of FourSlashFile that has emitThisFile flag on + let emitFiles: FourSlashFile[] = []; // List of FourSlashFile that has emitThisFile flag on - var allFourSlashFiles = this.testData.files; - for (var idx = 0; idx < allFourSlashFiles.length; ++idx) { - var file = allFourSlashFiles[idx]; + let allFourSlashFiles = this.testData.files; + for (let idx = 0; idx < allFourSlashFiles.length; ++idx) { + let file = allFourSlashFiles[idx]; if (file.fileOptions[metadataOptionNames.emitThisFile] === "true") { // Find a file with the flag emitThisFile turned on emitFiles.push(file); @@ -1238,23 +1240,23 @@ module FourSlash { "Generate getEmitOutput baseline : " + emitFiles.join(" "), this.testData.globalOptions[metadataOptionNames.baselineFile], () => { - var resultString = ""; + let resultString = ""; // Loop through all the emittedFiles and emit them one by one emitFiles.forEach(emitFile => { - var emitOutput = this.languageService.getEmitOutput(emitFile.fileName); + let emitOutput = this.languageService.getEmitOutput(emitFile.fileName); // Print emitOutputStatus in readable format resultString += "EmitSkipped: " + emitOutput.emitSkipped + ts.sys.newLine; if (emitOutput.emitSkipped) { resultString += "Diagnostics:" + ts.sys.newLine; - var diagnostics = ts.getPreEmitDiagnostics(this.languageService.getProgram()); - for (var i = 0, n = diagnostics.length; i < n; i++) { + let diagnostics = ts.getPreEmitDiagnostics(this.languageService.getProgram()); + for (let i = 0, n = diagnostics.length; i < n; i++) { resultString += " " + diagnostics[0].messageText + ts.sys.newLine; } } emitOutput.outputFiles.forEach((outputFile, idx, array) => { - var fileName = "FileName : " + outputFile.name + ts.sys.newLine; + let fileName = "FileName : " + outputFile.name + ts.sys.newLine; resultString = resultString + fileName + outputFile.text; }); resultString += ts.sys.newLine; @@ -1274,19 +1276,19 @@ module FourSlash { } public printCurrentParameterHelp() { - var help = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); + let help = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition); Harness.IO.log(JSON.stringify(help)); } public printCurrentQuickInfo() { - var quickInfo = this.languageService.getQuickInfoAtPosition(this.activeFile.fileName, this.currentCaretPosition); + let quickInfo = this.languageService.getQuickInfoAtPosition(this.activeFile.fileName, this.currentCaretPosition); Harness.IO.log(JSON.stringify(quickInfo)); } public printErrorList() { - var syntacticErrors = this.languageService.getSyntacticDiagnostics(this.activeFile.fileName); - var semanticErrors = this.languageService.getSemanticDiagnostics(this.activeFile.fileName); - var errorList = syntacticErrors.concat(semanticErrors); + let syntacticErrors = this.languageService.getSyntacticDiagnostics(this.activeFile.fileName); + let semanticErrors = this.languageService.getSemanticDiagnostics(this.activeFile.fileName); + let errorList = syntacticErrors.concat(semanticErrors); Harness.IO.log('Error list (' + errorList.length + ' errors)'); if (errorList.length) { @@ -1300,11 +1302,11 @@ module FourSlash { } public printCurrentFileState(makeWhitespaceVisible = false, makeCaretVisible = true) { - for (var i = 0; i < this.testData.files.length; i++) { - var file = this.testData.files[i]; - var active = (this.activeFile === file); + for (let i = 0; i < this.testData.files.length; i++) { + let file = this.testData.files[i]; + let active = (this.activeFile === file); Harness.IO.log('=== Script (' + file.fileName + ') ' + (active ? '(active, cursor at |)' : '') + ' ==='); - var content = this.getFileContent(file.fileName); + let content = this.getFileContent(file.fileName); if (active) { content = content.substr(0, this.currentCaretPosition) + (makeCaretVisible ? '|' : "") + content.substr(this.currentCaretPosition); } @@ -1316,22 +1318,22 @@ module FourSlash { } public printCurrentSignatureHelp() { - var sigHelp = this.getActiveSignatureHelpItem(); + let sigHelp = this.getActiveSignatureHelpItem(); Harness.IO.log(JSON.stringify(sigHelp)); } public printMemberListMembers() { - var members = this.getMemberListAtCaret(); + let members = this.getMemberListAtCaret(); Harness.IO.log(JSON.stringify(members)); } public printCompletionListMembers() { - var completions = this.getCompletionListAtCaret(); + let completions = this.getCompletionListAtCaret(); Harness.IO.log(JSON.stringify(completions)); } public printReferences() { - var references = this.getReferencesAtCaret(); + let references = this.getReferencesAtCaret(); ts.forEach(references, entry => { Harness.IO.log(JSON.stringify(entry)); }); @@ -1344,26 +1346,26 @@ module FourSlash { public deleteChar(count = 1) { this.scenarioActions.push(''); - var offset = this.currentCaretPosition; - var ch = ""; + let offset = this.currentCaretPosition; + let ch = ""; - var checkCadence = (count >> 2) + 1 + let checkCadence = (count >> 2) + 1; - for (var i = 0; i < count; i++) { + for (let i = 0; i < count; i++) { // Make the edit this.languageServiceAdapterHost.editScript(this.activeFile.fileName, offset, offset + 1, ch); this.updateMarkersForEdit(this.activeFile.fileName, offset, offset + 1, ch); if (i % checkCadence === 0) { - this.checkPostEditInvariants(); + this.checkPostEditInletiants(); } // Handle post-keystroke formatting if (this.enableFormatting) { - var edits = this.languageService.getFormattingEditsAfterKeystroke(this.activeFile.fileName, offset, ch, this.formatCodeOptions); + let edits = this.languageService.getFormattingEditsAfterKeystroke(this.activeFile.fileName, offset, ch, this.formatCodeOptions); if (edits.length) { offset += this.applyEdits(this.activeFile.fileName, edits, true); - //this.checkPostEditInvariants(); + // this.checkPostEditInletiants(); } } } @@ -1372,7 +1374,7 @@ module FourSlash { this.currentCaretPosition = offset; this.fixCaretPosition(); - this.checkPostEditInvariants(); + this.checkPostEditInletiants(); } public replace(start: number, length: number, text: string) { @@ -1380,29 +1382,29 @@ module FourSlash { this.languageServiceAdapterHost.editScript(this.activeFile.fileName, start, start + length, text); this.updateMarkersForEdit(this.activeFile.fileName, start, start + length, text); - this.checkPostEditInvariants(); + this.checkPostEditInletiants(); } public deleteCharBehindMarker(count = 1) { this.scenarioActions.push(''); - var offset = this.currentCaretPosition; - var ch = ""; - var checkCadence = (count >> 2) + 1 + let offset = this.currentCaretPosition; + let ch = ""; + let checkCadence = (count >> 2) + 1; - for (var i = 0; i < count; i++) { + for (let i = 0; i < count; i++) { offset--; // Make the edit this.languageServiceAdapterHost.editScript(this.activeFile.fileName, offset, offset + 1, ch); this.updateMarkersForEdit(this.activeFile.fileName, offset, offset + 1, ch); if (i % checkCadence === 0) { - this.checkPostEditInvariants(); + this.checkPostEditInletiants(); } // Handle post-keystroke formatting if (this.enableFormatting) { - var edits = this.languageService.getFormattingEditsAfterKeystroke(this.activeFile.fileName, offset, ch, this.formatCodeOptions); + let edits = this.languageService.getFormattingEditsAfterKeystroke(this.activeFile.fileName, offset, ch, this.formatCodeOptions); if (edits.length) { offset += this.applyEdits(this.activeFile.fileName, edits, true); } @@ -1413,7 +1415,7 @@ module FourSlash { this.currentCaretPosition = offset; this.fixCaretPosition(); - this.checkPostEditInvariants(); + this.checkPostEditInletiants(); } // Enters lines of text at the current caret position @@ -1431,13 +1433,13 @@ module FourSlash { // language service APIs to mimic Visual Studio's behavior // as much as possible private typeHighFidelity(text: string) { - var offset = this.currentCaretPosition; - var prevChar = ' '; - var checkCadence = (text.length >> 2) + 1; + let offset = this.currentCaretPosition; + let prevChar = ' '; + let checkCadence = (text.length >> 2) + 1; - for (var i = 0; i < text.length; i++) { + for (let i = 0; i < text.length; i++) { // Make the edit - var ch = text.charAt(i); + let ch = text.charAt(i); this.languageServiceAdapterHost.editScript(this.activeFile.fileName, offset, offset, ch); this.languageService.getBraceMatchingAtPosition(this.activeFile.fileName, offset); @@ -1453,17 +1455,17 @@ module FourSlash { } if (i % checkCadence === 0) { - this.checkPostEditInvariants(); + this.checkPostEditInletiants(); // this.languageService.getSyntacticDiagnostics(this.activeFile.fileName); // this.languageService.getSemanticDiagnostics(this.activeFile.fileName); } // Handle post-keystroke formatting if (this.enableFormatting) { - var edits = this.languageService.getFormattingEditsAfterKeystroke(this.activeFile.fileName, offset, ch, this.formatCodeOptions); + let edits = this.languageService.getFormattingEditsAfterKeystroke(this.activeFile.fileName, offset, ch, this.formatCodeOptions); if (edits.length) { offset += this.applyEdits(this.activeFile.fileName, edits, true); - // this.checkPostEditInvariants(); + // this.checkPostEditInletiants(); } } } @@ -1472,26 +1474,26 @@ module FourSlash { this.currentCaretPosition = offset; this.fixCaretPosition(); - this.checkPostEditInvariants(); + this.checkPostEditInletiants(); } // Enters text as if the user had pasted it public paste(text: string) { this.scenarioActions.push(''); - var start = this.currentCaretPosition; - var offset = this.currentCaretPosition; + let start = this.currentCaretPosition; + let offset = this.currentCaretPosition; this.languageServiceAdapterHost.editScript(this.activeFile.fileName, offset, offset, text); this.updateMarkersForEdit(this.activeFile.fileName, offset, offset, text); - this.checkPostEditInvariants(); + this.checkPostEditInletiants(); offset += text.length; // Handle formatting if (this.enableFormatting) { - var edits = this.languageService.getFormattingEditsForRange(this.activeFile.fileName, start, offset, this.formatCodeOptions); + let edits = this.languageService.getFormattingEditsForRange(this.activeFile.fileName, start, offset, this.formatCodeOptions); if (edits.length) { offset += this.applyEdits(this.activeFile.fileName, edits, true); - this.checkPostEditInvariants(); + this.checkPostEditInletiants(); } } @@ -1499,27 +1501,27 @@ module FourSlash { this.currentCaretPosition = offset; this.fixCaretPosition(); - this.checkPostEditInvariants(); + this.checkPostEditInletiants(); } - private checkPostEditInvariants() { - if (this.testType !== FourSlashTestType.Native) { - // getSourcefile() results can not be serialized. Only perform these verifications + private checkPostEditInletiants() { + if (this.testType !== FourSlashTestType.Native) { + // getSourcefile() results can not be serialized. Only perform these verifications // if running against a native LS object. return; } - var incrementalSourceFile = this.languageService.getSourceFile(this.activeFile.fileName); + let incrementalSourceFile = this.languageService.getSourceFile(this.activeFile.fileName); Utils.assertInvariants(incrementalSourceFile, /*parent:*/ undefined); - var incrementalSyntaxDiagnostics = incrementalSourceFile.parseDiagnostics; + let incrementalSyntaxDiagnostics = incrementalSourceFile.parseDiagnostics; // Check syntactic structure - var content = this.getFileContent(this.activeFile.fileName); + let content = this.getFileContent(this.activeFile.fileName); - var referenceSourceFile = ts.createLanguageServiceSourceFile( + let referenceSourceFile = ts.createLanguageServiceSourceFile( this.activeFile.fileName, createScriptSnapShot(content), ts.ScriptTarget.Latest, /*version:*/ "0", /*setNodeParents:*/ false); - var referenceSyntaxDiagnostics = referenceSourceFile.parseDiagnostics; + let referenceSyntaxDiagnostics = referenceSourceFile.parseDiagnostics; Utils.assertDiagnosticsEquals(incrementalSyntaxDiagnostics, referenceSyntaxDiagnostics); Utils.assertStructuralEquals(incrementalSourceFile, referenceSourceFile); @@ -1529,7 +1531,7 @@ module FourSlash { // The caret can potentially end up between the \r and \n, which is confusing. If // that happens, move it back one character if (this.currentCaretPosition > 0) { - var ch = this.getFileContent(this.activeFile.fileName).substring(this.currentCaretPosition - 1, this.currentCaretPosition); + let ch = this.getFileContent(this.activeFile.fileName).substring(this.currentCaretPosition - 1, this.currentCaretPosition); if (ch === '\r') { this.currentCaretPosition--; } @@ -1539,21 +1541,21 @@ module FourSlash { private applyEdits(fileName: string, edits: ts.TextChange[], isFormattingEdit = false): number { // We get back a set of edits, but langSvc.editScript only accepts one at a time. Use this to keep track // of the incremental offset from each edit to the next. Assumption is that these edit ranges don't overlap - var runningOffset = 0; + let runningOffset = 0; edits = edits.sort((a, b) => a.span.start - b.span.start); // Get a snapshot of the content of the file so we can make sure any formatting edits didn't destroy non-whitespace characters - var oldContent = this.getFileContent(this.activeFile.fileName); - for (var j = 0; j < edits.length; j++) { + let oldContent = this.getFileContent(this.activeFile.fileName); + for (let j = 0; j < edits.length; j++) { this.languageServiceAdapterHost.editScript(fileName, edits[j].span.start + runningOffset, ts.textSpanEnd(edits[j].span) + runningOffset, edits[j].newText); this.updateMarkersForEdit(fileName, edits[j].span.start + runningOffset, ts.textSpanEnd(edits[j].span) + runningOffset, edits[j].newText); - var change = (edits[j].span.start - ts.textSpanEnd(edits[j].span)) + edits[j].newText.length; + let change = (edits[j].span.start - ts.textSpanEnd(edits[j].span)) + edits[j].newText.length; runningOffset += change; // TODO: Consider doing this at least some of the time for higher fidelity. Currently causes a failure (bug 707150) // this.languageService.getScriptLexicalStructure(fileName); } if (isFormattingEdit) { - var newContent = this.getFileContent(fileName); + let newContent = this.getFileContent(fileName); if (newContent.replace(/\s/g, '') !== oldContent.replace(/\s/g, '')) { this.raiseError('Formatting operation destroyed non-whitespace content'); @@ -1567,7 +1569,7 @@ module FourSlash { } public setFormatOptions(formatCodeOptions: ts.FormatCodeOptions): ts.FormatCodeOptions { - var oldFormatCodeOptions = this.formatCodeOptions; + let oldFormatCodeOptions = this.formatCodeOptions; this.formatCodeOptions = formatCodeOptions; return oldFormatCodeOptions; } @@ -1575,7 +1577,7 @@ module FourSlash { public formatDocument() { this.scenarioActions.push(''); - var edits = this.languageService.getFormattingEditsForDocument(this.activeFile.fileName, this.formatCodeOptions); + let edits = this.languageService.getFormattingEditsForDocument(this.activeFile.fileName, this.formatCodeOptions); this.currentCaretPosition += this.applyEdits(this.activeFile.fileName, edits, true); this.fixCaretPosition(); } @@ -1583,14 +1585,14 @@ module FourSlash { public formatSelection(start: number, end: number) { this.taoInvalidReason = 'formatSelection NYI'; - var edits = this.languageService.getFormattingEditsForRange(this.activeFile.fileName, start, end, this.formatCodeOptions); + let edits = this.languageService.getFormattingEditsForRange(this.activeFile.fileName, start, end, this.formatCodeOptions); this.currentCaretPosition += this.applyEdits(this.activeFile.fileName, edits, true); this.fixCaretPosition(); } private updateMarkersForEdit(fileName: string, minChar: number, limChar: number, text: string) { - for (var i = 0; i < this.testData.markers.length; i++) { - var marker = this.testData.markers[i]; + for (let i = 0; i < this.testData.markers.length; i++) { + let marker = this.testData.markers[i]; if (marker.fileName === fileName) { if (marker.position > minChar) { if (marker.position < limChar) { @@ -1610,7 +1612,7 @@ module FourSlash { } public goToEOF() { - var len = this.getFileContent(this.activeFile.fileName).length; + let len = this.getFileContent(this.activeFile.fileName).length; this.goToPosition(len); } @@ -1621,7 +1623,7 @@ module FourSlash { this.taoInvalidReason = 'GoToDefinition not supported for non-zero definition indices'; } - var definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); + let definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); if (!definitions || !definitions.length) { this.raiseError('goToDefinition failed - expected to at least one definition location but got 0'); } @@ -1630,7 +1632,7 @@ module FourSlash { this.raiseError('goToDefinition failed - definitionIndex value (' + definitionIndex + ') exceeds definition list size (' + definitions.length + ')'); } - var definition = definitions[definitionIndex]; + let definition = definitions[definitionIndex]; this.openFile(definition.fileName); this.currentCaretPosition = definition.textSpan.start; } @@ -1643,7 +1645,7 @@ module FourSlash { this.taoInvalidReason = 'GoToTypeDefinition not supported for non-zero definition indices'; } - var definitions = this.languageService.getTypeDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); + let definitions = this.languageService.getTypeDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); if (!definitions || !definitions.length) { this.raiseError('goToTypeDefinition failed - expected to at least one definition location but got 0'); } @@ -1652,7 +1654,7 @@ module FourSlash { this.raiseError('goToTypeDefinition failed - definitionIndex value (' + definitionIndex + ') exceeds definition list size (' + definitions.length + ')'); } - var definition = definitions[definitionIndex]; + let definition = definitions[definitionIndex]; this.openFile(definition.fileName); this.currentCaretPosition = definition.textSpan.start; } @@ -1660,9 +1662,9 @@ module FourSlash { public verifyDefinitionLocationExists(negative: boolean) { this.taoInvalidReason = 'verifyDefinitionLocationExists NYI'; - var definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); + let definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); - var foundDefinitions = definitions && definitions.length; + let foundDefinitions = definitions && definitions.length; if (foundDefinitions && negative) { this.raiseError('goToDefinition - expected to 0 definition locations but got ' + definitions.length); @@ -1673,19 +1675,19 @@ module FourSlash { } public verifyDefinitionsCount(negative: boolean, expectedCount: number) { - var assertFn = negative ? assert.notEqual : assert.equal; + let assertFn = negative ? assert.notEqual : assert.equal; - var definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); - var actualCount = definitions && definitions.length || 0; + let definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); + let actualCount = definitions && definitions.length || 0; assertFn(actualCount, expectedCount, this.messageAtLastKnownMarker("Definitions Count")); } public verifyTypeDefinitionsCount(negative: boolean, expectedCount: number) { - var assertFn = negative ? assert.notEqual : assert.equal; + let assertFn = negative ? assert.notEqual : assert.equal; - var definitions = this.languageService.getTypeDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); - var actualCount = definitions && definitions.length || 0; + let definitions = this.languageService.getTypeDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); + let actualCount = definitions && definitions.length || 0; assertFn(actualCount, expectedCount, this.messageAtLastKnownMarker("Type definitions Count")); } @@ -1693,9 +1695,9 @@ module FourSlash { public verifyDefinitionsName(negative: boolean, expectedName: string, expectedContainerName: string) { this.taoInvalidReason = 'verifyDefinititionsInfo NYI'; - var definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); - var actualDefinitionName = definitions && definitions.length ? definitions[0].name : ""; - var actualDefinitionContainerName = definitions && definitions.length ? definitions[0].containerName : ""; + let definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); + let actualDefinitionName = definitions && definitions.length ? definitions[0].name : ""; + let actualDefinitionContainerName = definitions && definitions.length ? definitions[0].containerName : ""; if (negative) { assert.notEqual(actualDefinitionName, expectedName, this.messageAtLastKnownMarker("Definition Info Name")); assert.notEqual(actualDefinitionContainerName, expectedContainerName, this.messageAtLastKnownMarker("Definition Info Container Name")); @@ -1718,7 +1720,7 @@ module FourSlash { public verifyCaretAtMarker(markerName = '') { this.taoInvalidReason = 'verifyCaretAtMarker NYI'; - var pos = this.getMarkerByName(markerName); + let pos = this.getMarkerByName(markerName); if (pos.fileName !== this.activeFile.fileName) { throw new Error('verifyCaretAtMarker failed - expected to be in file "' + pos.fileName + '", but was in file "' + this.activeFile.fileName + '"'); } @@ -1734,8 +1736,8 @@ module FourSlash { public verifyIndentationAtCurrentPosition(numberOfSpaces: number) { this.taoInvalidReason = 'verifyIndentationAtCurrentPosition NYI'; - var actual = this.getIndentation(this.activeFile.fileName, this.currentCaretPosition); - var lineCol = this.getLineColStringAtPosition(this.currentCaretPosition); + let actual = this.getIndentation(this.activeFile.fileName, this.currentCaretPosition); + let lineCol = this.getLineColStringAtPosition(this.currentCaretPosition); if (actual !== numberOfSpaces) { this.raiseError('verifyIndentationAtCurrentPosition failed at ' + lineCol + ' - expected: ' + numberOfSpaces + ', actual: ' + actual); } @@ -1744,8 +1746,8 @@ module FourSlash { public verifyIndentationAtPosition(fileName: string, position: number, numberOfSpaces: number) { this.taoInvalidReason = 'verifyIndentationAtPosition NYI'; - var actual = this.getIndentation(fileName, position); - var lineCol = this.getLineColStringAtPosition(position); + let actual = this.getIndentation(fileName, position); + let lineCol = this.getLineColStringAtPosition(position); if (actual !== numberOfSpaces) { this.raiseError('verifyIndentationAtPosition failed at ' + lineCol + ' - expected: ' + numberOfSpaces + ', actual: ' + actual); } @@ -1754,7 +1756,7 @@ module FourSlash { public verifyCurrentLineContent(text: string) { this.taoInvalidReason = 'verifyCurrentLineContent NYI'; - var actual = this.getCurrentLineContent(); + let actual = this.getCurrentLineContent(); if (actual !== text) { throw new Error('verifyCurrentLineContent\n' + '\tExpected: "' + text + '"\n' + @@ -1765,8 +1767,8 @@ module FourSlash { public verifyCurrentFileContent(text: string) { this.taoInvalidReason = 'verifyCurrentFileContent NYI'; - var actual = this.getFileContent(this.activeFile.fileName); - var replaceNewlines = (str: string) => str.replace(/\r\n/g, "\n"); + let actual = this.getFileContent(this.activeFile.fileName); + let replaceNewlines = (str: string) => str.replace(/\r\n/g, "\n"); if (replaceNewlines(actual) !== replaceNewlines(text)) { throw new Error('verifyCurrentFileContent\n' + '\tExpected: "' + text + '"\n' + @@ -1777,7 +1779,7 @@ module FourSlash { public verifyTextAtCaretIs(text: string) { this.taoInvalidReason = 'verifyCurrentFileContent NYI'; - var actual = this.getFileContent(this.activeFile.fileName).substring(this.currentCaretPosition, this.currentCaretPosition + text.length); + let actual = this.getFileContent(this.activeFile.fileName).substring(this.currentCaretPosition, this.currentCaretPosition + text.length); if (actual !== text) { throw new Error('verifyTextAtCaretIs\n' + '\tExpected: "' + text + '"\n' + @@ -1788,14 +1790,14 @@ module FourSlash { public verifyCurrentNameOrDottedNameSpanText(text: string) { this.taoInvalidReason = 'verifyCurrentNameOrDottedNameSpanText NYI'; - var span = this.languageService.getNameOrDottedNameSpan(this.activeFile.fileName, this.currentCaretPosition, this.currentCaretPosition); + let span = this.languageService.getNameOrDottedNameSpan(this.activeFile.fileName, this.currentCaretPosition, this.currentCaretPosition); if (!span) { this.raiseError('verifyCurrentNameOrDottedNameSpanText\n' + '\tExpected: "' + text + '"\n' + '\t Actual: undefined'); } - var actual = this.getFileContent(this.activeFile.fileName).substring(span.start, ts.textSpanEnd(span)); + let actual = this.getFileContent(this.activeFile.fileName).substring(span.start, ts.textSpanEnd(span)); if (actual !== text) { this.raiseError('verifyCurrentNameOrDottedNameSpanText\n' + '\tExpected: "' + text + '"\n' + @@ -1832,11 +1834,11 @@ module FourSlash { jsonMismatchString()); } - for (var i = 0; i < expected.length; i++) { - var expectedClassification = expected[i]; - var actualClassification = actual[i]; + for (let i = 0; i < expected.length; i++) { + let expectedClassification = expected[i]; + let actualClassification = actual[i]; - var expectedType: string = (ts.ClassificationTypeNames)[expectedClassification.classificationType]; + let expectedType: string = (ts.ClassificationTypeNames)[expectedClassification.classificationType]; if (expectedType !== actualClassification.classificationType) { this.raiseError('verifyClassifications failed - expected classifications type to be ' + expectedType + ', but was ' + @@ -1844,11 +1846,11 @@ module FourSlash { jsonMismatchString()); } - var expectedSpan = expectedClassification.textSpan; - var actualSpan = actualClassification.textSpan; + let expectedSpan = expectedClassification.textSpan; + let actualSpan = actualClassification.textSpan; if (expectedSpan) { - var expectedLength = expectedSpan.end - expectedSpan.start; + let expectedLength = expectedSpan.end - expectedSpan.start; if (expectedSpan.start !== actualSpan.start || expectedLength !== actualSpan.length) { this.raiseError("verifyClassifications failed - expected span of text to be " + @@ -1858,7 +1860,7 @@ module FourSlash { } } - var actualText = this.activeFile.content.substr(actualSpan.start, actualSpan.length); + let actualText = this.activeFile.content.substr(actualSpan.start, actualSpan.length); if (expectedClassification.text !== actualText) { this.raiseError('verifyClassifications failed - expected classified text to be ' + expectedClassification.text + ', but was ' + @@ -1883,21 +1885,21 @@ module FourSlash { assert.equal( expected.join(","), actual.fileNameList.map( file => { - return file.replace(this.basePath + "/", "") + return file.replace(this.basePath + "/", ""); }).join(",") ); } } public verifySemanticClassifications(expected: { classificationType: string; text: string }[]) { - var actual = this.languageService.getSemanticClassifications(this.activeFile.fileName, + let actual = this.languageService.getSemanticClassifications(this.activeFile.fileName, ts.createTextSpan(0, this.activeFile.content.length)); this.verifyClassifications(expected, actual); } public verifySyntacticClassifications(expected: { classificationType: string; text: string }[]) { - var actual = this.languageService.getSyntacticClassifications(this.activeFile.fileName, + let actual = this.languageService.getSyntacticClassifications(this.activeFile.fileName, ts.createTextSpan(0, this.activeFile.content.length)); this.verifyClassifications(expected, actual); @@ -1906,15 +1908,15 @@ module FourSlash { public verifyOutliningSpans(spans: TextSpan[]) { this.taoInvalidReason = 'verifyOutliningSpans NYI'; - var actual = this.languageService.getOutliningSpans(this.activeFile.fileName); + let actual = this.languageService.getOutliningSpans(this.activeFile.fileName); if (actual.length !== spans.length) { this.raiseError('verifyOutliningSpans failed - expected total spans to be ' + spans.length + ', but was ' + actual.length); } - for (var i = 0; i < spans.length; i++) { - var expectedSpan = spans[i]; - var actualSpan = actual[i]; + for (let i = 0; i < spans.length; i++) { + let expectedSpan = spans[i]; + let actualSpan = actual[i]; if (expectedSpan.start !== actualSpan.textSpan.start || expectedSpan.end !== ts.textSpanEnd(actualSpan.textSpan)) { this.raiseError('verifyOutliningSpans failed - span ' + (i + 1) + ' expected: (' + expectedSpan.start + ',' + expectedSpan.end + '), actual: (' + actualSpan.textSpan.start + ',' + ts.textSpanEnd(actualSpan.textSpan) + ')'); } @@ -1922,17 +1924,17 @@ module FourSlash { } public verifyTodoComments(descriptors: string[], spans: TextSpan[]) { - var actual = this.languageService.getTodoComments(this.activeFile.fileName, + let actual = this.languageService.getTodoComments(this.activeFile.fileName, descriptors.map(d => { return { text: d, priority: 0 }; })); if (actual.length !== spans.length) { this.raiseError('verifyTodoComments failed - expected total spans to be ' + spans.length + ', but was ' + actual.length); } - for (var i = 0; i < spans.length; i++) { - var expectedSpan = spans[i]; - var actualComment = actual[i]; - var actualCommentSpan = ts.createTextSpan(actualComment.position, actualComment.message.length); + for (let i = 0; i < spans.length; i++) { + let expectedSpan = spans[i]; + let actualComment = actual[i]; + let actualCommentSpan = ts.createTextSpan(actualComment.position, actualComment.message.length); if (expectedSpan.start !== actualCommentSpan.start || expectedSpan.end !== ts.textSpanEnd(actualCommentSpan)) { this.raiseError('verifyOutliningSpans failed - span ' + (i + 1) + ' expected: (' + expectedSpan.start + ',' + expectedSpan.end + '), actual: (' + actualCommentSpan.start + ',' + ts.textSpanEnd(actualCommentSpan) + ')'); @@ -1943,13 +1945,13 @@ module FourSlash { public verifyMatchingBracePosition(bracePosition: number, expectedMatchPosition: number) { this.taoInvalidReason = 'verifyMatchingBracePosition NYI'; - var actual = this.languageService.getBraceMatchingAtPosition(this.activeFile.fileName, bracePosition); + let actual = this.languageService.getBraceMatchingAtPosition(this.activeFile.fileName, bracePosition); if (actual.length !== 2) { this.raiseError('verifyMatchingBracePosition failed - expected result to contain 2 spans, but it had ' + actual.length); } - var actualMatchPosition = -1; + let actualMatchPosition = -1; if (bracePosition === actual[0].start) { actualMatchPosition = actual[1].start; } else if (bracePosition === actual[1].start) { @@ -1966,7 +1968,7 @@ module FourSlash { public verifyNoMatchingBracePosition(bracePosition: number) { this.taoInvalidReason = 'verifyNoMatchingBracePosition NYI'; - var actual = this.languageService.getBraceMatchingAtPosition(this.activeFile.fileName, bracePosition); + let actual = this.languageService.getBraceMatchingAtPosition(this.activeFile.fileName, bracePosition); if (actual.length !== 0) { this.raiseError('verifyNoMatchingBracePosition failed - expected: 0 spans, actual: ' + actual.length); @@ -1980,12 +1982,12 @@ module FourSlash { public verifyNavigationItemsCount(expected: number, searchValue: string, matchKind?: string) { this.taoInvalidReason = 'verifyNavigationItemsCount NYI'; - var items = this.languageService.getNavigateToItems(searchValue); - var actual = 0; - var item: ts.NavigateToItem = null; + let items = this.languageService.getNavigateToItems(searchValue); + let actual = 0; + let item: ts.NavigateToItem = null; // Count only the match that match the same MatchKind - for (var i = 0; i < items.length; ++i) { + for (let i = 0; i < items.length; ++i) { item = items[i]; if (!matchKind || item.matchKind === matchKind) { actual++; @@ -2010,14 +2012,14 @@ module FourSlash { parentName?: string) { this.taoInvalidReason = 'verifyNavigationItemsListContains NYI'; - var items = this.languageService.getNavigateToItems(searchValue); + let items = this.languageService.getNavigateToItems(searchValue); if (!items || items.length === 0) { this.raiseError('verifyNavigationItemsListContains failed - found 0 navigation items, expected at least one.'); } - for (var i = 0; i < items.length; i++) { - var item = items[i]; + for (let i = 0; i < items.length; i++) { + let item = items[i]; if (item && item.name === name && item.kind === kind && (matchKind === undefined || item.matchKind === matchKind) && (fileName === undefined || item.fileName === fileName) && @@ -2028,7 +2030,7 @@ module FourSlash { // if there was an explicit match kind specified, then it should be validated. if (matchKind !== undefined) { - var missingItem = { name: name, kind: kind, searchValue: searchValue, matchKind: matchKind, fileName: fileName, parentName: parentName }; + let missingItem = { name: name, kind: kind, searchValue: searchValue, matchKind: matchKind, fileName: fileName, parentName: parentName }; this.raiseError('verifyNavigationItemsListContains failed - could not find the item: ' + JSON.stringify(missingItem) + ' in the returned list: (' + JSON.stringify(items) + ')'); } } @@ -2036,8 +2038,8 @@ module FourSlash { public verifyGetScriptLexicalStructureListCount(expected: number) { this.taoInvalidReason = 'verifyNavigationItemsListContains impossible'; - var items = this.languageService.getNavigationBarItems(this.activeFile.fileName); - var actual = this.getNavigationBarItemsCount(items); + let items = this.languageService.getNavigationBarItems(this.activeFile.fileName); + let actual = this.getNavigationBarItemsCount(items); if (expected !== actual) { this.raiseError('verifyGetScriptLexicalStructureListCount failed - found: ' + actual + ' navigation items, expected: ' + expected + '.'); @@ -2045,9 +2047,9 @@ module FourSlash { } private getNavigationBarItemsCount(items: ts.NavigationBarItem[]) { - var result = 0; + let result = 0; if (items) { - for (var i = 0, n = items.length; i < n; i++) { + for (let i = 0, n = items.length; i < n; i++) { result++; result += this.getNavigationBarItemsCount(items[i].childItems); } @@ -2062,7 +2064,7 @@ module FourSlash { markerPosition?: number) { this.taoInvalidReason = 'verifGetScriptLexicalStructureListContains impossible'; - var items = this.languageService.getNavigationBarItems(this.activeFile.fileName); + let items = this.languageService.getNavigationBarItems(this.activeFile.fileName); if (!items || items.length === 0) { this.raiseError('verifyGetScriptLexicalStructureListContains failed - found 0 navigation items, expected at least one.'); @@ -2072,14 +2074,14 @@ module FourSlash { return; } - var missingItem = { name: name, kind: kind }; + let missingItem = { name: name, kind: kind }; this.raiseError('verifyGetScriptLexicalStructureListContains failed - could not find the item: ' + JSON.stringify(missingItem) + ' in the returned list: (' + JSON.stringify(items, null, " ") + ')'); } private navigationBarItemsContains(items: ts.NavigationBarItem[], name: string, kind: string) { if (items) { - for (var i = 0; i < items.length; i++) { - var item = items[i]; + for (let i = 0; i < items.length; i++) { + let item = items[i]; if (item && item.text === name && item.kind === kind) { return true; } @@ -2094,25 +2096,25 @@ module FourSlash { } public printNavigationItems(searchValue: string) { - var items = this.languageService.getNavigateToItems(searchValue); - var length = items && items.length; + let items = this.languageService.getNavigateToItems(searchValue); + let length = items && items.length; Harness.IO.log('NavigationItems list (' + length + ' items)'); - for (var i = 0; i < length; i++) { - var item = items[i]; + for (let i = 0; i < length; i++) { + let item = items[i]; Harness.IO.log('name: ' + item.name + ', kind: ' + item.kind + ', parentName: ' + item.containerName + ', fileName: ' + item.fileName); } } public printScriptLexicalStructureItems() { - var items = this.languageService.getNavigationBarItems(this.activeFile.fileName); - var length = items && items.length; + let items = this.languageService.getNavigationBarItems(this.activeFile.fileName); + let length = items && items.length; Harness.IO.log('NavigationItems list (' + length + ' items)'); - for (var i = 0; i < length; i++) { - var item = items[i]; + for (let i = 0; i < length; i++) { + let item = items[i]; Harness.IO.log('name: ' + item.text + ', kind: ' + item.kind); } } @@ -2124,14 +2126,14 @@ module FourSlash { public verifyOccurrencesAtPositionListContains(fileName: string, start: number, end: number, isWriteAccess?: boolean) { this.taoInvalidReason = 'verifyOccurrencesAtPositionListContains NYI'; - var occurances = this.getOccurancesAtCurrentPosition(); + let occurances = this.getOccurancesAtCurrentPosition(); if (!occurances || occurances.length === 0) { this.raiseError('verifyOccurancesAtPositionListContains failed - found 0 references, expected at least one.'); } - for (var i = 0; i < occurances.length; i++) { - var occurance = occurances[i]; + for (let i = 0; i < occurances.length; i++) { + let occurance = occurances[i]; if (occurance && occurance.fileName === fileName && occurance.textSpan.start === start && ts.textSpanEnd(occurance.textSpan) === end) { if (typeof isWriteAccess !== "undefined" && occurance.isWriteAccess !== isWriteAccess) { this.raiseError('verifyOccurancesAtPositionListContains failed - item isWriteAccess value doe not match, actual: ' + occurance.isWriteAccess + ', expected: ' + isWriteAccess + '.'); @@ -2140,15 +2142,15 @@ module FourSlash { } } - var missingItem = { fileName: fileName, start: start, end: end, isWriteAccess: isWriteAccess }; + let missingItem = { fileName: fileName, start: start, end: end, isWriteAccess: isWriteAccess }; this.raiseError('verifyOccurancesAtPositionListContains failed - could not find the item: ' + JSON.stringify(missingItem) + ' in the returned list: (' + JSON.stringify(occurances) + ')'); } public verifyOccurrencesAtPositionListCount(expectedCount: number) { this.taoInvalidReason = 'verifyOccurrencesAtPositionListCount NYI'; - var occurances = this.getOccurancesAtCurrentPosition(); - var actualCount = occurances ? occurances.length : 0; + let occurances = this.getOccurancesAtCurrentPosition(); + let actualCount = occurances ? occurances.length : 0; if (expectedCount !== actualCount) { this.raiseError('verifyOccurrencesAtPositionListCount failed - actual: ' + actualCount + ', expected:' + expectedCount); } @@ -2156,13 +2158,13 @@ module FourSlash { // Get the text of the entire line the caret is currently at private getCurrentLineContent() { - var text = this.getFileContent(this.activeFile.fileName) + let text = this.getFileContent(this.activeFile.fileName); - var pos = this.currentCaretPosition; - var startPos = pos, endPos = pos; + let pos = this.currentCaretPosition; + let startPos = pos, endPos = pos; while (startPos > 0) { - var ch = text.charCodeAt(startPos - 1); + let ch = text.charCodeAt(startPos - 1); if (ch === ts.CharacterCodes.carriageReturn || ch === ts.CharacterCodes.lineFeed) { break; } @@ -2171,7 +2173,7 @@ module FourSlash { } while (endPos < text.length) { - var ch = text.charCodeAt(endPos); + let ch = text.charCodeAt(endPos); if (ch === ts.CharacterCodes.carriageReturn || ch === ts.CharacterCodes.lineFeed) { break; @@ -2191,11 +2193,11 @@ module FourSlash { this.taoInvalidReason = 'assertItemInCompletionList only supports the "name" parameter'; } - for (var i = 0; i < items.length; i++) { - var item = items[i]; + for (let i = 0; i < items.length; i++) { + let item = items[i]; if (item.name === name) { if (documentation != undefined || text !== undefined) { - var details = this.getCompletionEntryDetails(item.name); + let details = this.getCompletionEntryDetails(item.name); if (documentation !== undefined) { assert.equal(ts.displayPartsToString(details.documentation), documentation, assertionMessage("completion item documentation")); @@ -2213,30 +2215,30 @@ module FourSlash { } } - var itemsString = items.map((item) => JSON.stringify({ name: item.name, kind: item.kind })).join(",\n"); + let itemsString = items.map((item) => JSON.stringify({ name: item.name, kind: item.kind })).join(",\n"); this.raiseError('Expected "' + JSON.stringify({ name, text, documentation, kind }) + '" to be in list [' + itemsString + ']'); } private findFile(indexOrName: any) { - var result: FourSlashFile = null; + let result: FourSlashFile = null; if (typeof indexOrName === 'number') { - var index = indexOrName; + let index = indexOrName; if (index >= this.testData.files.length) { throw new Error('File index (' + index + ') in openFile was out of range. There are only ' + this.testData.files.length + ' files in this test.'); } else { result = this.testData.files[index]; } } else if (typeof indexOrName === 'string') { - var name = indexOrName; + let name = indexOrName; // names are stored in the compiler with this relative path, this allows people to use goTo.file on just the fileName name = name.indexOf('/') === -1 ? (this.basePath + '/' + name) : name; - var availableNames: string[] = []; - var foundIt = false; - for (var i = 0; i < this.testData.files.length; i++) { - var fn = this.testData.files[i].fileName; + let availableNames: string[] = []; + let foundIt = false; + for (let i = 0; i < this.testData.files.length; i++) { + let fn = this.testData.files[i].fileName; if (fn) { if (fn === name) { result = this.testData.files[i]; @@ -2258,15 +2260,15 @@ module FourSlash { } private getLineColStringAtPosition(position: number) { - var pos = this.languageServiceAdapterHost.positionToLineAndCharacter(this.activeFile.fileName, position); + let pos = this.languageServiceAdapterHost.positionToLineAndCharacter(this.activeFile.fileName, position); return 'line ' + (pos.line + 1) + ', col ' + pos.character; } private getMarkerByName(markerName: string) { - var markerPos = this.testData.markerPositions[markerName]; + let markerPos = this.testData.markerPositions[markerName]; if (markerPos === undefined) { - var markerNames: string[] = []; - for (var m in this.testData.markerPositions) markerNames.push(m); + let markerNames: string[] = []; + for (let m in this.testData.markerPositions) markerNames.push(m); throw new Error('Unknown marker "' + markerName + '" Available markers: ' + markerNames.map(m => '"' + m + '"').join(', ')); } else { return markerPos; @@ -2286,7 +2288,7 @@ module FourSlash { } public setCancelled(numberOfCalls: number): void { - this.cancellationToken.setCancelled(numberOfCalls) + this.cancellationToken.setCancelled(numberOfCalls); } public resetCancelled(): void { @@ -2295,12 +2297,12 @@ module FourSlash { } // TOOD: should these just use the Harness's stdout/stderr? - var fsOutput = new Harness.Compiler.WriterAggregator(); - var fsErrors = new Harness.Compiler.WriterAggregator(); - export var xmlData: TestXmlData[] = []; + let fsOutput = new Harness.Compiler.WriterAggregator(); + let fsErrors = new Harness.Compiler.WriterAggregator(); + export let xmlData: TestXmlData[] = []; export function runFourSlashTest(basePath: string, testType: FourSlashTestType, fileName: string) { - var content = Harness.IO.readFile(fileName); - var xml = runFourSlashTestContent(basePath, testType, content, fileName); + let content = Harness.IO.readFile(fileName); + let xml = runFourSlashTestContent(basePath, testType, content, fileName); xmlData.push(xml); } @@ -2365,8 +2367,8 @@ module FourSlash { } function chompLeadingSpace(content: string) { - var lines = content.split("\n"); - for (var i = 0; i < lines.length; i++) { + let lines = content.split("\n"); + for (let i = 0; i < lines.length; i++) { if ((lines[i].length !== 0) && (lines[i].charAt(0) !== ' ')) { return content; } @@ -2377,31 +2379,31 @@ module FourSlash { function parseTestData(basePath: string, contents: string, fileName: string): FourSlashData { // Regex for parsing options in the format "@Alpha: Value of any sort" - var optionRegex = /^\s*@(\w+): (.*)\s*/; + let optionRegex = /^\s*@(\w+): (.*)\s*/; // List of all the subfiles we've parsed out - var files: FourSlashFile[] = []; + let files: FourSlashFile[] = []; // Global options - var globalOptions: { [s: string]: string; } = {}; + let globalOptions: { [s: string]: string; } = {}; // Marker positions // Split up the input file by line // Note: IE JS engine incorrectly handles consecutive delimiters here when using RegExp split, so // we have to string-based splitting instead and try to figure out the delimiting chars - var lines = contents.split('\n'); + let lines = contents.split('\n'); - var markerPositions: MarkerMap = {}; - var markers: Marker[] = []; - var ranges: Range[] = []; + let markerPositions: MarkerMap = {}; + let markers: Marker[] = []; + let ranges: Range[] = []; // Stuff related to the subfile we're parsing - var currentFileContent: string = null; - var currentFileName = fileName; - var currentFileOptions: { [s: string]: string } = {}; + let currentFileContent: string = null; + let currentFileName = fileName; + let currentFileOptions: { [s: string]: string } = {}; - for (var i = 0; i < lines.length; i++) { - var line = lines[i]; - var lineLength = line.length; + for (let i = 0; i < lines.length; i++) { + let line = lines[i]; + let lineLength = line.length; if (lineLength > 0 && line.charAt(lineLength - 1) === '\r') { line = line.substr(0, lineLength - 1); @@ -2421,17 +2423,17 @@ module FourSlash { currentFileContent = currentFileContent + line.substr(4); } else if (line.substr(0, 2) === '//') { // Comment line, check for global/file @options and record them - var match = optionRegex.exec(line.substr(2)); + let match = optionRegex.exec(line.substr(2)); if (match) { - var globalMetadataNamesIndex = globalMetadataNames.indexOf(match[1]); - var fileMetadataNamesIndex = fileMetadataNames.indexOf(match[1]); + let globalMetadataNamesIndex = globalMetadataNames.indexOf(match[1]); + let fileMetadataNamesIndex = fileMetadataNames.indexOf(match[1]); if (globalMetadataNamesIndex === -1) { if (fileMetadataNamesIndex === -1) { throw new Error('Unrecognized metadata name "' + match[1] + '". Available global metadata names are: ' + globalMetadataNames.join(', ') + '; file metadata names are: ' + fileMetadataNames.join(', ')); } else if (fileMetadataNamesIndex === fileMetadataNames.indexOf(metadataOptionNames.fileName)) { // Found an @FileName directive, if this is not the first then create a new subfile if (currentFileContent) { - var file = parseFileContent(currentFileContent, currentFileName, markerPositions, markers, ranges); + let file = parseFileContent(currentFileContent, currentFileName, markerPositions, markers, ranges); file.fileOptions = currentFileOptions; // Store result file @@ -2464,7 +2466,7 @@ module FourSlash { } else { // Empty line or code line, terminate current subfile if there is one if (currentFileContent) { - var file = parseFileContent(currentFileContent, currentFileName, markerPositions, markers, ranges); + let file = parseFileContent(currentFileContent, currentFileName, markerPositions, markers, ranges); file.fileOptions = currentFileOptions; // Store result file @@ -2494,12 +2496,12 @@ module FourSlash { } function reportError(fileName: string, line: number, col: number, message: string) { - var errorMessage = fileName + "(" + line + "," + col + "): " + message; + let errorMessage = fileName + "(" + line + "," + col + "): " + message; throw new Error(errorMessage); } function recordObjectMarker(fileName: string, location: ILocationInformation, text: string, markerMap: MarkerMap, markers: Marker[]): Marker { - var markerValue: any = undefined; + let markerValue: any = undefined; try { // Attempt to parse the marker value as JSON markerValue = JSON.parse("{ " + text + " }"); @@ -2512,7 +2514,7 @@ module FourSlash { return null; } - var marker: Marker = { + let marker: Marker = { fileName: fileName, position: location.position, data: markerValue @@ -2529,14 +2531,14 @@ module FourSlash { } function recordMarker(fileName: string, location: ILocationInformation, name: string, markerMap: MarkerMap, markers: Marker[]): Marker { - var marker: Marker = { + let marker: Marker = { fileName: fileName, position: location.position }; // Verify markers for uniqueness if (markerMap[name] !== undefined) { - var message = "Marker '" + name + "' is duplicated in the source file contents."; + let message = "Marker '" + name + "' is duplicated in the source file contents."; reportError(marker.fileName, location.sourceLine, location.sourceColumn, message); return null; } else { @@ -2550,34 +2552,34 @@ module FourSlash { content = chompLeadingSpace(content); // Any slash-star comment with a character not in this string is not a marker. - var validMarkerChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz$1234567890_'; + let validMarkerChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz$1234567890_'; /// The file content (minus metacharacters) so far - var output: string = ""; + let output: string = ""; /// The current marker (or maybe multi-line comment?) we're parsing, possibly - var openMarker: ILocationInformation = null; + let openMarker: ILocationInformation = null; /// A stack of the open range markers that are still unclosed - var openRanges: IRangeLocationInformation[] = []; + let openRanges: IRangeLocationInformation[] = []; /// A list of ranges we've collected so far */ - var localRanges: Range[] = []; + let localRanges: Range[] = []; /// The latest position of the start of an unflushed plain text area - var lastNormalCharPosition: number = 0; + let lastNormalCharPosition: number = 0; /// The total number of metacharacters removed from the file (so far) - var difference: number = 0; + let difference: number = 0; /// The fourslash file state object we are generating - var state: State = State.none; + let state: State = State.none; /// Current position data - var line: number = 1; - var column: number = 1; + let line: number = 1; + let column: number = 1; - var flush = (lastSafeCharIndex: number) => { + let flush = (lastSafeCharIndex: number) => { if (lastSafeCharIndex === undefined) { output = output + content.substr(lastNormalCharPosition); } else { @@ -2586,9 +2588,9 @@ module FourSlash { }; if (content.length > 0) { - var previousChar = content.charAt(0); - for (var i = 1; i < content.length; i++) { - var currentChar = content.charAt(i); + let previousChar = content.charAt(0); + for (let i = 1; i < content.length; i++) { + let currentChar = content.charAt(i); switch (state) { case State.none: if (previousChar === "[" && currentChar === "|") { @@ -2605,12 +2607,12 @@ module FourSlash { difference += 2; } else if (previousChar === "|" && currentChar === "]") { // found a range end - var rangeStart = openRanges.pop(); + let rangeStart = openRanges.pop(); if (!rangeStart) { reportError(fileName, line, column, "Found range end with no matching start."); } - var range: Range = { + let range: Range = { fileName: fileName, start: rangeStart.position, end: (i - 1) - difference, @@ -2648,8 +2650,8 @@ module FourSlash { // Object markers are only ever terminated by |} and have no content restrictions if (previousChar === "|" && currentChar === "}") { // Record the marker - var objectMarkerNameText = content.substring(openMarker.sourcePosition + 2, i - 1).trim(); - var marker = recordObjectMarker(fileName, openMarker, objectMarkerNameText, markerMap, markers); + let objectMarkerNameText = content.substring(openMarker.sourcePosition + 2, i - 1).trim(); + let marker = recordObjectMarker(fileName, openMarker, objectMarkerNameText, markerMap, markers); if (openRanges.length > 0) { openRanges[openRanges.length - 1].marker = marker; @@ -2669,8 +2671,8 @@ module FourSlash { if (previousChar === "*" && currentChar === "/") { // Record the marker // start + 2 to ignore the */, -1 on the end to ignore the * (/ is next) - var markerNameText = content.substring(openMarker.sourcePosition + 2, i - 1).trim(); - var marker = recordMarker(fileName, openMarker, markerNameText, markerMap, markers); + let markerNameText = content.substring(openMarker.sourcePosition + 2, i - 1).trim(); + let marker = recordMarker(fileName, openMarker, markerNameText, markerMap, markers); if (openRanges.length > 0) { openRanges[openRanges.length - 1].marker = marker; @@ -2718,7 +2720,7 @@ module FourSlash { flush(undefined); if (openRanges.length > 0) { - var openRange = openRanges[0]; + let openRange = openRanges[0]; reportError(fileName, openRange.sourceLine, openRange.sourceColumn, "Unterminated range."); } diff --git a/src/harness/fourslashRunner.ts b/src/harness/fourslashRunner.ts index 0db01c30f32..05a11c4f52d 100644 --- a/src/harness/fourslashRunner.ts +++ b/src/harness/fourslashRunner.ts @@ -2,7 +2,7 @@ /// /// -const enum FourSlashTestType { +const enum FourSlashTestType { Native, Shims, Server @@ -35,70 +35,72 @@ class FourSlashRunner extends RunnerBase { this.tests = this.enumerateFiles(this.basePath, /\.ts/i, { recursive: false }); } - this.tests.forEach((fn: string) => { - describe(fn, () => { - fn = ts.normalizeSlashes(fn); - var justName = fn.replace(/^.*[\\\/]/, ''); + describe(this.testSuiteName + ' tests', () => { + this.tests.forEach((fn: string) => { + describe(fn, () => { + fn = ts.normalizeSlashes(fn); + let justName = fn.replace(/^.*[\\\/]/, ''); - // Convert to relative path - var testIndex = fn.indexOf('tests/'); - if (testIndex >= 0) fn = fn.substr(testIndex); + // Convert to relative path + let testIndex = fn.indexOf('tests/'); + if (testIndex >= 0) fn = fn.substr(testIndex); - if (justName && !justName.match(/fourslash\.ts$/i) && !justName.match(/\.d\.ts$/i)) { - it(this.testSuiteName + ' test ' + justName + ' runs correctly', () => { - FourSlash.runFourSlashTest(this.basePath, this.testType, fn); - }); - } + if (justName && !justName.match(/fourslash\.ts$/i) && !justName.match(/\.d\.ts$/i)) { + it(this.testSuiteName + ' test ' + justName + ' runs correctly', () => { + FourSlash.runFourSlashTest(this.basePath, this.testType, fn); + }); + } + }); }); - }); - describe('Generate Tao XML', () => { - var invalidReasons: any = {}; - FourSlash.xmlData.forEach(xml => { - if (xml.invalidReason !== null) { - invalidReasons[xml.invalidReason] = (invalidReasons[xml.invalidReason] || 0) + 1; + describe('Generate Tao XML', () => { + let invalidReasons: any = {}; + FourSlash.xmlData.forEach(xml => { + if (xml.invalidReason !== null) { + invalidReasons[xml.invalidReason] = (invalidReasons[xml.invalidReason] || 0) + 1; + } + }); + let invalidReport: { reason: string; count: number }[] = []; + for (let reason in invalidReasons) { + if (invalidReasons.hasOwnProperty(reason)) { + invalidReport.push({ reason: reason, count: invalidReasons[reason] }); + } } - }); - var invalidReport: { reason: string; count: number }[] = []; - for (var reason in invalidReasons) { - if (invalidReasons.hasOwnProperty(reason)) { - invalidReport.push({ reason: reason, count: invalidReasons[reason] }); - } - } - invalidReport.sort((lhs, rhs) => lhs.count > rhs.count ? -1 : lhs.count === rhs.count ? 0 : 1); + invalidReport.sort((lhs, rhs) => lhs.count > rhs.count ? -1 : lhs.count === rhs.count ? 0 : 1); - var lines: string[] = []; - lines.push(''); + lines.push(''); + lines.push(' '); + lines.push(' '); + lines.push(' '); + lines.push(' '); + FourSlash.xmlData.forEach(xml => { + if (xml.invalidReason !== null) { + lines.push(''); + } else { + lines.push(' '); + xml.actions.forEach(action => { + lines.push(' ' + action); + }); + lines.push(' '); + } + }); + lines.push(' '); + lines.push(' '); + lines.push(' '); + lines.push(' '); + lines.push(' '); + lines.push(' '); + lines.push(' '); + lines.push(' '); + lines.push(''); + Harness.IO.writeFile('built/local/fourslash.xml', lines.join('\r\n')); }); - lines.push('-->'); - lines.push(''); - lines.push(' '); - lines.push(' '); - lines.push(' '); - lines.push(' '); - FourSlash.xmlData.forEach(xml => { - if (xml.invalidReason !== null) { - lines.push(''); - } else { - lines.push(' '); - xml.actions.forEach(action => { - lines.push(' ' + action); - }); - lines.push(' '); - } - }); - lines.push(' '); - lines.push(' '); - lines.push(' '); - lines.push(' '); - lines.push(' '); - lines.push(' '); - lines.push(' '); - lines.push(' '); - lines.push(''); - Harness.IO.writeFile('built/local/fourslash.xml', lines.join('\r\n')); }); } } @@ -108,4 +110,4 @@ class GeneratedFourslashRunner extends FourSlashRunner { super(testType); this.basePath += '/generated/'; } -} \ No newline at end of file +} diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 9f26887ff90..17aa0dd325c 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -33,8 +33,6 @@ declare var __dirname: string; // Node-specific var global = Function("return this").call(null); module Utils { - var global = Function("return this").call(null); - // Setup some globals based on the current environment export const enum ExecutionEnvironment { Node, @@ -54,17 +52,17 @@ module Utils { } } - export var currentExecutionEnvironment = getExecutionEnvironment(); + export let currentExecutionEnvironment = getExecutionEnvironment(); export function evalFile(fileContents: string, fileName: string, nodeContext?: any) { - var environment = getExecutionEnvironment(); + let environment = getExecutionEnvironment(); switch (environment) { case ExecutionEnvironment.CScript: case ExecutionEnvironment.Browser: eval(fileContents); break; case ExecutionEnvironment.Node: - var vm = require('vm'); + let vm = require('vm'); if (nodeContext) { vm.runInNewContext(fileContents, nodeContext, fileName); } else { @@ -81,7 +79,7 @@ module Utils { // Split up the input file by line // Note: IE JS engine incorrectly handles consecutive delimiters here when using RegExp split, so // we have to use string-based splitting instead and try to figure out the delimiting chars - var lines = content.split('\r\n'); + let lines = content.split('\r\n'); if (lines.length === 1) { lines = content.split('\n'); @@ -98,8 +96,9 @@ module Utils { path = "tests/" + path; } + let content: string = undefined; try { - var content = ts.sys.readFile(Harness.userSpecifiedRoot + path); + content = ts.sys.readFile(Harness.userSpecifiedRoot + path); } catch (err) { return undefined; @@ -109,11 +108,11 @@ module Utils { } export function memoize(f: T): T { - var cache: { [idx: string]: any } = {}; + let cache: { [idx: string]: any } = {}; return (function () { - var key = Array.prototype.join.call(arguments); - var cachedResult = cache[key]; + let key = Array.prototype.join.call(arguments); + let cachedResult = cache[key]; if (cachedResult) { return cachedResult; } else { @@ -140,7 +139,7 @@ module Utils { }); // Make sure each of the children is in order. - var currentPos = 0; + let currentPos = 0; ts.forEachChild(node, child => { assert.isFalse(child.pos < currentPos, "child.pos < currentPos"); @@ -151,22 +150,22 @@ module Utils { assert.isFalse(array.end > node.end, "array.end > node.end"); assert.isFalse(array.pos < currentPos, "array.pos < currentPos"); - for (var i = 0, n = array.length; i < n; i++) { + for (let i = 0, n = array.length; i < n; i++) { assert.isFalse(array[i].pos < currentPos, "array[i].pos < currentPos"); - currentPos = array[i].end + currentPos = array[i].end; } currentPos = array.end; }); - var childNodesAndArrays: any[] = []; - ts.forEachChild(node, child => { childNodesAndArrays.push(child) }, array => { childNodesAndArrays.push(array) }); + let childNodesAndArrays: any[] = []; + ts.forEachChild(node, child => { childNodesAndArrays.push(child); }, array => { childNodesAndArrays.push(array); }); - for (var childName in node) { + for (let childName in node) { if (childName === "parent" || childName === "nextContainer" || childName === "modifiers" || childName === "externalModuleIndicator") { continue; } - var child = (node)[childName]; + let child = (node)[childName]; if (isNodeOrArray(child)) { assert.isFalse(childNodesAndArrays.indexOf(child) < 0, "Missing child when forEach'ing over node: " + (ts).SyntaxKind[node.kind] + "-" + childName); @@ -194,7 +193,7 @@ module Utils { } export function sourceFileToJSON(file: ts.Node): string { - return JSON.stringify(file,(k, v) => { + return JSON.stringify(file, (k, v) => { return isNodeOrArray(v) ? serializeNode(v) : v; }, " "); @@ -203,7 +202,7 @@ module Utils { return k; } - return (ts).SyntaxKind[k] + return (ts).SyntaxKind[k]; } function getFlagName(flags: any, f: number): any { @@ -211,7 +210,7 @@ module Utils { return 0; } - var result = ""; + let result = ""; ts.forEach(Object.getOwnPropertyNames(flags), (v: any) => { if (isFinite(v)) { v = +v; @@ -234,7 +233,7 @@ module Utils { function getParserContextFlagName(f: number) { return getFlagName((ts).ParserContextFlags, f); } function serializeNode(n: ts.Node): any { - var o: any = { kind: getKindName(n.kind) }; + let o: any = { kind: getKindName(n.kind) }; if (ts.containsParseError(n)) { o.containsParseError = true; } @@ -268,7 +267,7 @@ module Utils { // Clear the flag that are produced by aggregating child values.. That is ephemeral // data we don't care about in the dump. We only care what the parser set directly // on the ast. - var value = n.parserContextFlags & ts.ParserContextFlags.ParserGeneratedFlags; + let value = n.parserContextFlags & ts.ParserContextFlags.ParserGeneratedFlags; if (value) { o[propertyName] = getParserContextFlagName(value); } @@ -313,9 +312,9 @@ module Utils { assert.equal(array1.length, array2.length, "array1.length !== array2.length"); - for (var i = 0, n = array1.length; i < n; i++) { - var d1 = array1[i]; - var d2 = array2[i]; + for (let i = 0, n = array1.length; i < n; i++) { + let d1 = array1[i]; + let d2 = array2[i]; assert.equal(d1.start, d2.start, "d1.start !== d2.start"); assert.equal(d1.length, d2.length, "d1.length !== d2.length"); @@ -346,14 +345,14 @@ module Utils { ts.forEachChild(node1, child1 => { - var childName = findChildName(node1, child1); - var child2: ts.Node = (node2)[childName]; + let childName = findChildName(node1, child1); + let child2: ts.Node = (node2)[childName]; assertStructuralEquals(child1, child2); }, (array1: ts.NodeArray) => { - var childName = findChildName(node1, array1); - var array2: ts.NodeArray = (node2)[childName]; + let childName = findChildName(node1, array1); + let array2: ts.NodeArray = (node2)[childName]; assertArrayStructuralEquals(array1, array2); }); @@ -370,13 +369,13 @@ module Utils { assert.equal(array1.end, array2.end, "array1.end !== array2.end"); assert.equal(array1.length, array2.length, "array1.length !== array2.length"); - for (var i = 0, n = array1.length; i < n; i++) { + for (let i = 0, n = array1.length; i < n; i++) { assertStructuralEquals(array1[i], array2[i]); } } function findChildName(parent: any, child: any) { - for (var name in parent) { + for (let name in parent) { if (parent.hasOwnProperty(name) && parent[name] === child) { return name; } @@ -393,8 +392,8 @@ module Harness.Path { export function filePath(fullPath: string) { fullPath = ts.normalizeSlashes(fullPath); - var components = fullPath.split("/"); - var path: string[] = components.slice(0, components.length - 1); + let components = fullPath.split("/"); + let path: string[] = components.slice(0, components.length - 1); return path.join("/") + "/"; } } @@ -422,19 +421,19 @@ module Harness { } export module CScript { - var fso: any; + let fso: any; if (global.ActiveXObject) { fso = new global.ActiveXObject("Scripting.FileSystemObject"); } else { fso = {}; } - export var readFile: typeof IO.readFile = ts.sys.readFile; - export var writeFile: typeof IO.writeFile = ts.sys.writeFile; - export var directoryName: typeof IO.directoryName = fso.GetParentFolderName; - export var directoryExists: typeof IO.directoryExists = fso.FolderExists; - export var fileExists: typeof IO.fileExists = fso.FileExists; - export var log: typeof IO.log = global.WScript && global.WScript.StdOut.WriteLine; + export let readFile: typeof IO.readFile = ts.sys.readFile; + export let writeFile: typeof IO.writeFile = ts.sys.writeFile; + export let directoryName: typeof IO.directoryName = fso.GetParentFolderName; + export let directoryExists: typeof IO.directoryExists = fso.FolderExists; + export let fileExists: typeof IO.fileExists = fso.FileExists; + export let log: typeof IO.log = global.WScript && global.WScript.StdOut.WriteLine; export function createDirectory(path: string) { if (directoryExists(path)) { @@ -448,11 +447,11 @@ module Harness { } } - export var listFiles: typeof IO.listFiles = (path, spec?, options?) => { + export let listFiles: typeof IO.listFiles = (path, spec?, options?) => { options = options || <{ recursive?: boolean; }>{}; function filesInFolder(folder: any, root: string): string[] { - var paths: string[] = []; - var fc: any; + let paths: string[] = []; + let fc: any; if (options.recursive) { fc = new Enumerator(folder.subfolders); @@ -473,17 +472,16 @@ module Harness { return paths; } - var folder: any = fso.GetFolder(path); - var paths: string[] = []; + let folder: any = fso.GetFolder(path); + let paths: string[] = []; return filesInFolder(folder, path); - - } + }; } export module Node { - declare var require: any; - var fs: any, pathModule: any; + declare let require: any; + let fs: any, pathModule: any; if (require) { fs = require('fs'); pathModule = require('path'); @@ -491,10 +489,10 @@ module Harness { fs = pathModule = {}; } - export var readFile: typeof IO.readFile = ts.sys.readFile; - export var writeFile: typeof IO.writeFile = ts.sys.writeFile; - export var fileExists: typeof IO.fileExists = fs.existsSync; - export var log: typeof IO.log = console.log; + export let readFile: typeof IO.readFile = ts.sys.readFile; + export let writeFile: typeof IO.writeFile = ts.sys.writeFile; + export let fileExists: typeof IO.fileExists = fs.existsSync; + export let log: typeof IO.log = console.log; export function createDirectory(path: string) { if (!directoryExists(path)) { @@ -514,7 +512,7 @@ module Harness { } export function directoryName(path: string) { - var dirPath = pathModule.dirname(path); + let dirPath = pathModule.dirname(path); // Node will just continue to repeat the root path, rather than return null if (dirPath === path) { @@ -524,16 +522,16 @@ module Harness { } } - export var listFiles: typeof IO.listFiles = (path, spec?, options?) => { + export let listFiles: typeof IO.listFiles = (path, spec?, options?) => { options = options || <{ recursive?: boolean; }>{}; function filesInFolder(folder: string): string[] { - var paths: string[] = []; + let paths: string[] = []; - var files = fs.readdirSync(folder); - for (var i = 0; i < files.length; i++) { - var pathToFile = pathModule.join(folder, files[i]); - var stat = fs.statSync(pathToFile); + let files = fs.readdirSync(folder); + for (let i = 0; i < files.length; i++) { + let pathToFile = pathModule.join(folder, files[i]); + let stat = fs.statSync(pathToFile); if (options.recursive && stat.isDirectory()) { paths = paths.concat(filesInFolder(pathToFile)); } @@ -546,23 +544,23 @@ module Harness { } return filesInFolder(path); - } + }; - export var getMemoryUsage: typeof IO.getMemoryUsage = () => { + export let getMemoryUsage: typeof IO.getMemoryUsage = () => { if (global.gc) { global.gc(); } return process.memoryUsage().heapUsed; - } + }; } export module Network { - var serverRoot = "http://localhost:8888/"; + let serverRoot = "http://localhost:8888/"; // Unused? - var newLine = '\r\n'; - var currentDirectory = () => ''; - var supportsCodePage = () => false; + let newLine = '\r\n'; + let currentDirectory = () => ''; + let supportsCodePage = () => false; module Http { function waitForXHR(xhr: XMLHttpRequest) { @@ -572,7 +570,7 @@ module Harness { /// Ask the server to use node's path.resolve to resolve the given path function getResolvedPathFromServer(path: string) { - var xhr = new XMLHttpRequest(); + let xhr = new XMLHttpRequest(); try { xhr.open("GET", path + "?resolve", false); xhr.send(); @@ -591,7 +589,7 @@ module Harness { /// Ask the server for the contents of the file at the given URL via a simple GET request export function getFileFromServerSync(url: string): XHRResponse { - var xhr = new XMLHttpRequest(); + let xhr = new XMLHttpRequest(); try { xhr.open("GET", url, false); xhr.send(); @@ -605,10 +603,10 @@ module Harness { /// Submit a POST request to the server to do the given action (ex WRITE, DELETE) on the provided URL export function writeToServerSync(url: string, action: string, contents?: string): XHRResponse { - var xhr = new XMLHttpRequest(); + let xhr = new XMLHttpRequest(); try { - var action = '?action=' + action; - xhr.open('POST', url + action, false); + let actionMsg = '?action=' + action; + xhr.open('POST', url + actionMsg, false); xhr.setRequestHeader('Access-Control-Allow-Origin', '*'); xhr.send(contents); } @@ -633,7 +631,7 @@ module Harness { } function directoryNameImpl(path: string) { - var dirPath = path; + let dirPath = path; // root of the server if (dirPath.match(/localhost:\d+$/) || dirPath.match(/localhost:\d+\/$/)) { dirPath = null; @@ -646,22 +644,22 @@ module Harness { if (dirPath.match(/.*\/$/)) { dirPath = dirPath.substring(0, dirPath.length - 2); } - var dirPath = dirPath.substring(0, dirPath.lastIndexOf('/')); + dirPath = dirPath.substring(0, dirPath.lastIndexOf('/')); } return dirPath; } - export var directoryName: typeof IO.directoryName = Utils.memoize(directoryNameImpl); + export let directoryName: typeof IO.directoryName = Utils.memoize(directoryNameImpl); export function fileExists(path: string): boolean { - var response = Http.getFileFromServerSync(serverRoot + path); + let response = Http.getFileFromServerSync(serverRoot + path); return response.status === 200; } export function _listFilesImpl(path: string, spec?: RegExp, options?: any) { - var response = Http.getFileFromServerSync(serverRoot + path); + let response = Http.getFileFromServerSync(serverRoot + path); if (response.status === 200) { - var results = response.responseText.split(','); + let results = response.responseText.split(','); if (spec) { return results.filter(file => spec.test(file)); } else { @@ -672,12 +670,12 @@ module Harness { return ['']; } }; - export var listFiles = Utils.memoize(_listFilesImpl); + export let listFiles = Utils.memoize(_listFilesImpl); - export var log = console.log; + export let log = console.log; export function readFile(file: string) { - var response = Http.getFileFromServerSync(serverRoot + file); + let response = Http.getFileFromServerSync(serverRoot + file); if (response.status === 200) { return response.responseText; } else { @@ -706,9 +704,9 @@ module Harness { } module Harness { - var tcServicesFileName = "typescriptServices.js"; + let tcServicesFileName = "typescriptServices.js"; - export var libFolder: string; + export let libFolder: string; switch (Utils.getExecutionEnvironment()) { case Utils.ExecutionEnvironment.CScript: libFolder = "built/local/"; @@ -725,7 +723,7 @@ module Harness { default: throw new Error('Unknown context'); } - export var tcServicesFile = IO.readFile(tcServicesFileName); + export let tcServicesFile = IO.readFile(tcServicesFileName); export interface SourceMapEmitterCallback { (emittedFile: string, emittedLine: number, emittedColumn: number, sourceFile: string, sourceLine: number, sourceColumn: number, sourceName: string): void; @@ -777,7 +775,7 @@ module Harness { /** create file gets the whole path to create, so this works as expected with the --out parameter */ public writeFile(s: string, contents: string, writeByteOrderMark: boolean): void { - var writer: ITextWriter; + let writer: ITextWriter; if (this.fileCollection[s]) { writer = this.fileCollection[s]; } @@ -795,10 +793,10 @@ module Harness { public reset() { this.fileCollection = {}; } public toArray(): { fileName: string; file: WriterAggregator; }[] { - var result: { fileName: string; file: WriterAggregator; }[] = []; - for (var p in this.fileCollection) { + let result: { fileName: string; file: WriterAggregator; }[] = []; + for (let p in this.fileCollection) { if (this.fileCollection.hasOwnProperty(p)) { - var current = this.fileCollection[p]; + let current = this.fileCollection[p]; if (current.lines.length > 0) { if (p.indexOf('.d.ts') !== -1) { current.lines.unshift(['////[', Path.getFileName(p), ']'].join('')); } result.push({ fileName: p, file: this.fileCollection[p] }); @@ -813,11 +811,11 @@ module Harness { fileName: string, sourceText: string, languageVersion: ts.ScriptTarget) { - // We'll only assert invariants outside of light mode. + // We'll only assert inletiants outside of light mode. const shouldAssertInvariants = !Harness.lightMode; - // Only set the parent nodes if we're asserting invariants. We don't need them otherwise. - var result = ts.createSourceFile(fileName, sourceText, languageVersion, /*setParentNodes:*/ shouldAssertInvariants); + // Only set the parent nodes if we're asserting inletiants. We don't need them otherwise. + let result = ts.createSourceFile(fileName, sourceText, languageVersion, /*setParentNodes:*/ shouldAssertInvariants); if (shouldAssertInvariants) { Utils.assertInvariants(result, /*parent:*/ undefined); @@ -829,13 +827,13 @@ module Harness { const carriageReturnLineFeed = "\r\n"; const lineFeed = "\n"; - export var defaultLibFileName = 'lib.d.ts'; - export var defaultLibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest); - export var defaultES6LibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.es6.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest); + export let defaultLibFileName = 'lib.d.ts'; + export let defaultLibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest); + export let defaultES6LibSourceFile = createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + 'lib.core.es6.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest); // Cache these between executions so we don't have to re-parse them for every test - export var fourslashFileName = 'fourslash.ts'; - export var fourslashSourceFile: ts.SourceFile; + export let fourslashFileName = 'fourslash.ts'; + export let fourslashSourceFile: ts.SourceFile; export function getCanonicalFileName(fileName: string): string { return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); @@ -855,13 +853,13 @@ module Harness { return useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); } - var filemap: { [fileName: string]: ts.SourceFile; } = {}; - var getCurrentDirectory = currentDirectory === undefined ? ts.sys.getCurrentDirectory : () => currentDirectory; + let filemap: { [fileName: string]: ts.SourceFile; } = {}; + let getCurrentDirectory = currentDirectory === undefined ? ts.sys.getCurrentDirectory : () => currentDirectory; // Register input files function register(file: { unitName: string; content: string; }) { if (file.content !== undefined) { - var fileName = ts.normalizePath(file.unitName); + let fileName = ts.normalizePath(file.unitName); filemap[getCanonicalFileName(fileName)] = createSourceFileAndAssertInvariants(fileName, file.content, scriptTarget); } }; @@ -880,11 +878,11 @@ module Harness { return filemap[getCanonicalFileName(fn)]; } else if (currentDirectory) { - var canonicalAbsolutePath = getCanonicalFileName(ts.getNormalizedAbsolutePath(fn, currentDirectory)); + let canonicalAbsolutePath = getCanonicalFileName(ts.getNormalizedAbsolutePath(fn, currentDirectory)); return Object.prototype.hasOwnProperty.call(filemap, getCanonicalFileName(canonicalAbsolutePath)) ? filemap[canonicalAbsolutePath] : undefined; } else if (fn === fourslashFileName) { - var tsFn = 'tests/cases/fourslash/' + fourslashFileName; + let tsFn = 'tests/cases/fourslash/' + fourslashFileName; fourslashSourceFile = fourslashSourceFile || createSourceFileAndAssertInvariants(tsFn, Harness.IO.readFile(tsFn), scriptTarget); return fourslashSourceFile; } @@ -980,27 +978,27 @@ module Harness { // Files from built\local that are requested by test "@includeBuiltFiles" to be in the context. // Treat them as library files, so include them in build, but not in baselines. - var includeBuiltFiles: { unitName: string; content: string }[] = []; + let includeBuiltFiles: { unitName: string; content: string }[] = []; - var useCaseSensitiveFileNames = ts.sys.useCaseSensitiveFileNames; + let useCaseSensitiveFileNames = ts.sys.useCaseSensitiveFileNames; this.settings.forEach(setCompilerOptionForSetting); - var fileOutputs: GeneratedFile[] = []; + let fileOutputs: GeneratedFile[] = []; - var programFiles = inputFiles.concat(includeBuiltFiles).map(file => file.unitName); + let programFiles = inputFiles.concat(includeBuiltFiles).map(file => file.unitName); - var compilerHost = createCompilerHost( + let compilerHost = createCompilerHost( inputFiles.concat(includeBuiltFiles).concat(otherFiles), (fn, contents, writeByteOrderMark) => fileOutputs.push({ fileName: fn, code: contents, writeByteOrderMark: writeByteOrderMark }), options.target, useCaseSensitiveFileNames, currentDirectory, options.newLine); - var program = ts.createProgram(programFiles, options, compilerHost); + let program = ts.createProgram(programFiles, options, compilerHost); - var emitResult = program.emit(); + let emitResult = program.emit(); - var errors = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics); + let errors = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics); this.lastErrors = errors; - var result = new CompilerResult(fileOutputs, errors, program, ts.sys.getCurrentDirectory(), emitResult.sourceMaps); + let result = new CompilerResult(fileOutputs, errors, program, ts.sys.getCurrentDirectory(), emitResult.sourceMaps); onComplete(result, program); // reset what newline means in case the last test changed it @@ -1193,12 +1191,12 @@ module Harness { throw new Error('There were no errors and declFiles generated did not match number of js files generated'); } + let declInputFiles: { unitName: string; content: string }[] = []; + let declOtherFiles: { unitName: string; content: string }[] = []; + let declResult: Harness.Compiler.CompilerResult; + // if the .d.ts is non-empty, confirm it compiles correctly as well if (options.declaration && result.errors.length === 0 && result.declFilesCode.length > 0) { - var declInputFiles: { unitName: string; content: string }[] = []; - var declOtherFiles: { unitName: string; content: string }[] = []; - var declResult: Harness.Compiler.CompilerResult; - ts.forEach(inputFiles, file => addDtsFile(file, declInputFiles)); ts.forEach(otherFiles, file => addDtsFile(file, declOtherFiles)); this.compileFiles(declInputFiles, declOtherFiles, function (compileResult) { declResult = compileResult; }, @@ -1212,20 +1210,20 @@ module Harness { dtsFiles.push(file); } else if (isTS(file.unitName)) { - var declFile = findResultCodeFile(file.unitName); + let declFile = findResultCodeFile(file.unitName); if (!findUnit(declFile.fileName, declInputFiles) && !findUnit(declFile.fileName, declOtherFiles)) { dtsFiles.push({ unitName: declFile.fileName, content: declFile.code }); } } function findResultCodeFile(fileName: string) { - var sourceFile = result.program.getSourceFile(fileName); + let sourceFile = result.program.getSourceFile(fileName); assert(sourceFile, "Program has no source file with name '" + fileName + "'"); // Is this file going to be emitted separately - var sourceFileName: string; + let sourceFileName: string; if (ts.isExternalModule(sourceFile) || !options.out) { if (options.outDir) { - var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, result.currentDirectoryForProgram); + let sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, result.currentDirectoryForProgram); sourceFilePath = sourceFilePath.replace(result.program.getCommonSourceDirectory(), ""); sourceFileName = ts.combinePaths(options.outDir, sourceFilePath); } @@ -1238,7 +1236,7 @@ module Harness { sourceFileName = options.out; } - var dTsFileName = ts.removeFileExtension(sourceFileName) + ".d.ts"; + let dTsFileName = ts.removeFileExtension(sourceFileName) + ".d.ts"; return ts.forEach(result.declFilesCode, declFile => declFile.fileName === dTsFileName ? declFile : undefined); } @@ -1251,7 +1249,7 @@ module Harness { } function normalizeLineEndings(text: string, lineEnding: string): string { - var normalized = text.replace(/\r\n?/g, '\n'); + let normalized = text.replace(/\r\n?/g, '\n'); if (lineEnding !== '\n') { normalized = normalized.replace(/\n/g, lineEnding); } @@ -1260,10 +1258,10 @@ module Harness { export function minimalDiagnosticsToString(diagnostics: ts.Diagnostic[]) { // This is basically copied from tsc.ts's reportError to replicate what tsc does - var errorOutput = ""; + let errorOutput = ""; ts.forEach(diagnostics, diagnostic => { if (diagnostic.file) { - var lineAndCharacter = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); + let lineAndCharacter = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); errorOutput += diagnostic.file.fileName + "(" + (lineAndCharacter.line + 1) + "," + (lineAndCharacter.character + 1) + "): "; } @@ -1275,14 +1273,14 @@ module Harness { export function getErrorBaseline(inputFiles: { unitName: string; content: string }[], diagnostics: ts.Diagnostic[]) { diagnostics.sort(ts.compareDiagnostics); - var outputLines: string[] = []; + let outputLines: string[] = []; // Count up all the errors we find so we don't miss any - var totalErrorsReported = 0; + let totalErrorsReported = 0; function outputErrorText(error: ts.Diagnostic) { - var message = ts.flattenDiagnosticMessageText(error.messageText, ts.sys.newLine); + let message = ts.flattenDiagnosticMessageText(error.messageText, ts.sys.newLine); - var errLines = RunnerBase.removeFullPaths(message) + let errLines = RunnerBase.removeFullPaths(message) .split('\n') .map(s => s.length > 0 && s.charAt(s.length - 1) === '\r' ? s.substr(0, s.length - 1) : s) .filter(s => s.length > 0) @@ -1293,14 +1291,14 @@ module Harness { } // Report global errors - var globalErrors = diagnostics.filter(err => !err.file); + let globalErrors = diagnostics.filter(err => !err.file); globalErrors.forEach(outputErrorText); // 'merge' the lines of each input file with any errors associated with it inputFiles.filter(f => f.content !== undefined).forEach(inputFile => { // Filter down to the errors in the file - var fileErrors = diagnostics.filter(e => { - var errFn = e.file; + let fileErrors = diagnostics.filter(e => { + let errFn = e.file; return errFn && errFn.fileName === inputFile.unitName; }); @@ -1309,13 +1307,13 @@ module Harness { outputLines.push('==== ' + inputFile.unitName + ' (' + fileErrors.length + ' errors) ===='); // Make sure we emit something for every error - var markedErrorCount = 0; + let markedErrorCount = 0; // For each line, emit the line followed by any error squiggles matching this line // Note: IE JS engine incorrectly handles consecutive delimiters here when using RegExp split, so // we have to string-based splitting instead and try to figure out the delimiting chars - var lineStarts = ts.computeLineStarts(inputFile.content); - var lines = inputFile.content.split('\n'); + let lineStarts = ts.computeLineStarts(inputFile.content); + let lines = inputFile.content.split('\n'); if (lines.length === 1) { lines = lines[0].split("\r"); } @@ -1325,8 +1323,8 @@ module Harness { line = line.substr(0, line.length - 1); } - var thisLineStart = lineStarts[lineIndex]; - var nextLineStart: number; + let thisLineStart = lineStarts[lineIndex]; + let nextLineStart: number; // On the last line of the file, fake the next line start number so that we handle errors on the last character of the file correctly if (lineIndex === lines.length - 1) { nextLineStart = inputFile.content.length; @@ -1340,11 +1338,11 @@ module Harness { let end = ts.textSpanEnd(err); if ((end >= thisLineStart) && ((err.start < nextLineStart) || (lineIndex === lines.length - 1))) { // How many characters from the start of this line the error starts at (could be positive or negative) - var relativeOffset = err.start - thisLineStart; + let relativeOffset = err.start - thisLineStart; // How many characters of the error are on this line (might be longer than this line in reality) - var length = (end - err.start) - Math.max(0, thisLineStart - err.start); + let length = (end - err.start) - Math.max(0, thisLineStart - err.start); // Calculate the start of the squiggle - var squiggleStart = Math.max(0, relativeOffset); + let squiggleStart = Math.max(0, relativeOffset); // TODO/REVIEW: this doesn't work quite right in the browser if a multi file test has files whose names are just the right length relative to one another outputLines.push(' ' + line.substr(0, squiggleStart).replace(/[^\s]/g, ' ') + new Array(Math.min(length, line.length - squiggleStart) + 1).join('~')); @@ -1364,11 +1362,11 @@ module Harness { assert.equal(markedErrorCount, fileErrors.length, 'count of errors in ' + inputFile.unitName); }); - var numLibraryDiagnostics = ts.countWhere(diagnostics, diagnostic => { + let numLibraryDiagnostics = ts.countWhere(diagnostics, diagnostic => { return diagnostic.file && (isLibraryFile(diagnostic.file.fileName) || isBuiltFile(diagnostic.file.fileName)); }); - var numTest262HarnessDiagnostics = ts.countWhere(diagnostics, diagnostic => { + let numTest262HarnessDiagnostics = ts.countWhere(diagnostics, diagnostic => { // Count an error generated from tests262-harness folder.This should only apply for test262 return diagnostic.file && diagnostic.file.fileName.indexOf("test262-harness") >= 0; }); @@ -1385,7 +1383,7 @@ module Harness { outputFiles.sort((a, b) => cleanName(a.fileName).localeCompare(cleanName(b.fileName))); // Emit them - var result = ''; + let result = ''; for (let outputFile of outputFiles) { // Some extra spacing if this isn't the first file if (result.length) { @@ -1401,13 +1399,13 @@ module Harness { return result; function cleanName(fn: string) { - var lastSlash = ts.normalizeSlashes(fn).lastIndexOf('/'); + let lastSlash = ts.normalizeSlashes(fn).lastIndexOf('/'); return fn.substr(lastSlash + 1).toLowerCase(); } } /** The harness' compiler instance used when tests are actually run. Reseting or changing settings of this compiler instance must be done within a test case (i.e., describe/it) */ - var harnessCompiler: HarnessCompiler; + let harnessCompiler: HarnessCompiler; /** Returns the singleton harness compiler instance for generating and running tests. If required a fresh compiler instance will be created, otherwise the existing singleton will be re-used. @@ -1420,8 +1418,6 @@ module Harness { export function compileString(code: string, unitName: string, callback: (result: CompilerResult) => void) { // NEWTODO: Re-implement 'compileString' throw new Error('compileString NYI'); - //var harnessCompiler = Harness.Compiler.getCompiler(Harness.Compiler.CompilerInstance.RunTime); - //harnessCompiler.compileString(code, unitName, callback); } export interface GeneratedFile { @@ -1513,10 +1509,10 @@ module Harness { } // Regex for parsing options in the format "@Alpha: Value of any sort" - var optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines + let optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines // List of allowed metadata names - var fileMetadataNames = ["filename", "comments", "declaration", "module", + let fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noemithelpers", "noemitonerror", "noimplicitany", "noresolve", "newline", "normalizenewline", "emitbom", "errortruncation", "usecasesensitivefilenames", "preserveconstenums", @@ -1527,9 +1523,9 @@ module Harness { function extractCompilerSettings(content: string): CompilerSetting[] { - var opts: CompilerSetting[] = []; + let opts: CompilerSetting[] = []; - var match: RegExpExecArray; + let match: RegExpExecArray; while ((match = optionRegex.exec(content)) != null) { opts.push({ flag: match[1], value: match[2] }); } @@ -1539,26 +1535,26 @@ module Harness { /** Given a test file containing // @FileName directives, return an array of named units of code to be added to an existing compiler instance */ export function makeUnitsFromTest(code: string, fileName: string): { settings: CompilerSetting[]; testUnitData: TestUnitData[]; } { - var settings = extractCompilerSettings(code); + let settings = extractCompilerSettings(code); // List of all the subfiles we've parsed out - var testUnitData: TestUnitData[] = []; + let testUnitData: TestUnitData[] = []; - var lines = Utils.splitContentByNewlines(code); + let lines = Utils.splitContentByNewlines(code); // Stuff related to the subfile we're parsing - var currentFileContent: string = null; - var currentFileOptions: any = {}; - var currentFileName: any = null; - var refs: string[] = []; + let currentFileContent: string = null; + let currentFileOptions: any = {}; + let currentFileName: any = null; + let refs: string[] = []; - for (var i = 0; i < lines.length; i++) { - var line = lines[i]; - var testMetaData = optionRegex.exec(line); + for (let i = 0; i < lines.length; i++) { + let line = lines[i]; + let testMetaData = optionRegex.exec(line); if (testMetaData) { // Comment line, check for global/file @options and record them optionRegex.lastIndex = 0; - var metaDataName = testMetaData[1].toLowerCase(); + let metaDataName = testMetaData[1].toLowerCase(); if (metaDataName === "filename") { currentFileOptions[testMetaData[1]] = testMetaData[2]; } else { @@ -1568,8 +1564,7 @@ module Harness { // New metadata statement after having collected some code to go with the previous metadata if (currentFileName) { // Store result file - var newTestFile = - { + let newTestFile = { content: currentFileContent, name: currentFileName, fileOptions: currentFileOptions, @@ -1604,7 +1599,7 @@ module Harness { currentFileName = testUnitData.length > 0 ? currentFileName : Path.getFileName(fileName); // EOF, push whatever remains - var newTestFile2 = { + let newTestFile2 = { content: currentFileContent || '', name: currentFileName, fileOptions: currentFileOptions, @@ -1651,7 +1646,7 @@ module Harness { } } - var fileCache: { [idx: string]: boolean } = {}; + let fileCache: { [idx: string]: boolean } = {}; function generateActual(actualFileName: string, generateContent: () => string): string { // For now this is written using TypeScript, because sys is not available when running old test cases. // But we need to move to sys once we have @@ -1662,7 +1657,7 @@ module Harness { return; } - var parentDirectory = IO.directoryName(dirName); + let parentDirectory = IO.directoryName(dirName); if (parentDirectory != "") { createDirectoryStructure(parentDirectory); } @@ -1678,7 +1673,7 @@ module Harness { IO.deleteFile(actualFileName); } - var actual = generateContent(); + let actual = generateContent(); if (actual === undefined) { throw new Error('The generated content was "undefined". Return "null" if no baselining is required."'); @@ -1701,13 +1696,13 @@ module Harness { return; } - var refFileName = referencePath(relativeFileName, opts && opts.Baselinefolder, opts && opts.Subfolder); + let refFileName = referencePath(relativeFileName, opts && opts.Baselinefolder, opts && opts.Subfolder); if (actual === null) { actual = ''; } - var expected = ''; + let expected = ''; if (IO.fileExists(refFileName)) { expected = IO.readFile(refFileName); } @@ -1716,10 +1711,10 @@ module Harness { } function writeComparison(expected: string, actual: string, relativeFileName: string, actualFileName: string, descriptionForDescribe: string) { - var encoded_actual = (new Buffer(actual)).toString('utf8') + let encoded_actual = (new Buffer(actual)).toString('utf8'); if (expected != encoded_actual) { // Overwrite & issue error - var errMsg = 'The baseline file ' + relativeFileName + ' has changed'; + let errMsg = 'The baseline file ' + relativeFileName + ' has changed'; throw new Error(errMsg); } } @@ -1731,17 +1726,17 @@ module Harness { runImmediately = false, opts?: BaselineOptions): void { - var actual = undefined; - var actualFileName = localPath(relativeFileName, opts && opts.Baselinefolder, opts && opts.Subfolder); + let actual = undefined; + let actualFileName = localPath(relativeFileName, opts && opts.Baselinefolder, opts && opts.Subfolder); if (runImmediately) { actual = generateActual(actualFileName, generateContent); - var comparison = compareToBaseline(actual, relativeFileName, opts); + let comparison = compareToBaseline(actual, relativeFileName, opts); writeComparison(comparison.expected, comparison.actual, relativeFileName, actualFileName, descriptionForDescribe); } else { actual = generateActual(actualFileName, generateContent); - var comparison = compareToBaseline(actual, relativeFileName, opts); + let comparison = compareToBaseline(actual, relativeFileName, opts); writeComparison(comparison.expected, comparison.actual, relativeFileName, actualFileName, descriptionForDescribe); } } @@ -1756,11 +1751,11 @@ module Harness { } export function getDefaultLibraryFile(): { unitName: string, content: string } { - var libFile = Harness.userSpecifiedRoot + Harness.libFolder + "/" + "lib.d.ts"; + let libFile = Harness.userSpecifiedRoot + Harness.libFolder + "/" + "lib.d.ts"; return { unitName: libFile, content: IO.readFile(libFile) - } + }; } if (Error) (Error).stackTraceLimit = 1; diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 6cb92df5948..3c543e50566 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -26,9 +26,9 @@ module Harness.LanguageService { public editContent(start: number, end: number, newText: string): void { // Apply edits - var prefix = this.content.substring(0, start); - var middle = newText; - var suffix = this.content.substring(end); + let prefix = this.content.substring(0, start); + let middle = newText; + let suffix = this.content.substring(end); this.setContent(prefix + middle + suffix); // Store edit range + new length of script @@ -48,10 +48,10 @@ module Harness.LanguageService { return ts.unchangedTextChangeRange; } - var initialEditRangeIndex = this.editRanges.length - (this.version - startVersion); - var lastEditRangeIndex = this.editRanges.length - (this.version - endVersion); + let initialEditRangeIndex = this.editRanges.length - (this.version - startVersion); + let lastEditRangeIndex = this.editRanges.length - (this.version - endVersion); - var entries = this.editRanges.slice(initialEditRangeIndex, lastEditRangeIndex); + let entries = this.editRanges.slice(initialEditRangeIndex, lastEditRangeIndex); return ts.collapseTextChangeRangesAcrossMultipleVersions(entries.map(e => e.textChangeRange)); } } @@ -74,7 +74,7 @@ module Harness.LanguageService { } public getChangeRange(oldScript: ts.IScriptSnapshot): ts.TextChangeRange { - var oldShim = oldScript; + let oldShim = oldScript; return this.scriptInfo.getTextChangeRangeBetweenVersions(oldShim.version, this.version); } } @@ -92,9 +92,9 @@ module Harness.LanguageService { } public getChangeRange(oldScript: ts.ScriptSnapshotShim): string { - var oldShim = oldScript; + let oldShim = oldScript; - var range = this.scriptSnapshot.getChangeRange(oldShim.scriptSnapshot); + let range = this.scriptSnapshot.getChangeRange(oldShim.scriptSnapshot); if (range === null) { return null; } @@ -130,8 +130,8 @@ module Harness.LanguageService { } public getFilenames(): string[] { - var fileNames: string[] = []; - ts.forEachKey(this.fileNameToScript,(fileName) => { fileNames.push(fileName); }); + let fileNames: string[] = []; + ts.forEachKey(this.fileNameToScript, (fileName) => { fileNames.push(fileName); }); return fileNames; } @@ -144,7 +144,7 @@ module Harness.LanguageService { } public editScript(fileName: string, start: number, end: number, newText: string) { - var script = this.getScriptInfo(fileName); + let script = this.getScriptInfo(fileName); if (script !== null) { script.editContent(start, end, newText); return; @@ -161,7 +161,7 @@ module Harness.LanguageService { * @param col 0 based index */ public positionToLineAndCharacter(fileName: string, position: number): ts.LineAndCharacter { - var script: ScriptInfo = this.fileNameToScript[fileName]; + let script: ScriptInfo = this.fileNameToScript[fileName]; assert.isNotNull(script); return ts.computeLineAndCharacterOfPosition(script.lineMap, position); @@ -176,11 +176,11 @@ module Harness.LanguageService { getDefaultLibFileName(): string { return ""; } getScriptFileNames(): string[] { return this.getFilenames(); } getScriptSnapshot(fileName: string): ts.IScriptSnapshot { - var script = this.getScriptInfo(fileName); + let script = this.getScriptInfo(fileName); return script ? new ScriptSnapshot(script) : undefined; } getScriptVersion(fileName: string): string { - var script = this.getScriptInfo(fileName); + let script = this.getScriptInfo(fileName); return script ? script.version.toString() : undefined; } @@ -220,7 +220,7 @@ module Harness.LanguageService { getDefaultLibFileName(): string { return this.nativeHost.getDefaultLibFileName(); } getScriptFileNames(): string { return JSON.stringify(this.nativeHost.getScriptFileNames()); } getScriptSnapshot(fileName: string): ts.ScriptSnapshotShim { - var nativeScriptSnapshot = this.nativeHost.getScriptSnapshot(fileName); + let nativeScriptSnapshot = this.nativeHost.getScriptSnapshot(fileName); return nativeScriptSnapshot && new ScriptSnapshotProxy(nativeScriptSnapshot); } getScriptVersion(fileName: string): string { return this.nativeHost.getScriptVersion(fileName); } @@ -242,13 +242,13 @@ module Harness.LanguageService { throw new Error("NYI"); } getClassificationsForLine(text: string, lexState: ts.EndOfLineState, classifyKeywordsInGenerics?: boolean): ts.ClassificationResult { - var result = this.shim.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics).split('\n'); - var entries: ts.ClassificationInfo[] = []; - var i = 0; - var position = 0; + let result = this.shim.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics).split('\n'); + let entries: ts.ClassificationInfo[] = []; + let i = 0; + let position = 0; for (; i < result.length - 1; i += 2) { - var t = entries[i / 2] = { + let t = entries[i / 2] = { length: parseInt(result[i]), classification: parseInt(result[i + 1]) }; @@ -256,7 +256,7 @@ module Harness.LanguageService { assert.isTrue(t.length > 0, "Result length should be greater than 0, got :" + t.length); position += t.length; } - var finalLexState = parseInt(result[result.length - 1]); + let finalLexState = parseInt(result[result.length - 1]); assert.equal(position, text.length, "Expected cumulative length of all entries to match the length of the source. expected: " + text.length + ", but got: " + position); @@ -268,7 +268,7 @@ module Harness.LanguageService { } function unwrapJSONCallResult(result: string): any { - var parsedResult = JSON.parse(result); + let parsedResult = JSON.parse(result); if (parsedResult.error) { throw new Error("Language Service Shim Error: " + JSON.stringify(parsedResult.error)); } @@ -282,7 +282,7 @@ module Harness.LanguageService { constructor(private shim: ts.LanguageServiceShim) { } private unwrappJSONCallResult(result: string): any { - var parsedResult = JSON.parse(result); + let parsedResult = JSON.parse(result); if (parsedResult.error) { throw new Error("Language Service Shim Error: " + JSON.stringify(parsedResult.error)); } @@ -404,16 +404,16 @@ module Harness.LanguageService { getLanguageService(): ts.LanguageService { return new LanguageServiceShimProxy(this.factory.createLanguageServiceShim(this.host)); } getClassifier(): ts.Classifier { return new ClassifierShimProxy(this.factory.createClassifierShim(this.host)); } getPreProcessedFileInfo(fileName: string, fileContents: string): ts.PreProcessedFileInfo { - var shimResult: { + let shimResult: { referencedFiles: ts.IFileReference[]; importedFiles: ts.IFileReference[]; isLibFile: boolean; }; - var coreServicesShim = this.factory.createCoreServicesShim(this.host); + let coreServicesShim = this.factory.createCoreServicesShim(this.host); shimResult = unwrapJSONCallResult(coreServicesShim.getPreProcessedFileInfo(fileName, ts.ScriptSnapshot.fromString(fileContents))); - var convertResult: ts.PreProcessedFileInfo = { + let convertResult: ts.PreProcessedFileInfo = { referencedFiles: [], importedFiles: [], isLibFile: shimResult.isLibFile @@ -496,7 +496,7 @@ module Harness.LanguageService { fileName = Harness.Compiler.defaultLibFileName; } - var snapshot = this.host.getScriptSnapshot(fileName); + let snapshot = this.host.getScriptSnapshot(fileName); return snapshot && snapshot.getText(0, snapshot.getLength()); } @@ -574,13 +574,13 @@ module Harness.LanguageService { private client: ts.server.SessionClient; constructor(cancellationToken?: ts.HostCancellationToken, options?: ts.CompilerOptions) { // This is the main host that tests use to direct tests - var clientHost = new SessionClientHost(cancellationToken, options); - var client = new ts.server.SessionClient(clientHost); + let clientHost = new SessionClientHost(cancellationToken, options); + let client = new ts.server.SessionClient(clientHost); // This host is just a proxy for the clientHost, it uses the client // host to answer server queries about files on disk - var serverHost = new SessionServerHost(clientHost); - var server = new ts.server.Session(serverHost, Buffer.byteLength, process.hrtime, serverHost); + let serverHost = new SessionServerHost(clientHost); + let server = new ts.server.Session(serverHost, Buffer.byteLength, process.hrtime, serverHost); // Fake the connection between the client and the server serverHost.writeMessage = client.onMessage.bind(client); diff --git a/src/harness/loggedIO.ts b/src/harness/loggedIO.ts index 8ba38043e78..0ce567e9563 100644 --- a/src/harness/loggedIO.ts +++ b/src/harness/loggedIO.ts @@ -70,9 +70,9 @@ interface PlaybackControl { } module Playback { - var recordLog: IOLog = undefined; - var replayLog: IOLog = undefined; - var recordLogFileNameBase = ''; + let recordLog: IOLog = undefined; + let replayLog: IOLog = undefined; + let recordLogFileNameBase = ''; interface Memoized { (s: string): T; @@ -80,8 +80,8 @@ module Playback { } function memoize(func: (s: string) => T): Memoized { - var lookup: { [s: string]: T } = {}; - var run: Memoized = >((s: string) => { + let lookup: { [s: string]: T } = {}; + let run: Memoized = >((s: string) => { if (lookup.hasOwnProperty(s)) return lookup[s]; return lookup[s] = func(s); }); @@ -161,10 +161,10 @@ module Playback { } function findResultByFields(logArray: { result?: T }[], expectedFields: {}, defaultValue?: T): T { - var predicate = (entry: { result?: T }) => { + let predicate = (entry: { result?: T }) => { return Object.getOwnPropertyNames(expectedFields).every((name) => (entry)[name] === (expectedFields)[name]); }; - var results = logArray.filter(entry => predicate(entry)); + let results = logArray.filter(entry => predicate(entry)); if (results.length === 0) { if (defaultValue !== undefined) { return defaultValue; @@ -176,17 +176,17 @@ module Playback { } function findResultByPath(wrapper: { resolvePath(s: string): string }, logArray: { path: string; result?: T }[], expectedPath: string, defaultValue?: T): T { - var normalizedName = ts.normalizeSlashes(expectedPath).toLowerCase(); + let normalizedName = ts.normalizeSlashes(expectedPath).toLowerCase(); // Try to find the result through normal fileName - for (var i = 0; i < logArray.length; i++) { + for (let i = 0; i < logArray.length; i++) { if (ts.normalizeSlashes(logArray[i].path).toLowerCase() === normalizedName) { return logArray[i].result; } } // Fallback, try to resolve the target paths as well if (replayLog.pathsResolved.length > 0) { - var normalizedResolvedName = wrapper.resolvePath(expectedPath).toLowerCase(); - for (var i = 0; i < logArray.length; i++) { + let normalizedResolvedName = wrapper.resolvePath(expectedPath).toLowerCase(); + for (let i = 0; i < logArray.length; i++) { if (wrapper.resolvePath(logArray[i].path).toLowerCase() === normalizedResolvedName) { return logArray[i].result; } @@ -200,9 +200,9 @@ module Playback { } } - var pathEquivCache: any = {}; + let pathEquivCache: any = {}; function pathsAreEquivalent(left: string, right: string, wrapper: { resolvePath(s: string): string }) { - var key = left + '-~~-' + right; + let key = left + '-~~-' + right; function areSame(a: string, b: string) { return ts.normalizeSlashes(a).toLowerCase() === ts.normalizeSlashes(b).toLowerCase(); } @@ -219,11 +219,11 @@ module Playback { } function noOpReplay(name: string) { - //console.log("Swallowed write operation during replay: " + name); + // console.log("Swallowed write operation during replay: " + name); } export function wrapSystem(underlying: ts.System): PlaybackSystem { - var wrapper: PlaybackSystem = {}; + let wrapper: PlaybackSystem = {}; initWrapper(wrapper, underlying); wrapper.startReplayFromFile = logFn => { @@ -231,8 +231,8 @@ module Playback { }; wrapper.endRecord = () => { if (recordLog !== undefined) { - var i = 0; - var fn = () => recordLogFileNameBase + i + '.json'; + let i = 0; + let fn = () => recordLogFileNameBase + i + '.json'; while (underlying.fileExists(fn())) i++; underlying.writeFile(fn(), JSON.stringify(recordLog)); recordLog = undefined; @@ -289,8 +289,8 @@ module Playback { wrapper.readFile = recordReplay(wrapper.readFile, underlying)( (path) => { - var result = underlying.readFile(path); - var logEntry = { path: path, codepage: 0, result: { contents: result, codepage: 0 } }; + let result = underlying.readFile(path); + let logEntry = { path: path, codepage: 0, result: { contents: result, codepage: 0 } }; recordLog.filesRead.push(logEntry); return result; }, diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index 5eb0016ff8d..5ea118aacbf 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -46,7 +46,7 @@ interface BatchCompileProjectTestCaseResult extends CompileProjectFilesResult { class ProjectRunner extends RunnerBase { public initializeTests() { if (this.tests.length === 0) { - var testFiles = this.enumerateFiles("tests/cases/project", /\.json$/, { recursive: true }); + let testFiles = this.enumerateFiles("tests/cases/project", /\.json$/, { recursive: true }); testFiles.forEach(fn => { fn = fn.replace(/\\/g, "/"); this.runProjectTestCase(fn); @@ -58,10 +58,11 @@ class ProjectRunner extends RunnerBase { } private runProjectTestCase(testCaseFileName: string) { - var testCase: ProjectRunnerTestCase; + let testCase: ProjectRunnerTestCase; + let testFileText: string = null; try { - var testFileText = ts.sys.readFile(testCaseFileName); + testFileText = ts.sys.readFile(testCaseFileName); } catch (e) { assert(false, "Unable to open testcase file: " + testCaseFileName + ": " + e.message); @@ -73,7 +74,7 @@ class ProjectRunner extends RunnerBase { catch (e) { assert(false, "Testcase: " + testCaseFileName + " does not contain valid json format: " + e.message); } - var testCaseJustName = testCaseFileName.replace(/^.*[\\\/]/, '').replace(/\.json/, ""); + let testCaseJustName = testCaseFileName.replace(/^.*[\\\/]/, '').replace(/\.json/, ""); function moduleNameToString(moduleKind: ts.ModuleKind) { return moduleKind === ts.ModuleKind.AMD @@ -89,7 +90,7 @@ class ProjectRunner extends RunnerBase { } // When test case output goes to tests/baselines/local/projectOutput/testCaseName/moduleKind/ - // We have these two separate locations because when comparing baselines the baseline verifier will delete the existing file + // We have these two separate locations because when comparing baselines the baseline verifier will delete the existing file // so even if it was created by compiler in that location, the file will be deleted by verified before we can read it // so lets keep these two locations separate function getProjectOutputFolder(fileName: string, moduleKind: ts.ModuleKind) { @@ -97,9 +98,9 @@ class ProjectRunner extends RunnerBase { } function cleanProjectUrl(url: string) { - var diskProjectPath = ts.normalizeSlashes(ts.sys.resolvePath(testCase.projectRoot)); - var projectRootUrl = "file:///" + diskProjectPath; - var normalizedProjectRoot = ts.normalizeSlashes(testCase.projectRoot); + let diskProjectPath = ts.normalizeSlashes(ts.sys.resolvePath(testCase.projectRoot)); + let projectRootUrl = "file:///" + diskProjectPath; + let normalizedProjectRoot = ts.normalizeSlashes(testCase.projectRoot); diskProjectPath = diskProjectPath.substr(0, diskProjectPath.lastIndexOf(normalizedProjectRoot)); projectRootUrl = projectRootUrl.substr(0, projectRootUrl.lastIndexOf(normalizedProjectRoot)); if (url && url.length) { @@ -124,21 +125,21 @@ class ProjectRunner extends RunnerBase { return ts.sys.resolvePath(testCase.projectRoot); } - function compileProjectFiles(moduleKind: ts.ModuleKind, getInputFiles: ()=> string[], + function compileProjectFiles(moduleKind: ts.ModuleKind, getInputFiles: () => string[], getSourceFileText: (fileName: string) => string, writeFile: (fileName: string, data: string, writeByteOrderMark: boolean) => void): CompileProjectFilesResult { - var program = ts.createProgram(getInputFiles(), createCompilerOptions(), createCompilerHost()); - var errors = ts.getPreEmitDiagnostics(program); + let program = ts.createProgram(getInputFiles(), createCompilerOptions(), createCompilerHost()); + let errors = ts.getPreEmitDiagnostics(program); - var emitResult = program.emit(); + let emitResult = program.emit(); errors = ts.concatenate(errors, emitResult.diagnostics); - var sourceMapData = emitResult.sourceMaps; + let sourceMapData = emitResult.sourceMaps; // Clean up source map data that will be used in baselining if (sourceMapData) { - for (var i = 0; i < sourceMapData.length; i++) { - for (var j = 0; j < sourceMapData[i].sourceMapSources.length; j++) { + for (let i = 0; i < sourceMapData.length; i++) { + for (let j = 0; j < sourceMapData[i].sourceMapSources.length; j++) { sourceMapData[i].sourceMapSources[j] = cleanProjectUrl(sourceMapData[i].sourceMapSources[j]); } sourceMapData[i].jsSourceMappingURL = cleanProjectUrl(sourceMapData[i].jsSourceMappingURL); @@ -168,12 +169,12 @@ class ProjectRunner extends RunnerBase { } function getSourceFile(fileName: string, languageVersion: ts.ScriptTarget): ts.SourceFile { - var sourceFile: ts.SourceFile = undefined; + let sourceFile: ts.SourceFile = undefined; if (fileName === Harness.Compiler.defaultLibFileName) { sourceFile = languageVersion === ts.ScriptTarget.ES6 ? Harness.Compiler.defaultES6LibSourceFile : Harness.Compiler.defaultLibSourceFile; } else { - var text = getSourceFileText(fileName); + let text = getSourceFileText(fileName); if (text !== undefined) { sourceFile = Harness.Compiler.createSourceFileAndAssertInvariants(fileName, text, languageVersion); } @@ -194,13 +195,13 @@ class ProjectRunner extends RunnerBase { }; } } - + function batchCompilerProjectTestCase(moduleKind: ts.ModuleKind): BatchCompileProjectTestCaseResult{ - var nonSubfolderDiskFiles = 0; + let nonSubfolderDiskFiles = 0; - var outputFiles: BatchCompileProjectTestCaseEmittedFile[] = []; + let outputFiles: BatchCompileProjectTestCaseEmittedFile[] = []; - var projectCompilerResult = compileProjectFiles(moduleKind, () => testCase.inputFiles, getSourceFileText, writeFile); + let projectCompilerResult = compileProjectFiles(moduleKind, () => testCase.inputFiles, getSourceFileText, writeFile); return { moduleKind, program: projectCompilerResult.program, @@ -211,8 +212,9 @@ class ProjectRunner extends RunnerBase { }; function getSourceFileText(fileName: string): string { + let text: string = undefined; try { - var text = ts.sys.readFile(ts.isRootedDiskPath(fileName) + text = ts.sys.readFile(ts.isRootedDiskPath(fileName) ? fileName : ts.normalizeSlashes(testCase.projectRoot) + "/" + ts.normalizeSlashes(fileName)); } @@ -223,14 +225,14 @@ class ProjectRunner extends RunnerBase { } function writeFile(fileName: string, data: string, writeByteOrderMark: boolean) { - var diskFileName = ts.isRootedDiskPath(fileName) + let diskFileName = ts.isRootedDiskPath(fileName) ? fileName : ts.normalizeSlashes(testCase.projectRoot) + "/" + ts.normalizeSlashes(fileName); - var diskRelativeName = ts.getRelativePathToDirectoryOrUrl(testCase.projectRoot, diskFileName, + let diskRelativeName = ts.getRelativePathToDirectoryOrUrl(testCase.projectRoot, diskFileName, getCurrentDirectory(), Harness.Compiler.getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); if (ts.isRootedDiskPath(diskRelativeName) || diskRelativeName.substr(0, 3) === "../") { - // If the generated output file resides in the parent folder or is rooted path, + // If the generated output file resides in the parent folder or is rooted path, // we need to instead create files that can live in the project reference folder // but make sure extension of these files matches with the fileName the compiler asked to write diskRelativeName = "diskFile" + nonSubfolderDiskFiles++ + @@ -240,22 +242,22 @@ class ProjectRunner extends RunnerBase { if (Harness.Compiler.isJS(fileName)) { // Make sure if there is URl we have it cleaned up - var indexOfSourceMapUrl = data.lastIndexOf("//# sourceMappingURL="); + let indexOfSourceMapUrl = data.lastIndexOf("//# sourceMappingURL="); if (indexOfSourceMapUrl !== -1) { data = data.substring(0, indexOfSourceMapUrl + 21) + cleanProjectUrl(data.substring(indexOfSourceMapUrl + 21)); } } else if (Harness.Compiler.isJSMap(fileName)) { // Make sure sources list is cleaned - var sourceMapData = JSON.parse(data); - for (var i = 0; i < sourceMapData.sources.length; i++) { + let sourceMapData = JSON.parse(data); + for (let i = 0; i < sourceMapData.sources.length; i++) { sourceMapData.sources[i] = cleanProjectUrl(sourceMapData.sources[i]); } sourceMapData.sourceRoot = cleanProjectUrl(sourceMapData.sourceRoot); data = JSON.stringify(sourceMapData); } - var outputFilePath = getProjectOutputFolder(diskRelativeName, moduleKind); + let outputFilePath = getProjectOutputFolder(diskRelativeName, moduleKind); // Actual writing of file as in tc.ts function ensureDirectoryStructure(directoryname: string) { if (directoryname) { @@ -273,36 +275,37 @@ class ProjectRunner extends RunnerBase { } function compileCompileDTsFiles(compilerResult: BatchCompileProjectTestCaseResult) { - var allInputFiles: { emittedFileName: string; code: string; }[] = []; - var compilerOptions = compilerResult.program.getCompilerOptions(); + let allInputFiles: { emittedFileName: string; code: string; }[] = []; + let compilerOptions = compilerResult.program.getCompilerOptions(); ts.forEach(compilerResult.program.getSourceFiles(), sourceFile => { if (Harness.Compiler.isDTS(sourceFile.fileName)) { allInputFiles.unshift({ emittedFileName: sourceFile.fileName, code: sourceFile.text }); } else if (ts.shouldEmitToOwnFile(sourceFile, compilerResult.program.getCompilerOptions())) { + let emitOutputFilePathWithoutExtension: string = undefined; if (compilerOptions.outDir) { - var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, compilerResult.program.getCurrentDirectory()); + let sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, compilerResult.program.getCurrentDirectory()); sourceFilePath = sourceFilePath.replace(compilerResult.program.getCommonSourceDirectory(), ""); - var emitOutputFilePathWithoutExtension = ts.removeFileExtension(ts.combinePaths(compilerOptions.outDir, sourceFilePath)); + emitOutputFilePathWithoutExtension = ts.removeFileExtension(ts.combinePaths(compilerOptions.outDir, sourceFilePath)); } else { - var emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName); + emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName); } - var outputDtsFileName = emitOutputFilePathWithoutExtension + ".d.ts"; + let outputDtsFileName = emitOutputFilePathWithoutExtension + ".d.ts"; allInputFiles.unshift(findOutpuDtsFile(outputDtsFileName)); } else { - var outputDtsFileName = ts.removeFileExtension(compilerOptions.out) + ".d.ts"; - var outputDtsFile = findOutpuDtsFile(outputDtsFileName); + let outputDtsFileName = ts.removeFileExtension(compilerOptions.out) + ".d.ts"; + let outputDtsFile = findOutpuDtsFile(outputDtsFileName); if (!ts.contains(allInputFiles, outputDtsFile)) { allInputFiles.unshift(outputDtsFile); } } }); - return compileProjectFiles(compilerResult.moduleKind,getInputFiles, getSourceFileText, writeFile); + return compileProjectFiles(compilerResult.moduleKind, getInputFiles, getSourceFileText, writeFile); function findOutpuDtsFile(fileName: string) { return ts.forEach(compilerResult.outputFiles, outputFile => outputFile.emittedFileName === fileName ? outputFile : undefined); @@ -319,7 +322,7 @@ class ProjectRunner extends RunnerBase { } function getErrorsBaseline(compilerResult: CompileProjectFilesResult) { - var inputFiles = ts.map(ts.filter(compilerResult.program.getSourceFiles(), + let inputFiles = ts.map(ts.filter(compilerResult.program.getSourceFiles(), sourceFile => sourceFile.fileName !== "lib.d.ts"), sourceFile => { return { unitName: sourceFile.fileName, content: sourceFile.text }; @@ -328,110 +331,112 @@ class ProjectRunner extends RunnerBase { return Harness.Compiler.getErrorBaseline(inputFiles, compilerResult.errors); } - var name = 'Compiling project for ' + testCase.scenario + ': testcase ' + testCaseFileName; + let name = 'Compiling project for ' + testCase.scenario + ': testcase ' + testCaseFileName; - describe(name, () => { - function verifyCompilerResults(moduleKind: ts.ModuleKind) { - function getCompilerResolutionInfo() { - var resolutionInfo: ProjectRunnerTestCaseResolutionInfo = { - scenario: testCase.scenario, - projectRoot: testCase.projectRoot, - inputFiles: testCase.inputFiles, - out: testCase.out, - outDir: testCase.outDir, - sourceMap: testCase.sourceMap, - mapRoot: testCase.mapRoot, - resolveMapRoot: testCase.resolveMapRoot, - sourceRoot: testCase.sourceRoot, - resolveSourceRoot: testCase.resolveSourceRoot, - declaration: testCase.declaration, - baselineCheck: testCase.baselineCheck, - runTest: testCase.runTest, - bug: testCase.bug, - rootDir: testCase.rootDir, - resolvedInputFiles: ts.map(compilerResult.program.getSourceFiles(), inputFile => inputFile.fileName), - emittedFiles: ts.map(compilerResult.outputFiles, outputFile => outputFile.emittedFileName) - }; + describe('Projects tests', () => { + describe(name, () => { + function verifyCompilerResults(moduleKind: ts.ModuleKind) { + let compilerResult: BatchCompileProjectTestCaseResult; - return resolutionInfo; - } + function getCompilerResolutionInfo() { + let resolutionInfo: ProjectRunnerTestCaseResolutionInfo = { + scenario: testCase.scenario, + projectRoot: testCase.projectRoot, + inputFiles: testCase.inputFiles, + out: testCase.out, + outDir: testCase.outDir, + sourceMap: testCase.sourceMap, + mapRoot: testCase.mapRoot, + resolveMapRoot: testCase.resolveMapRoot, + sourceRoot: testCase.sourceRoot, + resolveSourceRoot: testCase.resolveSourceRoot, + declaration: testCase.declaration, + baselineCheck: testCase.baselineCheck, + runTest: testCase.runTest, + bug: testCase.bug, + rootDir: testCase.rootDir, + resolvedInputFiles: ts.map(compilerResult.program.getSourceFiles(), inputFile => inputFile.fileName), + emittedFiles: ts.map(compilerResult.outputFiles, outputFile => outputFile.emittedFileName) + }; - var compilerResult: BatchCompileProjectTestCaseResult; + return resolutionInfo; + } - it(name + ": " + moduleNameToString(moduleKind) , () => { - // Compile using node - compilerResult = batchCompilerProjectTestCase(moduleKind); - }); - - it('Resolution information of (' + moduleNameToString(moduleKind) + '): ' + testCaseFileName, () => { - Harness.Baseline.runBaseline('Resolution information of (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + '.json', () => { - return JSON.stringify(getCompilerResolutionInfo(), undefined, " "); + it(name + ": " + moduleNameToString(moduleKind) , () => { + // Compile using node + compilerResult = batchCompilerProjectTestCase(moduleKind); }); - }); - - it('Errors for (' + moduleNameToString(moduleKind) + '): ' + testCaseFileName, () => { - if (compilerResult.errors.length) { - Harness.Baseline.runBaseline('Errors for (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + '.errors.txt', () => { - return getErrorsBaseline(compilerResult); + it('Resolution information of (' + moduleNameToString(moduleKind) + '): ' + testCaseFileName, () => { + Harness.Baseline.runBaseline('Resolution information of (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + '.json', () => { + return JSON.stringify(getCompilerResolutionInfo(), undefined, " "); }); - } - }); + }); - it('Baseline of emitted result (' + moduleNameToString(moduleKind) + '): ' + testCaseFileName, () => { - if (testCase.baselineCheck) { - ts.forEach(compilerResult.outputFiles, outputFile => { - - Harness.Baseline.runBaseline('Baseline of emitted result (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + outputFile.fileName, () => { - try { - return ts.sys.readFile(getProjectOutputFolder(outputFile.fileName, compilerResult.moduleKind)); - } - catch (e) { - return undefined; - } - }); - }); - } - }); - - - it('SourceMapRecord for (' + moduleNameToString(moduleKind) + '): ' + testCaseFileName, () => { - if (compilerResult.sourceMapData) { - Harness.Baseline.runBaseline('SourceMapRecord for (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + '.sourcemap.txt', () => { - return Harness.SourceMapRecoder.getSourceMapRecord(compilerResult.sourceMapData, compilerResult.program, - ts.filter(compilerResult.outputFiles, outputFile => Harness.Compiler.isJS(outputFile.emittedFileName))); - }); - } - }); - - // Verify that all the generated .d.ts files compile - - it('Errors in generated Dts files for (' + moduleNameToString(moduleKind) + '): ' + testCaseFileName, () => { - if (!compilerResult.errors.length && testCase.declaration) { - var dTsCompileResult = compileCompileDTsFiles(compilerResult); - if (dTsCompileResult.errors.length) { - Harness.Baseline.runBaseline('Errors in generated Dts files for (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + '.dts.errors.txt', () => { - return getErrorsBaseline(dTsCompileResult); + it('Errors for (' + moduleNameToString(moduleKind) + '): ' + testCaseFileName, () => { + if (compilerResult.errors.length) { + Harness.Baseline.runBaseline('Errors for (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + '.errors.txt', () => { + return getErrorsBaseline(compilerResult); }); } - } - }); + }); + + + it('Baseline of emitted result (' + moduleNameToString(moduleKind) + '): ' + testCaseFileName, () => { + if (testCase.baselineCheck) { + ts.forEach(compilerResult.outputFiles, outputFile => { + + Harness.Baseline.runBaseline('Baseline of emitted result (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + outputFile.fileName, () => { + try { + return ts.sys.readFile(getProjectOutputFolder(outputFile.fileName, compilerResult.moduleKind)); + } + catch (e) { + return undefined; + } + }); + }); + } + }); + + + it('SourceMapRecord for (' + moduleNameToString(moduleKind) + '): ' + testCaseFileName, () => { + if (compilerResult.sourceMapData) { + Harness.Baseline.runBaseline('SourceMapRecord for (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + '.sourcemap.txt', () => { + return Harness.SourceMapRecoder.getSourceMapRecord(compilerResult.sourceMapData, compilerResult.program, + ts.filter(compilerResult.outputFiles, outputFile => Harness.Compiler.isJS(outputFile.emittedFileName))); + }); + } + }); + + // Verify that all the generated .d.ts files compile + + it('Errors in generated Dts files for (' + moduleNameToString(moduleKind) + '): ' + testCaseFileName, () => { + if (!compilerResult.errors.length && testCase.declaration) { + let dTsCompileResult = compileCompileDTsFiles(compilerResult); + if (dTsCompileResult.errors.length) { + Harness.Baseline.runBaseline('Errors in generated Dts files for (' + moduleNameToString(compilerResult.moduleKind) + '): ' + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + '.dts.errors.txt', () => { + return getErrorsBaseline(dTsCompileResult); + }); + } + } + }); + after(() => { + compilerResult = undefined; + }); + } + + verifyCompilerResults(ts.ModuleKind.CommonJS); + verifyCompilerResults(ts.ModuleKind.AMD); + after(() => { - compilerResult = undefined; + // Mocha holds onto the closure environment of the describe callback even after the test is done. + // Therefore we have to clean out large objects after the test is done. + testCase = undefined; + testFileText = undefined; + testCaseJustName = undefined; }); - } - - verifyCompilerResults(ts.ModuleKind.CommonJS); - verifyCompilerResults(ts.ModuleKind.AMD); - - after(() => { - // Mocha holds onto the closure environment of the describe callback even after the test is done. - // Therefore we have to clean out large objects after the test is done. - testCase = undefined; - testFileText = undefined; - testCaseJustName = undefined; }); }); } -} \ No newline at end of file +} diff --git a/src/harness/runner.ts b/src/harness/runner.ts index 13d93302f18..e4ed604e980 100644 --- a/src/harness/runner.ts +++ b/src/harness/runner.ts @@ -1,6 +1,6 @@ // // 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 @@ -20,26 +20,26 @@ /// /// +let runners: RunnerBase[] = []; +let iterations: number = 1; + function runTests(runners: RunnerBase[]) { - for (var i = iterations; i > 0; i--) { - for (var j = 0; j < runners.length; j++) { + for (let i = iterations; i > 0; i--) { + for (let j = 0; j < runners.length; j++) { runners[j].initializeTests(); } } } -var runners: RunnerBase[] = []; -var iterations: number = 1; - // users can define tests to run in mytest.config that will override cmd line args, otherwise use cmd line args (test.config), otherwise no options -var mytestconfig = 'mytest.config'; -var testconfig = 'test.config'; -var testConfigFile = +let mytestconfig = 'mytest.config'; +let testconfig = 'test.config'; +let testConfigFile = Harness.IO.fileExists(mytestconfig) ? Harness.IO.readFile(mytestconfig) : (Harness.IO.fileExists(testconfig) ? Harness.IO.readFile(testconfig) : ''); if (testConfigFile !== '') { - var testConfig = JSON.parse(testConfigFile); + let testConfig = JSON.parse(testConfigFile); if (testConfig.light) { Harness.lightMode = true; } @@ -99,7 +99,7 @@ if (runners.length === 0) { runners.push(new FourSlashRunner(FourSlashTestType.Native)); runners.push(new FourSlashRunner(FourSlashTestType.Shims)); runners.push(new FourSlashRunner(FourSlashTestType.Server)); - //runners.push(new GeneratedFourslashRunner()); + // runners.push(new GeneratedFourslashRunner()); } ts.sys.newLine = '\r\n'; diff --git a/src/harness/runnerbase.ts b/src/harness/runnerbase.ts index fa8d9d2c597..66438d938dd 100644 --- a/src/harness/runnerbase.ts +++ b/src/harness/runnerbase.ts @@ -24,17 +24,17 @@ class RunnerBase { /** Replaces instances of full paths with fileNames only */ static removeFullPaths(path: string) { - var fixedPath = path; + let fixedPath = path; // full paths either start with a drive letter or / for *nix, shouldn't have \ in the path at this point - var fullPath = /(\w+:|\/)?([\w+\-\.]|\/)*\.tsx?/g; - var fullPathList = fixedPath.match(fullPath); + let fullPath = /(\w+:|\/)?([\w+\-\.]|\/)*\.tsx?/g; + let fullPathList = fixedPath.match(fullPath); if (fullPathList) { fullPathList.forEach((match: string) => fixedPath = fixedPath.replace(match, Harness.Path.getFileName(match))); } // when running in the browser the 'full path' is the host name, shows up in error baselines - var localHost = /http:\/localhost:\d+/g; + let localHost = /http:\/localhost:\d+/g; fixedPath = fixedPath.replace(localHost, ''); return fixedPath; } diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index 43a118b6aec..bbe80abc887 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -5,9 +5,9 @@ module RWC { function runWithIOLog(ioLog: IOLog, fn: () => void) { - var oldSys = ts.sys; + let oldSys = ts.sys; - var wrappedSys = Playback.wrapSystem(ts.sys); + let wrappedSys = Playback.wrapSystem(ts.sys); wrappedSys.startReplayFromData(ioLog); ts.sys = wrappedSys; @@ -21,17 +21,17 @@ module RWC { export function runRWCTest(jsonPath: string) { describe("Testing a RWC project: " + jsonPath, () => { - var inputFiles: { unitName: string; content: string; }[] = []; - var otherFiles: { unitName: string; content: string; }[] = []; - var compilerResult: Harness.Compiler.CompilerResult; - var compilerOptions: ts.CompilerOptions; - var baselineOpts: Harness.Baseline.BaselineOptions = { + let inputFiles: { unitName: string; content: string; }[] = []; + let otherFiles: { unitName: string; content: string; }[] = []; + let compilerResult: Harness.Compiler.CompilerResult; + let compilerOptions: ts.CompilerOptions; + let baselineOpts: Harness.Baseline.BaselineOptions = { Subfolder: 'rwc', Baselinefolder: 'internal/baselines' }; - var baseName = /(.*)\/(.*).json/.exec(ts.normalizeSlashes(jsonPath))[2]; - var currentDirectory: string; - var useCustomLibraryFile: boolean; + let baseName = /(.*)\/(.*).json/.exec(ts.normalizeSlashes(jsonPath))[2]; + let currentDirectory: string; + let useCustomLibraryFile: boolean; after(() => { // Mocha holds onto the closure environment of the describe callback even after the test is done. @@ -50,10 +50,10 @@ module RWC { }); it('can compile', () => { - var harnessCompiler = Harness.Compiler.getCompiler(); - var opts: ts.ParsedCommandLine; + let harnessCompiler = Harness.Compiler.getCompiler(); + let opts: ts.ParsedCommandLine; - var ioLog: IOLog = JSON.parse(Harness.IO.readFile(jsonPath)); + let ioLog: IOLog = JSON.parse(Harness.IO.readFile(jsonPath)); currentDirectory = ioLog.currentDirectory; useCustomLibraryFile = ioLog.useCustomLibraryFile; runWithIOLog(ioLog, () => { @@ -77,7 +77,7 @@ module RWC { for (let fileRead of ioLog.filesRead) { // Check if the file is already added into the set of input files. var resolvedPath = ts.normalizeSlashes(ts.sys.resolvePath(fileRead.path)); - var inInputList = ts.forEach(inputFiles, inputFile => inputFile.unitName === resolvedPath); + let inInputList = ts.forEach(inputFiles, inputFile => inputFile.unitName === resolvedPath); if (!Harness.isLibraryFile(fileRead.path)) { if (inInputList) { @@ -117,9 +117,10 @@ module RWC { }); function getHarnessCompilerInputUnit(fileName: string) { - var unitName = ts.normalizeSlashes(ts.sys.resolvePath(fileName)); + let unitName = ts.normalizeSlashes(ts.sys.resolvePath(fileName)); + let content: string = null; try { - var content = ts.sys.readFile(unitName); + content = ts.sys.readFile(unitName); } catch (e) { // Leave content undefined. @@ -155,13 +156,13 @@ module RWC { }, false, baselineOpts); }); - //it('has correct source map record', () => { - // if (compilerOptions.sourceMap) { - // Harness.Baseline.runBaseline('has correct source map record', baseName + '.sourcemap.txt', () => { - // return compilerResult.getSourceMapRecord(); - // }, false, baselineOpts); - // } - //}); + /*it('has correct source map record', () => { + if (compilerOptions.sourceMap) { + Harness.Baseline.runBaseline('has correct source map record', baseName + '.sourcemap.txt', () => { + return compilerResult.getSourceMapRecord(); + }, false, baselineOpts); + } + });*/ it('has the expected errors', () => { Harness.Baseline.runBaseline('has the expected errors', baseName + '.errors.txt', () => { @@ -178,7 +179,7 @@ module RWC { it('has the expected errors in generated declaration files', () => { if (compilerOptions.declaration && !compilerResult.errors.length) { Harness.Baseline.runBaseline('has the expected errors in generated declaration files', baseName + '.dts.errors.txt', () => { - var declFileCompilationResult = Harness.Compiler.getCompiler().compileDeclarationFiles(inputFiles, otherFiles, compilerResult, + let declFileCompilationResult = Harness.Compiler.getCompiler().compileDeclarationFiles(inputFiles, otherFiles, compilerResult, /*settingscallback*/ undefined, compilerOptions, currentDirectory); if (declFileCompilationResult.declResult.errors.length === 0) { return null; @@ -204,8 +205,8 @@ class RWCRunner extends RunnerBase { */ public initializeTests(): void { // Read in and evaluate the test list - var testList = Harness.IO.listFiles(RWCRunner.sourcePath, /.+\.json$/); - for (var i = 0; i < testList.length; i++) { + let testList = Harness.IO.listFiles(RWCRunner.sourcePath, /.+\.json$/); + for (let i = 0; i < testList.length; i++) { this.runTest(testList[i]); } } diff --git a/src/harness/sourceMapRecorder.ts b/src/harness/sourceMapRecorder.ts index ed079774d94..767dd37949f 100644 --- a/src/harness/sourceMapRecorder.ts +++ b/src/harness/sourceMapRecorder.ts @@ -1,6 +1,6 @@ // // 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 @@ -23,12 +23,12 @@ module Harness.SourceMapRecoder { } module SourceMapDecoder { - var sourceMapMappings: string; - var sourceMapNames: string[]; - var decodingIndex: number; - var prevNameIndex: number; - var decodeOfEncodedMapping: ts.SourceMapSpan; - var errorDecodeOfEncodedMapping: string; + let sourceMapMappings: string; + let sourceMapNames: string[]; + let decodingIndex: number; + let prevNameIndex: number; + let decodeOfEncodedMapping: ts.SourceMapSpan; + let errorDecodeOfEncodedMapping: string; export function initializeSourceMapDecoding(sourceMapData: ts.SourceMapData) { sourceMapMappings = sourceMapData.sourceMapMappings; @@ -82,9 +82,9 @@ module Harness.SourceMapRecoder { return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(sourceMapMappings.charAt(decodingIndex)); } - var moreDigits = true; - var shiftCount = 0; - var value = 0; + let moreDigits = true; + let shiftCount = 0; + let value = 0; for (; moreDigits; decodingIndex++) { if (createErrorIfCondition(decodingIndex >= sourceMapMappings.length, "Error in decoding base64VLQFormatDecode, past the mapping string")) { @@ -92,7 +92,7 @@ module Harness.SourceMapRecoder { } // 6 digit number - var currentByte = base64FormatDecode(); + let currentByte = base64FormatDecode(); // If msb is set, we still have more bits to continue moreDigits = (currentByte & 32) !== 0; @@ -143,7 +143,7 @@ module Harness.SourceMapRecoder { return { error: errorDecodeOfEncodedMapping, sourceMapSpan: decodeOfEncodedMapping }; } - // 2. Relative sourceIndex + // 2. Relative sourceIndex decodeOfEncodedMapping.sourceIndex += base64VLQFormatDecode(); // Incorrect sourceIndex dont support this map if (createErrorIfCondition(decodeOfEncodedMapping.sourceIndex < 0, "Invalid sourceIndex found")) { @@ -165,7 +165,7 @@ module Harness.SourceMapRecoder { return { error: errorDecodeOfEncodedMapping, sourceMapSpan: decodeOfEncodedMapping }; } - // 4. Relative sourceColumn 0 based + // 4. Relative sourceColumn 0 based decodeOfEncodedMapping.sourceColumn += base64VLQFormatDecode(); // Incorrect sourceColumn dont support this map if (createErrorIfCondition(decodeOfEncodedMapping.sourceColumn < 1, "Invalid sourceLine found")) { @@ -203,19 +203,19 @@ module Harness.SourceMapRecoder { } module SourceMapSpanWriter { - var sourceMapRecoder: Compiler.WriterAggregator; - var sourceMapSources: string[]; - var sourceMapNames: string[]; + let sourceMapRecoder: Compiler.WriterAggregator; + let sourceMapSources: string[]; + let sourceMapNames: string[]; - var jsFile: Compiler.GeneratedFile; - var jsLineMap: number[]; - var tsCode: string; - var tsLineMap: number[]; + let jsFile: Compiler.GeneratedFile; + let jsLineMap: number[]; + let tsCode: string; + let tsLineMap: number[]; - var spansOnSingleLine: SourceMapSpanWithDecodeErrors[]; - var prevWrittenSourcePos: number; - var prevWrittenJsLine: number; - var spanMarkerContinues: boolean; + let spansOnSingleLine: SourceMapSpanWithDecodeErrors[]; + let prevWrittenSourcePos: number; + let prevWrittenJsLine: number; + let spanMarkerContinues: boolean; export function intializeSourceMapSpanWriter(sourceMapRecordWriter: Compiler.WriterAggregator, sourceMapData: ts.SourceMapData, currentJsFile: Compiler.GeneratedFile) { sourceMapRecoder = sourceMapRecordWriter; @@ -244,7 +244,7 @@ module Harness.SourceMapRecoder { } function getSourceMapSpanString(mapEntry: ts.SourceMapSpan, getAbsentNameIndex?: boolean) { - var mapString = "Emitted(" + mapEntry.emittedLine + ", " + mapEntry.emittedColumn + ") Source(" + mapEntry.sourceLine + ", " + mapEntry.sourceColumn + ") + SourceIndex(" + mapEntry.sourceIndex + ")"; + let mapString = "Emitted(" + mapEntry.emittedLine + ", " + mapEntry.emittedColumn + ") Source(" + mapEntry.sourceLine + ", " + mapEntry.sourceColumn + ") + SourceIndex(" + mapEntry.sourceIndex + ")"; if (mapEntry.nameIndex >= 0 && mapEntry.nameIndex < sourceMapNames.length) { mapString += " name (" + sourceMapNames[mapEntry.nameIndex] + ")"; } @@ -259,8 +259,8 @@ module Harness.SourceMapRecoder { export function recordSourceMapSpan(sourceMapSpan: ts.SourceMapSpan) { // verify the decoded span is same as the new span - var decodeResult = SourceMapDecoder.decodeNextEncodedSourceMapSpan(); - var decodedErrors: string[]; + let decodeResult = SourceMapDecoder.decodeNextEncodedSourceMapSpan(); + let decodedErrors: string[]; if (decodeResult.error || decodeResult.sourceMapSpan.emittedLine !== sourceMapSpan.emittedLine || decodeResult.sourceMapSpan.emittedColumn !== sourceMapSpan.emittedColumn @@ -278,7 +278,7 @@ module Harness.SourceMapRecoder { } if (spansOnSingleLine.length && spansOnSingleLine[0].sourceMapSpan.emittedLine !== sourceMapSpan.emittedLine) { - // On different line from the one that we have been recording till now, + // On different line from the one that we have been recording till now, writeRecordedSpans(); spansOnSingleLine = [{ sourceMapSpan: sourceMapSpan, decodeErrors: decodedErrors }]; } @@ -317,8 +317,8 @@ module Harness.SourceMapRecoder { } function getTextOfLine(line: number, lineMap: number[], code: string) { - var startPos = lineMap[line]; - var endPos = lineMap[line + 1]; + let startPos = lineMap[line]; + let endPos = lineMap[line + 1]; return code.substring(startPos, endPos); } @@ -329,14 +329,16 @@ module Harness.SourceMapRecoder { } function writeRecordedSpans() { + let markerIds: string[] = []; + function getMarkerId(markerIndex: number) { - var markerId = ""; + let markerId = ""; if (spanMarkerContinues) { assert.isTrue(markerIndex === 0); markerId = "1->"; } else { - var markerId = "" + (markerIndex + 1); + markerId = "" + (markerIndex + 1); if (markerId.length < 2) { markerId = markerId + " "; } @@ -345,10 +347,10 @@ module Harness.SourceMapRecoder { return markerId; } - var prevEmittedCol: number; + let prevEmittedCol: number; function iterateSpans(fn: (currentSpan: SourceMapSpanWithDecodeErrors, index: number) => void) { prevEmittedCol = 1; - for (var i = 0; i < spansOnSingleLine.length; i++) { + for (let i = 0; i < spansOnSingleLine.length; i++) { fn(spansOnSingleLine[i], i); prevEmittedCol = spansOnSingleLine[i].sourceMapSpan.emittedColumn; } @@ -356,18 +358,18 @@ module Harness.SourceMapRecoder { function writeSourceMapIndent(indentLength: number, indentPrefix: string) { sourceMapRecoder.Write(indentPrefix); - for (var i = 1; i < indentLength; i++) { + for (let i = 1; i < indentLength; i++) { sourceMapRecoder.Write(" "); } } function writeSourceMapMarker(currentSpan: SourceMapSpanWithDecodeErrors, index: number, endColumn = currentSpan.sourceMapSpan.emittedColumn, endContinues?: boolean) { - var markerId = getMarkerId(index); + let markerId = getMarkerId(index); markerIds.push(markerId); writeSourceMapIndent(prevEmittedCol, markerId); - for (var i = prevEmittedCol; i < endColumn; i++) { + for (let i = prevEmittedCol; i < endColumn; i++) { sourceMapRecoder.Write("^"); } if (endContinues) { @@ -378,8 +380,8 @@ module Harness.SourceMapRecoder { } function writeSourceMapSourceText(currentSpan: SourceMapSpanWithDecodeErrors, index: number) { - var sourcePos = tsLineMap[currentSpan.sourceMapSpan.sourceLine - 1] + (currentSpan.sourceMapSpan.sourceColumn - 1); - var sourceText = ""; + let sourcePos = tsLineMap[currentSpan.sourceMapSpan.sourceLine - 1] + (currentSpan.sourceMapSpan.sourceColumn - 1); + let sourceText = ""; if (prevWrittenSourcePos < sourcePos) { // Position that goes forward, get text sourceText = tsCode.substring(prevWrittenSourcePos, sourcePos); @@ -387,14 +389,14 @@ module Harness.SourceMapRecoder { if (currentSpan.decodeErrors) { // If there are decode errors, write - for (var i = 0; i < currentSpan.decodeErrors.length; i++) { + for (let i = 0; i < currentSpan.decodeErrors.length; i++) { writeSourceMapIndent(prevEmittedCol, markerIds[index]); sourceMapRecoder.WriteLine(currentSpan.decodeErrors[i]); } } - var tsCodeLineMap = ts.computeLineStarts(sourceText); - for (var i = 0; i < tsCodeLineMap.length; i++) { + let tsCodeLineMap = ts.computeLineStarts(sourceText); + for (let i = 0; i < tsCodeLineMap.length; i++) { writeSourceMapIndent(prevEmittedCol, i === 0 ? markerIds[index] : " >"); sourceMapRecoder.Write(getTextOfLine(i, tsCodeLineMap, sourceText)); if (i === tsCodeLineMap.length - 1) { @@ -410,16 +412,15 @@ module Harness.SourceMapRecoder { } if (spansOnSingleLine.length) { - var currentJsLine = spansOnSingleLine[0].sourceMapSpan.emittedLine; + let currentJsLine = spansOnSingleLine[0].sourceMapSpan.emittedLine; // Write js line writeJsFileLines(currentJsLine); // Emit markers - var markerIds: string[] = []; iterateSpans(writeSourceMapMarker); - var jsFileText = getTextOfLine(currentJsLine, jsLineMap, jsFile.code); + let jsFileText = getTextOfLine(currentJsLine, jsLineMap, jsFile.code); if (prevEmittedCol < jsFileText.length) { // There is remaining text on this line that will be part of next source span so write marker that continues writeSourceMapMarker(undefined, spansOnSingleLine.length, /*endColumn*/ jsFileText.length, /*endContinues*/ true); @@ -437,16 +438,16 @@ module Harness.SourceMapRecoder { } export function getSourceMapRecord(sourceMapDataList: ts.SourceMapData[], program: ts.Program, jsFiles: Compiler.GeneratedFile[]) { - var sourceMapRecoder = new Compiler.WriterAggregator(); + let sourceMapRecoder = new Compiler.WriterAggregator(); - for (var i = 0; i < sourceMapDataList.length; i++) { - var sourceMapData = sourceMapDataList[i]; - var prevSourceFile: ts.SourceFile = null; + for (let i = 0; i < sourceMapDataList.length; i++) { + let sourceMapData = sourceMapDataList[i]; + let prevSourceFile: ts.SourceFile = null; SourceMapSpanWriter.intializeSourceMapSpanWriter(sourceMapRecoder, sourceMapData, jsFiles[i]); - for (var j = 0; j < sourceMapData.sourceMapDecodedMappings.length; j++) { - var decodedSourceMapping = sourceMapData.sourceMapDecodedMappings[j]; - var currentSourceFile = program.getSourceFile(sourceMapData.inputSourceFileNames[decodedSourceMapping.sourceIndex]); + for (let j = 0; j < sourceMapData.sourceMapDecodedMappings.length; j++) { + let decodedSourceMapping = sourceMapData.sourceMapDecodedMappings[j]; + let currentSourceFile = program.getSourceFile(sourceMapData.inputSourceFileNames[decodedSourceMapping.sourceIndex]); if (currentSourceFile !== prevSourceFile) { SourceMapSpanWriter.recordNewSourceFileSpan(decodedSourceMapping, currentSourceFile.text); prevSourceFile = currentSourceFile; @@ -455,7 +456,7 @@ module Harness.SourceMapRecoder { SourceMapSpanWriter.recordSourceMapSpan(decodedSourceMapping); } } - SourceMapSpanWriter.close();// If the last spans werent emitted, emit them + SourceMapSpanWriter.close(); // If the last spans werent emitted, emit them } sourceMapRecoder.Close(); return sourceMapRecoder.lines.join('\r\n'); diff --git a/src/harness/test262Runner.ts b/src/harness/test262Runner.ts index 5f8250c5e23..e34e58844ac 100644 --- a/src/harness/test262Runner.ts +++ b/src/harness/test262Runner.ts @@ -27,7 +27,7 @@ class Test262BaselineRunner extends RunnerBase { describe('test262 test for ' + filePath, () => { // Mocha holds onto the closure environment of the describe callback even after the test is done. // Everything declared here should be cleared out in the "after" callback. - var testState: { + let testState: { filename: string; compilerResult: Harness.Compiler.CompilerResult; inputFiles: { unitName: string; content: string }[]; @@ -35,11 +35,11 @@ class Test262BaselineRunner extends RunnerBase { }; before(() => { - var content = Harness.IO.readFile(filePath); - var testFilename = ts.removeFileExtension(filePath).replace(/\//g, '_') + ".test"; - var testCaseContent = Harness.TestCaseParser.makeUnitsFromTest(content, testFilename); + let content = Harness.IO.readFile(filePath); + let testFilename = ts.removeFileExtension(filePath).replace(/\//g, '_') + ".test"; + let testCaseContent = Harness.TestCaseParser.makeUnitsFromTest(content, testFilename); - var inputFiles = testCaseContent.testUnitData.map(unit => { + let inputFiles = testCaseContent.testUnitData.map(unit => { return { unitName: Test262BaselineRunner.getTestFilePath(unit.name), content: unit.content }; }); @@ -63,14 +63,14 @@ class Test262BaselineRunner extends RunnerBase { it('has the expected emitted code', () => { Harness.Baseline.runBaseline('has the expected emitted code', testState.filename + '.output.js', () => { - var files = testState.compilerResult.files.filter(f=> f.fileName !== Test262BaselineRunner.helpersFilePath); + let files = testState.compilerResult.files.filter(f => f.fileName !== Test262BaselineRunner.helpersFilePath); return Harness.Compiler.collateOutputs(files); }, false, Test262BaselineRunner.baselineOptions); }); it('has the expected errors', () => { Harness.Baseline.runBaseline('has the expected errors', testState.filename + '.errors.txt', () => { - var errors = testState.compilerResult.errors; + let errors = testState.compilerResult.errors; if (errors.length === 0) { return null; } @@ -79,14 +79,14 @@ class Test262BaselineRunner extends RunnerBase { }, false, Test262BaselineRunner.baselineOptions); }); - it('satisfies invariants', () => { - var sourceFile = testState.program.getSourceFile(Test262BaselineRunner.getTestFilePath(testState.filename)); + it('satisfies inletiants', () => { + let sourceFile = testState.program.getSourceFile(Test262BaselineRunner.getTestFilePath(testState.filename)); Utils.assertInvariants(sourceFile, /*parent:*/ undefined); }); - it('has the expected AST',() => { - Harness.Baseline.runBaseline('has the expected AST', testState.filename + '.AST.txt',() => { - var sourceFile = testState.program.getSourceFile(Test262BaselineRunner.getTestFilePath(testState.filename)); + it('has the expected AST', () => { + Harness.Baseline.runBaseline('has the expected AST', testState.filename + '.AST.txt', () => { + let sourceFile = testState.program.getSourceFile(Test262BaselineRunner.getTestFilePath(testState.filename)); return Utils.sourceFileToJSON(sourceFile); }, false, Test262BaselineRunner.baselineOptions); }); @@ -96,7 +96,7 @@ class Test262BaselineRunner extends RunnerBase { public initializeTests() { // this will set up a series of describe/it blocks to run between the setup and cleanup phases if (this.tests.length === 0) { - var testFiles = this.enumerateFiles(Test262BaselineRunner.basePath, Test262BaselineRunner.testFileExtensionRegex, { recursive: true }); + let testFiles = this.enumerateFiles(Test262BaselineRunner.basePath, Test262BaselineRunner.testFileExtensionRegex, { recursive: true }); testFiles.forEach(fn => { this.runTest(ts.normalizePath(fn)); }); @@ -105,4 +105,4 @@ class Test262BaselineRunner extends RunnerBase { this.tests.forEach(test => this.runTest(test)); } } -} \ No newline at end of file +} diff --git a/src/harness/typeWriter.ts b/src/harness/typeWriter.ts index b68e606c79d..27cb3574473 100644 --- a/src/harness/typeWriter.ts +++ b/src/harness/typeWriter.ts @@ -13,7 +13,7 @@ class TypeWriterWalker { private checker: ts.TypeChecker; constructor(private program: ts.Program, fullTypeCheck: boolean) { - // Consider getting both the diagnostics checker and the non-diagnostics checker to verify + // Consider getting both the diagnostics checker and the non-diagnostics checker to verify // they are consistent. this.checker = fullTypeCheck ? program.getDiagnosticsProducingTypeChecker() @@ -21,7 +21,7 @@ class TypeWriterWalker { } public getTypeAndSymbols(fileName: string): TypeWriterResult[] { - var sourceFile = this.program.getSourceFile(fileName); + let sourceFile = this.program.getSourceFile(fileName); this.currentSourceFile = sourceFile; this.results = []; this.visitNode(sourceFile); @@ -37,19 +37,19 @@ class TypeWriterWalker { } private logTypeAndSymbol(node: ts.Node): void { - var actualPos = ts.skipTrivia(this.currentSourceFile.text, node.pos); - var lineAndCharacter = this.currentSourceFile.getLineAndCharacterOfPosition(actualPos); - var sourceText = ts.getTextOfNodeFromSourceText(this.currentSourceFile.text, node); + let actualPos = ts.skipTrivia(this.currentSourceFile.text, node.pos); + let lineAndCharacter = this.currentSourceFile.getLineAndCharacterOfPosition(actualPos); + let sourceText = ts.getTextOfNodeFromSourceText(this.currentSourceFile.text, node); // Workaround to ensure we output 'C' instead of 'typeof C' for base class expressions - // var type = this.checker.getTypeAtLocation(node); - var type = node.parent && ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent) && this.checker.getTypeAtLocation(node.parent) || this.checker.getTypeAtLocation(node); + // let type = this.checker.getTypeAtLocation(node); + let type = node.parent && ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent) && this.checker.getTypeAtLocation(node.parent) || this.checker.getTypeAtLocation(node); ts.Debug.assert(type !== undefined, "type doesn't exist"); - var symbol = this.checker.getSymbolAtLocation(node); + let symbol = this.checker.getSymbolAtLocation(node); - var typeString = this.checker.typeToString(type, node.parent, ts.TypeFormatFlags.NoTruncation); - var symbolString: string; + let typeString = this.checker.typeToString(type, node.parent, ts.TypeFormatFlags.NoTruncation); + let symbolString: string; if (symbol) { symbolString = "Symbol(" + this.checker.symbolToString(symbol, node.parent); if (symbol.declarations) { @@ -57,7 +57,7 @@ class TypeWriterWalker { symbolString += ", "; let declSourceFile = declaration.getSourceFile(); let declLineAndCharacter = declSourceFile.getLineAndCharacterOfPosition(declaration.pos); - symbolString += `Decl(${ ts.getBaseFileName(declSourceFile.fileName) }, ${ declLineAndCharacter.line }, ${ declLineAndCharacter.character })` + symbolString += `Decl(${ ts.getBaseFileName(declSourceFile.fileName) }, ${ declLineAndCharacter.line }, ${ declLineAndCharacter.character })`; } } symbolString += ")"; diff --git a/src/server/session.ts b/src/server/session.ts index c95b1a7cc1b..e0c540db18b 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -839,6 +839,127 @@ namespace ts.server { exit() { } + private handlers : Map<(request: protocol.Request) => {response?: any, responseRequired?: boolean}> = { + [CommandNames.Exit]: () => { + this.exit(); + return {}; + }, + [CommandNames.Definition]: (request: protocol.Request) => { + var defArgs = request.arguments; + return {response: this.getDefinition(defArgs.line, defArgs.offset, defArgs.file)}; + }, + [CommandNames.TypeDefinition]: (request: protocol.Request) => { + var defArgs = request.arguments; + return {response: this.getTypeDefinition(defArgs.line, defArgs.offset, defArgs.file)}; + }, + [CommandNames.References]: (request: protocol.Request) => { + var defArgs = request.arguments; + return {response: this.getReferences(defArgs.line, defArgs.offset, defArgs.file)}; + }, + [CommandNames.Rename]: (request: protocol.Request) => { + var renameArgs = request.arguments; + return {response: this.getRenameLocations(renameArgs.line, renameArgs.offset, renameArgs.file, renameArgs.findInComments, renameArgs.findInStrings)} + }, + [CommandNames.Open]: (request: protocol.Request) => { + var openArgs = request.arguments; + this.openClientFile(openArgs.file); + return {} + }, + [CommandNames.Quickinfo]: (request: protocol.Request) => { + var quickinfoArgs = request.arguments; + return {response: this.getQuickInfo(quickinfoArgs.line, quickinfoArgs.offset, quickinfoArgs.file)}; + }, + [CommandNames.Format]: (request: protocol.Request) => { + var formatArgs = request.arguments; + return {response: this.getFormattingEditsForRange(formatArgs.line, formatArgs.offset, formatArgs.endLine, formatArgs.endOffset, formatArgs.file)}; + }, + [CommandNames.Formatonkey]: (request: protocol.Request) => { + var formatOnKeyArgs = request.arguments; + return {response: this.getFormattingEditsAfterKeystroke(formatOnKeyArgs.line, formatOnKeyArgs.offset, formatOnKeyArgs.key, formatOnKeyArgs.file)}; + }, + [CommandNames.Completions]: (request: protocol.Request) => { + var completionsArgs = request.arguments; + return {response: this.getCompletions(completionsArgs.line, completionsArgs.offset, completionsArgs.prefix, completionsArgs.file)} + }, + [CommandNames.CompletionDetails]: (request: protocol.Request) => { + var completionDetailsArgs = request.arguments; + return {response: this.getCompletionEntryDetails(completionDetailsArgs.line,completionDetailsArgs.offset, + completionDetailsArgs.entryNames,completionDetailsArgs.file)} + }, + [CommandNames.SignatureHelp]: (request: protocol.Request) => { + var signatureHelpArgs = request.arguments; + return {response: this.getSignatureHelpItems(signatureHelpArgs.line, signatureHelpArgs.offset, signatureHelpArgs.file)} + }, + [CommandNames.Geterr]: (request: protocol.Request) => { + var geterrArgs = request.arguments; + return {response: this.getDiagnostics(geterrArgs.delay, geterrArgs.files), responseRequired: false}; + }, + [CommandNames.Change]: (request: protocol.Request) => { + var changeArgs = request.arguments; + this.change(changeArgs.line, changeArgs.offset, changeArgs.endLine, changeArgs.endOffset, + changeArgs.insertString, changeArgs.file); + return {responseRequired: false} + }, + [CommandNames.Configure]: (request: protocol.Request) => { + var configureArgs = request.arguments; + this.projectService.setHostConfiguration(configureArgs); + this.output(undefined, CommandNames.Configure, request.seq); + return {responseRequired: false} + }, + [CommandNames.Reload]: (request: protocol.Request) => { + var reloadArgs = request.arguments; + this.reload(reloadArgs.file, reloadArgs.tmpfile, request.seq); + return {responseRequired: false} + }, + [CommandNames.Saveto]: (request: protocol.Request) => { + var savetoArgs = request.arguments; + this.saveToTmp(savetoArgs.file, savetoArgs.tmpfile); + return {responseRequired: false} + }, + [CommandNames.Close]: (request: protocol.Request) => { + var closeArgs = request.arguments; + this.closeClientFile(closeArgs.file); + return {responseRequired: false}; + }, + [CommandNames.Navto]: (request: protocol.Request) => { + var navtoArgs = request.arguments; + return {response: this.getNavigateToItems(navtoArgs.searchValue, navtoArgs.file, navtoArgs.maxResultCount)}; + }, + [CommandNames.Brace]: (request: protocol.Request) => { + var braceArguments = request.arguments; + return {response: this.getBraceMatching(braceArguments.line, braceArguments.offset, braceArguments.file)}; + }, + [CommandNames.NavBar]: (request: protocol.Request) => { + var navBarArgs = request.arguments; + return {response: this.getNavigationBarItems(navBarArgs.file)}; + }, + [CommandNames.Occurrences]: (request: protocol.Request) => { + var { line, offset, file: fileName } = request.arguments; + return {response: this.getOccurrences(line, offset, fileName)}; + }, + [CommandNames.ProjectInfo]: (request: protocol.Request) => { + var { file, needFileNameList } = request.arguments; + return {response: this.getProjectInfo(file, needFileNameList)}; + }, + }; + addProtocolHandler(command: string, handler: (request: protocol.Request) => {response?: any, responseRequired: boolean}) { + if (this.handlers[command]) { + throw new Error(`Protocol handler already exists for command "${command}"`); + } + this.handlers[command] = handler; + } + + executeCommand(request: protocol.Request) : {response?: any, responseRequired?: boolean} { + var handler = this.handlers[request.command]; + if (handler) { + return handler(request); + } else { + this.projectService.log("Unrecognized JSON command: " + JSON.stringify(request)); + this.output(undefined, CommandNames.Unknown, request.seq, "Unrecognized JSON command: " + request.command); + return {responseRequired: false}; + } + } + onMessage(message: string) { if (this.logger.isVerbose()) { this.logger.info("request: " + message); @@ -846,142 +967,7 @@ namespace ts.server { } try { var request = JSON.parse(message); - var response: any; - var errorMessage: string; - var responseRequired = true; - switch (request.command) { - case CommandNames.Exit: { - this.exit(); - responseRequired = false; - break; - } - case CommandNames.Definition: { - var defArgs = request.arguments; - response = this.getDefinition(defArgs.line, defArgs.offset, defArgs.file); - break; - } - case CommandNames.TypeDefinition: { - var defArgs = request.arguments; - response = this.getTypeDefinition(defArgs.line, defArgs.offset, defArgs.file); - break; - } - case CommandNames.References: { - var refArgs = request.arguments; - response = this.getReferences(refArgs.line, refArgs.offset, refArgs.file); - break; - } - case CommandNames.Rename: { - var renameArgs = request.arguments; - response = this.getRenameLocations(renameArgs.line, renameArgs.offset, renameArgs.file, renameArgs.findInComments, renameArgs.findInStrings); - break; - } - case CommandNames.Open: { - var openArgs = request.arguments; - this.openClientFile(openArgs.file); - responseRequired = false; - break; - } - case CommandNames.Quickinfo: { - var quickinfoArgs = request.arguments; - response = this.getQuickInfo(quickinfoArgs.line, quickinfoArgs.offset, quickinfoArgs.file); - break; - } - case CommandNames.Format: { - var formatArgs = request.arguments; - response = this.getFormattingEditsForRange(formatArgs.line, formatArgs.offset, formatArgs.endLine, formatArgs.endOffset, formatArgs.file); - break; - } - case CommandNames.Formatonkey: { - var formatOnKeyArgs = request.arguments; - response = this.getFormattingEditsAfterKeystroke(formatOnKeyArgs.line, formatOnKeyArgs.offset, formatOnKeyArgs.key, formatOnKeyArgs.file); - break; - } - case CommandNames.Completions: { - var completionsArgs = request.arguments; - response = this.getCompletions(completionsArgs.line, completionsArgs.offset, completionsArgs.prefix, completionsArgs.file); - break; - } - case CommandNames.CompletionDetails: { - var completionDetailsArgs = request.arguments; - response = - this.getCompletionEntryDetails(completionDetailsArgs.line,completionDetailsArgs.offset, - completionDetailsArgs.entryNames,completionDetailsArgs.file); - break; - } - case CommandNames.SignatureHelp: { - var signatureHelpArgs = request.arguments; - response = this.getSignatureHelpItems(signatureHelpArgs.line, signatureHelpArgs.offset, signatureHelpArgs.file); - break; - } - case CommandNames.Geterr: { - var geterrArgs = request.arguments; - response = this.getDiagnostics(geterrArgs.delay, geterrArgs.files); - responseRequired = false; - break; - } - case CommandNames.Change: { - var changeArgs = request.arguments; - this.change(changeArgs.line, changeArgs.offset, changeArgs.endLine, changeArgs.endOffset, - changeArgs.insertString, changeArgs.file); - responseRequired = false; - break; - } - case CommandNames.Configure: { - var configureArgs = request.arguments; - this.projectService.setHostConfiguration(configureArgs); - this.output(undefined, CommandNames.Configure, request.seq); - responseRequired = false; - break; - } - case CommandNames.Reload: { - var reloadArgs = request.arguments; - this.reload(reloadArgs.file, reloadArgs.tmpfile, request.seq); - responseRequired = false; - break; - } - case CommandNames.Saveto: { - var savetoArgs = request.arguments; - this.saveToTmp(savetoArgs.file, savetoArgs.tmpfile); - responseRequired = false; - break; - } - case CommandNames.Close: { - var closeArgs = request.arguments; - this.closeClientFile(closeArgs.file); - responseRequired = false; - break; - } - case CommandNames.Navto: { - var navtoArgs = request.arguments; - response = this.getNavigateToItems(navtoArgs.searchValue, navtoArgs.file, navtoArgs.maxResultCount); - break; - } - case CommandNames.Brace: { - var braceArguments = request.arguments; - response = this.getBraceMatching(braceArguments.line, braceArguments.offset, braceArguments.file); - break; - } - case CommandNames.NavBar: { - var navBarArgs = request.arguments; - response = this.getNavigationBarItems(navBarArgs.file); - break; - } - case CommandNames.Occurrences: { - var { line, offset, file: fileName } = request.arguments; - response = this.getOccurrences(line, offset, fileName); - break; - } - case CommandNames.ProjectInfo: { - var { file, needFileNameList } = request.arguments; - response = this.getProjectInfo(file, needFileNameList); - break; - } - default: { - this.projectService.log("Unrecognized JSON command: " + message); - this.output(undefined, CommandNames.Unknown, request.seq, "Unrecognized JSON command: " + request.command); - break; - } - } + var {response, responseRequired} = this.executeCommand(request); if (this.logger.isVerbose()) { var elapsed = this.hrtime(start); diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 011f7d7fa5e..66cdbd53750 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -480,6 +480,8 @@ namespace ts.formatting { case SyntaxKind.CloseBraceToken: case SyntaxKind.OpenBracketToken: case SyntaxKind.CloseBracketToken: + case SyntaxKind.OpenParenToken: + case SyntaxKind.CloseParenToken: case SyntaxKind.ElseKeyword: case SyntaxKind.WhileKeyword: case SyntaxKind.AtToken: @@ -644,7 +646,7 @@ namespace ts.formatting { // consume list start token startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; let indentation = - computeIndentation(tokenInfo.token, startLine, Constants.Unknown, parent, parentDynamicIndentation, startLine); + computeIndentation(tokenInfo.token, startLine, Constants.Unknown, parent, parentDynamicIndentation, parentStartLine); listDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentation.indentation, indentation.delta); consumeTokenAndAdvanceScanner(tokenInfo, parent, listDynamicIndentation); diff --git a/src/services/services.ts b/src/services/services.ts index 10e38f98613..fc939a37513 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4546,6 +4546,7 @@ namespace ts { if (hasKind(node.parent, SyntaxKind.GetAccessor) || hasKind(node.parent, SyntaxKind.SetAccessor)) { return getGetAndSetOccurrences(node.parent); } + break; default: if (isModifier(node.kind) && node.parent && (isDeclaration(node.parent) || node.parent.kind === SyntaxKind.VariableStatement)) { @@ -4681,12 +4682,13 @@ namespace ts { // Make sure we only highlight the keyword when it makes sense to do so. if (isAccessibilityModifier(modifier)) { if (!(container.kind === SyntaxKind.ClassDeclaration || + container.kind === SyntaxKind.ClassExpression || (declaration.kind === SyntaxKind.Parameter && hasKind(container, SyntaxKind.Constructor)))) { return undefined; } } else if (modifier === SyntaxKind.StaticKeyword) { - if (container.kind !== SyntaxKind.ClassDeclaration) { + if (!(container.kind === SyntaxKind.ClassDeclaration || container.kind === SyntaxKind.ClassExpression)) { return undefined; } } @@ -4695,6 +4697,11 @@ namespace ts { return undefined; } } + else if (modifier === SyntaxKind.AbstractKeyword) { + if (!(container.kind === SyntaxKind.ClassDeclaration || declaration.kind === SyntaxKind.ClassDeclaration)) { + return undefined; + } + } else { // unsupported modifier return undefined; @@ -4707,19 +4714,26 @@ namespace ts { switch (container.kind) { case SyntaxKind.ModuleBlock: case SyntaxKind.SourceFile: - nodes = (container).statements; + // Container is either a class declaration or the declaration is a classDeclaration + if (modifierFlag & NodeFlags.Abstract) { + nodes = ((declaration).members).concat(declaration); + } + else { + nodes = (container).statements; + } break; case SyntaxKind.Constructor: nodes = ((container).parameters).concat( (container.parent).members); break; case SyntaxKind.ClassDeclaration: - nodes = (container).members; + case SyntaxKind.ClassExpression: + nodes = (container).members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. if (modifierFlag & NodeFlags.AccessibilityModifier) { - let constructor = forEach((container).members, member => { + let constructor = forEach((container).members, member => { return member.kind === SyntaxKind.Constructor && member; }); @@ -4727,6 +4741,9 @@ namespace ts { nodes = nodes.concat(constructor.parameters); } } + else if (modifierFlag & NodeFlags.Abstract) { + nodes = nodes.concat(container); + } break; default: Debug.fail("Invalid container kind.") @@ -4754,6 +4771,8 @@ namespace ts { return NodeFlags.Export; case SyntaxKind.DeclareKeyword: return NodeFlags.Ambient; + case SyntaxKind.AbstractKeyword: + return NodeFlags.Abstract; default: Debug.fail(); } @@ -6574,7 +6593,7 @@ namespace ts { } } - return ClassificationType.text; + return ClassificationType.identifier; } } diff --git a/tests/baselines/reference/classAbstractClinterfaceAssignability.errors.txt b/tests/baselines/reference/classAbstractClinterfaceAssignability.errors.txt new file mode 100644 index 00000000000..d9462f28a22 --- /dev/null +++ b/tests/baselines/reference/classAbstractClinterfaceAssignability.errors.txt @@ -0,0 +1,31 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractClinterfaceAssignability.ts(23,1): error TS2322: Type 'typeof A' is not assignable to type 'IConstructor'. + Cannot assign an abstract constructor type to a non-abstract constructor type. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractClinterfaceAssignability.ts (1 errors) ==== + interface I { + x: number; + } + + interface IConstructor { + new (): I; + + y: number; + prototype: I; + } + + var I: IConstructor; + + abstract class A { + x: number; + static y: number; + } + + var AA: typeof A; + AA = I; + + var AAA: typeof I; + AAA = A; + ~~~ +!!! error TS2322: Type 'typeof A' is not assignable to type 'IConstructor'. +!!! error TS2322: Cannot assign an abstract constructor type to a non-abstract constructor type. \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractClinterfaceAssignability.js b/tests/baselines/reference/classAbstractClinterfaceAssignability.js new file mode 100644 index 00000000000..cbcf9dd189c --- /dev/null +++ b/tests/baselines/reference/classAbstractClinterfaceAssignability.js @@ -0,0 +1,36 @@ +//// [classAbstractClinterfaceAssignability.ts] +interface I { + x: number; +} + +interface IConstructor { + new (): I; + + y: number; + prototype: I; +} + +var I: IConstructor; + +abstract class A { + x: number; + static y: number; +} + +var AA: typeof A; +AA = I; + +var AAA: typeof I; +AAA = A; + +//// [classAbstractClinterfaceAssignability.js] +var I; +var A = (function () { + function A() { + } + return A; +})(); +var AA; +AA = I; +var AAA; +AAA = A; diff --git a/tests/baselines/reference/classAbstractConstructorAssignability.errors.txt b/tests/baselines/reference/classAbstractConstructorAssignability.errors.txt new file mode 100644 index 00000000000..a3e9e077914 --- /dev/null +++ b/tests/baselines/reference/classAbstractConstructorAssignability.errors.txt @@ -0,0 +1,30 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructorAssignability.ts(8,5): error TS2322: Type 'typeof B' is not assignable to type 'typeof A'. + Cannot assign an abstract constructor type to a non-abstract constructor type. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructorAssignability.ts(10,5): error TS2322: Type 'typeof B' is not assignable to type 'typeof C'. + Cannot assign an abstract constructor type to a non-abstract constructor type. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructorAssignability.ts(13,1): error TS2511: Cannot create an instance of the abstract class 'B'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructorAssignability.ts (3 errors) ==== + + class A {} + + abstract class B extends A {} + + class C extends B {} + + var AA : typeof A = B; + ~~ +!!! error TS2322: Type 'typeof B' is not assignable to type 'typeof A'. +!!! error TS2322: Cannot assign an abstract constructor type to a non-abstract constructor type. + var BB : typeof B = A; + var CC : typeof C = B; + ~~ +!!! error TS2322: Type 'typeof B' is not assignable to type 'typeof C'. +!!! error TS2322: Cannot assign an abstract constructor type to a non-abstract constructor type. + + new AA; + new BB; + ~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'B'. + new CC; \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractConstructorAssignability.js b/tests/baselines/reference/classAbstractConstructorAssignability.js new file mode 100644 index 00000000000..04357a44554 --- /dev/null +++ b/tests/baselines/reference/classAbstractConstructorAssignability.js @@ -0,0 +1,47 @@ +//// [classAbstractConstructorAssignability.ts] + +class A {} + +abstract class B extends A {} + +class C extends B {} + +var AA : typeof A = B; +var BB : typeof B = A; +var CC : typeof C = B; + +new AA; +new BB; +new CC; + +//// [classAbstractConstructorAssignability.js] +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 A = (function () { + function A() { + } + return A; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; +})(A); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(B); +var AA = B; +var BB = A; +var CC = B; +new AA; +new BB; +new CC; diff --git a/tests/baselines/reference/classAbstractExtends.errors.txt b/tests/baselines/reference/classAbstractExtends.errors.txt new file mode 100644 index 00000000000..550067cd0e1 --- /dev/null +++ b/tests/baselines/reference/classAbstractExtends.errors.txt @@ -0,0 +1,22 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractExtends.ts(10,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'bar' from class 'B'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractExtends.ts (1 errors) ==== + + class A { + foo() {} + } + + abstract class B extends A { + abstract bar(); + } + + class C extends B { } + ~ +!!! error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'bar' from class 'B'. + + abstract class D extends B {} + + class E extends B { + bar() {} + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractExtends.js b/tests/baselines/reference/classAbstractExtends.js new file mode 100644 index 00000000000..58e49de2c77 --- /dev/null +++ b/tests/baselines/reference/classAbstractExtends.js @@ -0,0 +1,59 @@ +//// [classAbstractExtends.ts] + +class A { + foo() {} +} + +abstract class B extends A { + abstract bar(); +} + +class C extends B { } + +abstract class D extends B {} + +class E extends B { + bar() {} +} + +//// [classAbstractExtends.js] +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 A = (function () { + function A() { + } + A.prototype.foo = function () { }; + return A; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; +})(A); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(B); +var D = (function (_super) { + __extends(D, _super); + function D() { + _super.apply(this, arguments); + } + return D; +})(B); +var E = (function (_super) { + __extends(E, _super); + function E() { + _super.apply(this, arguments); + } + E.prototype.bar = function () { }; + return E; +})(B); diff --git a/tests/baselines/reference/classAbstractFactoryFunction.errors.txt b/tests/baselines/reference/classAbstractFactoryFunction.errors.txt new file mode 100644 index 00000000000..f1b43adae59 --- /dev/null +++ b/tests/baselines/reference/classAbstractFactoryFunction.errors.txt @@ -0,0 +1,28 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractFactoryFunction.ts(10,12): error TS2511: Cannot create an instance of the abstract class 'B'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractFactoryFunction.ts(14,6): error TS2345: Argument of type 'typeof B' is not assignable to parameter of type 'typeof A'. + Cannot assign an abstract constructor type to a non-abstract constructor type. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractFactoryFunction.ts (2 errors) ==== + + class A {} + abstract class B extends A {} + + function NewA(Factory: typeof A) { + return new A; + } + + function NewB(Factory: typeof B) { + return new B; + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'B'. + } + + NewA(A); + NewA(B); + ~ +!!! error TS2345: Argument of type 'typeof B' is not assignable to parameter of type 'typeof A'. +!!! error TS2345: Cannot assign an abstract constructor type to a non-abstract constructor type. + + NewB(A); + NewB(B); \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractFactoryFunction.js b/tests/baselines/reference/classAbstractFactoryFunction.js new file mode 100644 index 00000000000..b1d89ba385d --- /dev/null +++ b/tests/baselines/reference/classAbstractFactoryFunction.js @@ -0,0 +1,47 @@ +//// [classAbstractFactoryFunction.ts] + +class A {} +abstract class B extends A {} + +function NewA(Factory: typeof A) { + return new A; +} + +function NewB(Factory: typeof B) { + return new B; +} + +NewA(A); +NewA(B); + +NewB(A); +NewB(B); + +//// [classAbstractFactoryFunction.js] +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 A = (function () { + function A() { + } + return A; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; +})(A); +function NewA(Factory) { + return new A; +} +function NewB(Factory) { + return new B; +} +NewA(A); +NewA(B); +NewB(A); +NewB(B); diff --git a/tests/baselines/reference/classAbstractInstantiations1.errors.txt b/tests/baselines/reference/classAbstractInstantiations1.errors.txt index 6171ef2efab..24a969fc6b8 100644 --- a/tests/baselines/reference/classAbstractInstantiations1.errors.txt +++ b/tests/baselines/reference/classAbstractInstantiations1.errors.txt @@ -1,10 +1,14 @@ -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(8,1): error TS2511: Cannot create an instance of the abstract class 'A'. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(9,1): error TS2511: Cannot create an instance of the abstract class 'A'. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(11,1): error TS2511: Cannot create an instance of the abstract class 'C'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(12,1): error TS2511: Cannot create an instance of the abstract class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(13,1): error TS2511: Cannot create an instance of the abstract class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(15,1): error TS2511: Cannot create an instance of the abstract class 'C'. ==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts (3 errors) ==== + // + // Calling new with (non)abstract classes. + // + abstract class A {} class B extends A {} diff --git a/tests/baselines/reference/classAbstractInstantiations1.js b/tests/baselines/reference/classAbstractInstantiations1.js index f3a0eecada9..689a78f1a06 100644 --- a/tests/baselines/reference/classAbstractInstantiations1.js +++ b/tests/baselines/reference/classAbstractInstantiations1.js @@ -1,5 +1,9 @@ //// [classAbstractInstantiations1.ts] +// +// Calling new with (non)abstract classes. +// + abstract class A {} class B extends A {} @@ -21,6 +25,9 @@ c = new B; //// [classAbstractInstantiations1.js] +// +// Calling new with (non)abstract classes. +// 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; } diff --git a/tests/baselines/reference/classAbstractInstantiations2.errors.txt b/tests/baselines/reference/classAbstractInstantiations2.errors.txt index b3b01fd656d..077f87c5050 100644 --- a/tests/baselines/reference/classAbstractInstantiations2.errors.txt +++ b/tests/baselines/reference/classAbstractInstantiations2.errors.txt @@ -1,4 +1,6 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(10,1): error TS2511: Cannot create an instance of the abstract class 'B'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(13,5): error TS2322: Type 'typeof B' is not assignable to type 'typeof A'. + Cannot assign an abstract constructor type to a non-abstract constructor type. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(17,5): error TS2511: Cannot create an instance of the abstract class 'B'. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(21,1): error TS2511: Cannot create an instance of the abstract class 'B'. tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(26,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'bar' from class 'B'. @@ -7,7 +9,7 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(50,5): error TS1244: Abstract methods can only appear within an abstract class. -==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts (7 errors) ==== +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts (8 errors) ==== class A { // ... } @@ -23,6 +25,9 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst var BB: typeof B = B; var AA: typeof A = BB; // error, AA is not of abstract type. + ~~ +!!! error TS2322: Type 'typeof B' is not assignable to type 'typeof A'. +!!! error TS2322: Cannot assign an abstract constructor type to a non-abstract constructor type. new AA; function constructB(Factory : typeof B) { diff --git a/tests/baselines/reference/classAbstractMethodInNonAbstractClass.errors.txt b/tests/baselines/reference/classAbstractMethodInNonAbstractClass.errors.txt new file mode 100644 index 00000000000..d6f9b7540d4 --- /dev/null +++ b/tests/baselines/reference/classAbstractMethodInNonAbstractClass.errors.txt @@ -0,0 +1,19 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodInNonAbstractClass.ts(2,5): error TS1244: Abstract methods can only appear within an abstract class. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodInNonAbstractClass.ts(6,5): error TS1244: Abstract methods can only appear within an abstract class. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodInNonAbstractClass.ts(6,5): error TS1245: Method 'foo' cannot have an implementation because it is marked abstract. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodInNonAbstractClass.ts (3 errors) ==== + class A { + abstract foo(); + ~~~~~~~~ +!!! error TS1244: Abstract methods can only appear within an abstract class. + } + + class B { + abstract foo() {} + ~~~~~~~~ +!!! error TS1244: Abstract methods can only appear within an abstract class. + ~~~~~~~~~~~~~~~~~ +!!! error TS1245: Method 'foo' cannot have an implementation because it is marked abstract. + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractMethodInNonAbstractClass.js b/tests/baselines/reference/classAbstractMethodInNonAbstractClass.js new file mode 100644 index 00000000000..6a38440cf41 --- /dev/null +++ b/tests/baselines/reference/classAbstractMethodInNonAbstractClass.js @@ -0,0 +1,21 @@ +//// [classAbstractMethodInNonAbstractClass.ts] +class A { + abstract foo(); +} + +class B { + abstract foo() {} +} + +//// [classAbstractMethodInNonAbstractClass.js] +var A = (function () { + function A() { + } + return A; +})(); +var B = (function () { + function B() { + } + B.prototype.foo = function () { }; + return B; +})(); diff --git a/tests/baselines/reference/classAbstractOverrideWithAbstract.errors.txt b/tests/baselines/reference/classAbstractOverrideWithAbstract.errors.txt new file mode 100644 index 00000000000..d9d073a07e0 --- /dev/null +++ b/tests/baselines/reference/classAbstractOverrideWithAbstract.errors.txt @@ -0,0 +1,29 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverrideWithAbstract.ts(19,7): error TS2515: Non-abstract class 'CC' does not implement inherited abstract member 'foo' from class 'BB'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverrideWithAbstract.ts (1 errors) ==== + class A { + foo() {} + } + + abstract class B extends A { + abstract foo(); + } + + abstract class AA { + foo() {} + abstract bar(); + } + + abstract class BB extends AA { + abstract foo(); + bar () {} + } + + class CC extends BB {} // error + ~~ +!!! error TS2515: Non-abstract class 'CC' does not implement inherited abstract member 'foo' from class 'BB'. + + class DD extends BB { + foo() {} + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractOverrideWithAbstract.js b/tests/baselines/reference/classAbstractOverrideWithAbstract.js new file mode 100644 index 00000000000..fb03192f35e --- /dev/null +++ b/tests/baselines/reference/classAbstractOverrideWithAbstract.js @@ -0,0 +1,73 @@ +//// [classAbstractOverrideWithAbstract.ts] +class A { + foo() {} +} + +abstract class B extends A { + abstract foo(); +} + +abstract class AA { + foo() {} + abstract bar(); +} + +abstract class BB extends AA { + abstract foo(); + bar () {} +} + +class CC extends BB {} // error + +class DD extends BB { + foo() {} +} + +//// [classAbstractOverrideWithAbstract.js] +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 A = (function () { + function A() { + } + A.prototype.foo = function () { }; + return A; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; +})(A); +var AA = (function () { + function AA() { + } + AA.prototype.foo = function () { }; + return AA; +})(); +var BB = (function (_super) { + __extends(BB, _super); + function BB() { + _super.apply(this, arguments); + } + BB.prototype.bar = function () { }; + return BB; +})(AA); +var CC = (function (_super) { + __extends(CC, _super); + function CC() { + _super.apply(this, arguments); + } + return CC; +})(BB); // error +var DD = (function (_super) { + __extends(DD, _super); + function DD() { + _super.apply(this, arguments); + } + DD.prototype.foo = function () { }; + return DD; +})(BB); diff --git a/tests/baselines/reference/destructuringParameterDeclaration1ES5.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration1ES5.errors.txt index 269d2b5640d..8e51c2b6111 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration1ES5.errors.txt +++ b/tests/baselines/reference/destructuringParameterDeclaration1ES5.errors.txt @@ -1,16 +1,8 @@ -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES5.ts(32,4): error TS2345: Argument of type '[string, number, number]' is not assignable to parameter of type '[undefined, null, undefined]'. - Types of property '0' are incompatible. - Type 'string' is not assignable to type 'undefined'. -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES5.ts(33,4): error TS2345: Argument of type '[[string], number, [[boolean, boolean]]]' is not assignable to parameter of type '[[undefined], undefined, [[undefined, undefined]]]'. - Types of property '0' are incompatible. - Type '[string]' is not assignable to type '[undefined]'. - Types of property '0' are incompatible. - Type 'string' is not assignable to type 'undefined'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES5.ts(62,10): error TS2393: Duplicate function implementation. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES5.ts(63,10): error TS2393: Duplicate function implementation. -==== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES5.ts (4 errors) ==== +==== tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES5.ts (2 errors) ==== // A parameter declaration may specify either an identifier or a binding pattern. // The identifiers specified in parameter declarations and binding patterns // in a parameter list must be unique within that parameter list. @@ -43,17 +35,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration1ES5. b2("string", { x: 200, y: "string" }); b2("string", { x: 200, y: true }); b6(["string", 1, 2]); // Shouldn't be an error - ~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '[string, number, number]' is not assignable to parameter of type '[undefined, null, undefined]'. -!!! error TS2345: Types of property '0' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type 'undefined'. b7([["string"], 1, [[true, false]]]); // Shouldn't be an error - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '[[string], number, [[boolean, boolean]]]' is not assignable to parameter of type '[[undefined], undefined, [[undefined, undefined]]]'. -!!! error TS2345: Types of property '0' are incompatible. -!!! error TS2345: Type '[string]' is not assignable to type '[undefined]'. -!!! error TS2345: Types of property '0' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type 'undefined'. // If the declaration specifies a binding pattern, the parameter type is the implied type of that binding pattern (section 5.1.3) diff --git a/tests/baselines/reference/typeArgumentInferenceApparentType1.js b/tests/baselines/reference/typeArgumentInferenceApparentType1.js new file mode 100644 index 00000000000..7a4f1ea19f5 --- /dev/null +++ b/tests/baselines/reference/typeArgumentInferenceApparentType1.js @@ -0,0 +1,12 @@ +//// [typeArgumentInferenceApparentType1.ts] +function method(iterable: Iterable): T { + return; +} + +var res: string = method("test"); + +//// [typeArgumentInferenceApparentType1.js] +function method(iterable) { + return; +} +var res = method("test"); diff --git a/tests/baselines/reference/typeArgumentInferenceApparentType1.symbols b/tests/baselines/reference/typeArgumentInferenceApparentType1.symbols new file mode 100644 index 00000000000..abcb8fdfc68 --- /dev/null +++ b/tests/baselines/reference/typeArgumentInferenceApparentType1.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/typeArgumentInferenceApparentType1.ts === +function method(iterable: Iterable): T { +>method : Symbol(method, Decl(typeArgumentInferenceApparentType1.ts, 0, 0)) +>T : Symbol(T, Decl(typeArgumentInferenceApparentType1.ts, 0, 16)) +>iterable : Symbol(iterable, Decl(typeArgumentInferenceApparentType1.ts, 0, 19)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>T : Symbol(T, Decl(typeArgumentInferenceApparentType1.ts, 0, 16)) +>T : Symbol(T, Decl(typeArgumentInferenceApparentType1.ts, 0, 16)) + + return; +} + +var res: string = method("test"); +>res : Symbol(res, Decl(typeArgumentInferenceApparentType1.ts, 4, 3)) +>method : Symbol(method, Decl(typeArgumentInferenceApparentType1.ts, 0, 0)) + diff --git a/tests/baselines/reference/typeArgumentInferenceApparentType1.types b/tests/baselines/reference/typeArgumentInferenceApparentType1.types new file mode 100644 index 00000000000..29fd1aeca18 --- /dev/null +++ b/tests/baselines/reference/typeArgumentInferenceApparentType1.types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/typeArgumentInferenceApparentType1.ts === +function method(iterable: Iterable): T { +>method : (iterable: Iterable) => T +>T : T +>iterable : Iterable +>Iterable : Iterable +>T : T +>T : T + + return; +} + +var res: string = method("test"); +>res : string +>method("test") : string +>method : (iterable: Iterable) => T +>"test" : string + diff --git a/tests/baselines/reference/typeArgumentInferenceApparentType2.js b/tests/baselines/reference/typeArgumentInferenceApparentType2.js new file mode 100644 index 00000000000..cf9f3bca00e --- /dev/null +++ b/tests/baselines/reference/typeArgumentInferenceApparentType2.js @@ -0,0 +1,17 @@ +//// [typeArgumentInferenceApparentType2.ts] +function method(iterable: Iterable): T { + function inner>() { + var u: U; + var res: T = method(u); + } + return; +} + +//// [typeArgumentInferenceApparentType2.js] +function method(iterable) { + function inner() { + var u; + var res = method(u); + } + return; +} diff --git a/tests/baselines/reference/typeArgumentInferenceApparentType2.symbols b/tests/baselines/reference/typeArgumentInferenceApparentType2.symbols new file mode 100644 index 00000000000..86cf8e7cdcd --- /dev/null +++ b/tests/baselines/reference/typeArgumentInferenceApparentType2.symbols @@ -0,0 +1,27 @@ +=== tests/cases/compiler/typeArgumentInferenceApparentType2.ts === +function method(iterable: Iterable): T { +>method : Symbol(method, Decl(typeArgumentInferenceApparentType2.ts, 0, 0)) +>T : Symbol(T, Decl(typeArgumentInferenceApparentType2.ts, 0, 16)) +>iterable : Symbol(iterable, Decl(typeArgumentInferenceApparentType2.ts, 0, 19)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>T : Symbol(T, Decl(typeArgumentInferenceApparentType2.ts, 0, 16)) +>T : Symbol(T, Decl(typeArgumentInferenceApparentType2.ts, 0, 16)) + + function inner>() { +>inner : Symbol(inner, Decl(typeArgumentInferenceApparentType2.ts, 0, 46)) +>U : Symbol(U, Decl(typeArgumentInferenceApparentType2.ts, 1, 19)) +>Iterable : Symbol(Iterable, Decl(lib.d.ts, 1681, 1)) +>T : Symbol(T, Decl(typeArgumentInferenceApparentType2.ts, 0, 16)) + + var u: U; +>u : Symbol(u, Decl(typeArgumentInferenceApparentType2.ts, 2, 11)) +>U : Symbol(U, Decl(typeArgumentInferenceApparentType2.ts, 1, 19)) + + var res: T = method(u); +>res : Symbol(res, Decl(typeArgumentInferenceApparentType2.ts, 3, 11)) +>T : Symbol(T, Decl(typeArgumentInferenceApparentType2.ts, 0, 16)) +>method : Symbol(method, Decl(typeArgumentInferenceApparentType2.ts, 0, 0)) +>u : Symbol(u, Decl(typeArgumentInferenceApparentType2.ts, 2, 11)) + } + return; +} diff --git a/tests/baselines/reference/typeArgumentInferenceApparentType2.types b/tests/baselines/reference/typeArgumentInferenceApparentType2.types new file mode 100644 index 00000000000..6a0e6ae6454 --- /dev/null +++ b/tests/baselines/reference/typeArgumentInferenceApparentType2.types @@ -0,0 +1,28 @@ +=== tests/cases/compiler/typeArgumentInferenceApparentType2.ts === +function method(iterable: Iterable): T { +>method : (iterable: Iterable) => T +>T : T +>iterable : Iterable +>Iterable : Iterable +>T : T +>T : T + + function inner>() { +>inner : >() => void +>U : U +>Iterable : Iterable +>T : T + + var u: U; +>u : U +>U : U + + var res: T = method(u); +>res : T +>T : T +>method(u) : T +>method : (iterable: Iterable) => T +>u : U + } + return; +} diff --git a/tests/baselines/reference/wideningTuples1.js b/tests/baselines/reference/wideningTuples1.js new file mode 100644 index 00000000000..ed39a735bfe --- /dev/null +++ b/tests/baselines/reference/wideningTuples1.js @@ -0,0 +1,9 @@ +//// [wideningTuples1.ts] +declare function foo(x: T): T; + +var y = foo([undefined]); +y = [""]; + +//// [wideningTuples1.js] +var y = foo([undefined]); +y = [""]; diff --git a/tests/baselines/reference/wideningTuples1.symbols b/tests/baselines/reference/wideningTuples1.symbols new file mode 100644 index 00000000000..819510b7319 --- /dev/null +++ b/tests/baselines/reference/wideningTuples1.symbols @@ -0,0 +1,16 @@ +=== tests/cases/conformance/types/tuple/wideningTuples1.ts === +declare function foo(x: T): T; +>foo : Symbol(foo, Decl(wideningTuples1.ts, 0, 0)) +>T : Symbol(T, Decl(wideningTuples1.ts, 0, 21)) +>x : Symbol(x, Decl(wideningTuples1.ts, 0, 38)) +>T : Symbol(T, Decl(wideningTuples1.ts, 0, 21)) +>T : Symbol(T, Decl(wideningTuples1.ts, 0, 21)) + +var y = foo([undefined]); +>y : Symbol(y, Decl(wideningTuples1.ts, 2, 3)) +>foo : Symbol(foo, Decl(wideningTuples1.ts, 0, 0)) +>undefined : Symbol(undefined) + +y = [""]; +>y : Symbol(y, Decl(wideningTuples1.ts, 2, 3)) + diff --git a/tests/baselines/reference/wideningTuples1.types b/tests/baselines/reference/wideningTuples1.types new file mode 100644 index 00000000000..1fdd4a6cb53 --- /dev/null +++ b/tests/baselines/reference/wideningTuples1.types @@ -0,0 +1,21 @@ +=== tests/cases/conformance/types/tuple/wideningTuples1.ts === +declare function foo(x: T): T; +>foo : (x: T) => T +>T : T +>x : T +>T : T +>T : T + +var y = foo([undefined]); +>y : [any] +>foo([undefined]) : [any] +>foo : (x: T) => T +>[undefined] : [undefined] +>undefined : undefined + +y = [""]; +>y = [""] : [string] +>y : [any] +>[""] : [string] +>"" : string + diff --git a/tests/baselines/reference/wideningTuples2.js b/tests/baselines/reference/wideningTuples2.js new file mode 100644 index 00000000000..fa74e089961 --- /dev/null +++ b/tests/baselines/reference/wideningTuples2.js @@ -0,0 +1,13 @@ +//// [wideningTuples2.ts] +var foo: () => [any] = function bar() { + let intermediate = bar(); + intermediate = [""]; + return [undefined]; +}; + +//// [wideningTuples2.js] +var foo = function bar() { + var intermediate = bar(); + intermediate = [""]; + return [undefined]; +}; diff --git a/tests/baselines/reference/wideningTuples2.symbols b/tests/baselines/reference/wideningTuples2.symbols new file mode 100644 index 00000000000..74186045e90 --- /dev/null +++ b/tests/baselines/reference/wideningTuples2.symbols @@ -0,0 +1,16 @@ +=== tests/cases/conformance/types/tuple/wideningTuples2.ts === +var foo: () => [any] = function bar() { +>foo : Symbol(foo, Decl(wideningTuples2.ts, 0, 3)) +>bar : Symbol(bar, Decl(wideningTuples2.ts, 0, 22)) + + let intermediate = bar(); +>intermediate : Symbol(intermediate, Decl(wideningTuples2.ts, 1, 7)) +>bar : Symbol(bar, Decl(wideningTuples2.ts, 0, 22)) + + intermediate = [""]; +>intermediate : Symbol(intermediate, Decl(wideningTuples2.ts, 1, 7)) + + return [undefined]; +>undefined : Symbol(undefined) + +}; diff --git a/tests/baselines/reference/wideningTuples2.types b/tests/baselines/reference/wideningTuples2.types new file mode 100644 index 00000000000..c07166c53f0 --- /dev/null +++ b/tests/baselines/reference/wideningTuples2.types @@ -0,0 +1,22 @@ +=== tests/cases/conformance/types/tuple/wideningTuples2.ts === +var foo: () => [any] = function bar() { +>foo : () => [any] +>function bar() { let intermediate = bar(); intermediate = [""]; return [undefined];} : () => [any] +>bar : () => [any] + + let intermediate = bar(); +>intermediate : [any] +>bar() : [any] +>bar : () => [any] + + intermediate = [""]; +>intermediate = [""] : [string] +>intermediate : [any] +>[""] : [string] +>"" : string + + return [undefined]; +>[undefined] : [undefined] +>undefined : undefined + +}; diff --git a/tests/baselines/reference/wideningTuples3.errors.txt b/tests/baselines/reference/wideningTuples3.errors.txt new file mode 100644 index 00000000000..43c7e349a0c --- /dev/null +++ b/tests/baselines/reference/wideningTuples3.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/types/tuple/wideningTuples3.ts(3,5): error TS7005: Variable 'b' implicitly has an '[any, any]' type. + + +==== tests/cases/conformance/types/tuple/wideningTuples3.ts (1 errors) ==== + var a: [any]; + + var b = a = [undefined, null]; + ~ +!!! error TS7005: Variable 'b' implicitly has an '[any, any]' type. \ No newline at end of file diff --git a/tests/baselines/reference/wideningTuples3.js b/tests/baselines/reference/wideningTuples3.js new file mode 100644 index 00000000000..dfeaae745d4 --- /dev/null +++ b/tests/baselines/reference/wideningTuples3.js @@ -0,0 +1,8 @@ +//// [wideningTuples3.ts] +var a: [any]; + +var b = a = [undefined, null]; + +//// [wideningTuples3.js] +var a; +var b = a = [undefined, null]; diff --git a/tests/baselines/reference/wideningTuples4.js b/tests/baselines/reference/wideningTuples4.js new file mode 100644 index 00000000000..b4d16a3058b --- /dev/null +++ b/tests/baselines/reference/wideningTuples4.js @@ -0,0 +1,10 @@ +//// [wideningTuples4.ts] +var a: [any]; + +var b = a = [undefined, null]; +b = ["", ""]; + +//// [wideningTuples4.js] +var a; +var b = a = [undefined, null]; +b = ["", ""]; diff --git a/tests/baselines/reference/wideningTuples4.symbols b/tests/baselines/reference/wideningTuples4.symbols new file mode 100644 index 00000000000..95e7cc3cff8 --- /dev/null +++ b/tests/baselines/reference/wideningTuples4.symbols @@ -0,0 +1,12 @@ +=== tests/cases/conformance/types/tuple/wideningTuples4.ts === +var a: [any]; +>a : Symbol(a, Decl(wideningTuples4.ts, 0, 3)) + +var b = a = [undefined, null]; +>b : Symbol(b, Decl(wideningTuples4.ts, 2, 3)) +>a : Symbol(a, Decl(wideningTuples4.ts, 0, 3)) +>undefined : Symbol(undefined) + +b = ["", ""]; +>b : Symbol(b, Decl(wideningTuples4.ts, 2, 3)) + diff --git a/tests/baselines/reference/wideningTuples4.types b/tests/baselines/reference/wideningTuples4.types new file mode 100644 index 00000000000..6d101dd1e01 --- /dev/null +++ b/tests/baselines/reference/wideningTuples4.types @@ -0,0 +1,19 @@ +=== tests/cases/conformance/types/tuple/wideningTuples4.ts === +var a: [any]; +>a : [any] + +var b = a = [undefined, null]; +>b : [any, any] +>a = [undefined, null] : [undefined, null] +>a : [any] +>[undefined, null] : [undefined, null] +>undefined : undefined +>null : null + +b = ["", ""]; +>b = ["", ""] : [string, string] +>b : [any, any] +>["", ""] : [string, string] +>"" : string +>"" : string + diff --git a/tests/baselines/reference/wideningTuples5.errors.txt b/tests/baselines/reference/wideningTuples5.errors.txt new file mode 100644 index 00000000000..bfd72079f55 --- /dev/null +++ b/tests/baselines/reference/wideningTuples5.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/types/tuple/wideningTuples5.ts(1,6): error TS7005: Variable 'a' implicitly has an 'any' type. +tests/cases/conformance/types/tuple/wideningTuples5.ts(1,9): error TS7005: Variable 'b' implicitly has an 'any' type. + + +==== tests/cases/conformance/types/tuple/wideningTuples5.ts (2 errors) ==== + var [a, b] = [undefined, null]; + ~ +!!! error TS7005: Variable 'a' implicitly has an 'any' type. + ~ +!!! error TS7005: Variable 'b' implicitly has an 'any' type. \ No newline at end of file diff --git a/tests/baselines/reference/wideningTuples5.js b/tests/baselines/reference/wideningTuples5.js new file mode 100644 index 00000000000..5763fb3340f --- /dev/null +++ b/tests/baselines/reference/wideningTuples5.js @@ -0,0 +1,5 @@ +//// [wideningTuples5.ts] +var [a, b] = [undefined, null]; + +//// [wideningTuples5.js] +var _a = [undefined, null], a = _a[0], b = _a[1]; diff --git a/tests/baselines/reference/wideningTuples6.js b/tests/baselines/reference/wideningTuples6.js new file mode 100644 index 00000000000..b1d5e8ec0bd --- /dev/null +++ b/tests/baselines/reference/wideningTuples6.js @@ -0,0 +1,9 @@ +//// [wideningTuples6.ts] +var [a, b] = [undefined, null]; +a = ""; +b = ""; + +//// [wideningTuples6.js] +var _a = [undefined, null], a = _a[0], b = _a[1]; +a = ""; +b = ""; diff --git a/tests/baselines/reference/wideningTuples6.symbols b/tests/baselines/reference/wideningTuples6.symbols new file mode 100644 index 00000000000..88de6a7b9b7 --- /dev/null +++ b/tests/baselines/reference/wideningTuples6.symbols @@ -0,0 +1,12 @@ +=== tests/cases/conformance/types/tuple/wideningTuples6.ts === +var [a, b] = [undefined, null]; +>a : Symbol(a, Decl(wideningTuples6.ts, 0, 5)) +>b : Symbol(b, Decl(wideningTuples6.ts, 0, 7)) +>undefined : Symbol(undefined) + +a = ""; +>a : Symbol(a, Decl(wideningTuples6.ts, 0, 5)) + +b = ""; +>b : Symbol(b, Decl(wideningTuples6.ts, 0, 7)) + diff --git a/tests/baselines/reference/wideningTuples6.types b/tests/baselines/reference/wideningTuples6.types new file mode 100644 index 00000000000..d75c0b49e9e --- /dev/null +++ b/tests/baselines/reference/wideningTuples6.types @@ -0,0 +1,18 @@ +=== tests/cases/conformance/types/tuple/wideningTuples6.ts === +var [a, b] = [undefined, null]; +>a : any +>b : any +>[undefined, null] : [undefined, null] +>undefined : undefined +>null : null + +a = ""; +>a = "" : string +>a : any +>"" : string + +b = ""; +>b = "" : string +>b : any +>"" : string + diff --git a/tests/baselines/reference/wideningTuples7.errors.txt b/tests/baselines/reference/wideningTuples7.errors.txt new file mode 100644 index 00000000000..25fd1f58e64 --- /dev/null +++ b/tests/baselines/reference/wideningTuples7.errors.txt @@ -0,0 +1,10 @@ +tests/cases/conformance/types/tuple/wideningTuples7.ts(1,20): error TS7010: 'bar', which lacks return-type annotation, implicitly has an '[any]' return type. + + +==== tests/cases/conformance/types/tuple/wideningTuples7.ts (1 errors) ==== + var foo = function bar() { + ~~~ +!!! error TS7010: 'bar', which lacks return-type annotation, implicitly has an '[any]' return type. + let intermediate: [string]; + return intermediate = [undefined]; + }; \ No newline at end of file diff --git a/tests/baselines/reference/wideningTuples7.js b/tests/baselines/reference/wideningTuples7.js new file mode 100644 index 00000000000..4d94a1909ad --- /dev/null +++ b/tests/baselines/reference/wideningTuples7.js @@ -0,0 +1,11 @@ +//// [wideningTuples7.ts] +var foo = function bar() { + let intermediate: [string]; + return intermediate = [undefined]; +}; + +//// [wideningTuples7.js] +var foo = function bar() { + var intermediate; + return intermediate = [undefined]; +}; diff --git a/tests/cases/compiler/typeArgumentInferenceApparentType1.ts b/tests/cases/compiler/typeArgumentInferenceApparentType1.ts new file mode 100644 index 00000000000..4cc4a0dd4e5 --- /dev/null +++ b/tests/cases/compiler/typeArgumentInferenceApparentType1.ts @@ -0,0 +1,6 @@ +//@target: ES6 +function method(iterable: Iterable): T { + return; +} + +var res: string = method("test"); \ No newline at end of file diff --git a/tests/cases/compiler/typeArgumentInferenceApparentType2.ts b/tests/cases/compiler/typeArgumentInferenceApparentType2.ts new file mode 100644 index 00000000000..88ae4df8c4c --- /dev/null +++ b/tests/cases/compiler/typeArgumentInferenceApparentType2.ts @@ -0,0 +1,8 @@ +//@target: ES6 +function method(iterable: Iterable): T { + function inner>() { + var u: U; + var res: T = method(u); + } + return; +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractClinterfaceAssignability.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractClinterfaceAssignability.ts new file mode 100644 index 00000000000..682ad6faa0f --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractClinterfaceAssignability.ts @@ -0,0 +1,23 @@ +interface I { + x: number; +} + +interface IConstructor { + new (): I; + + y: number; + prototype: I; +} + +var I: IConstructor; + +abstract class A { + x: number; + static y: number; +} + +var AA: typeof A; +AA = I; + +var AAA: typeof I; +AAA = A; \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructorAssignability.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructorAssignability.ts new file mode 100644 index 00000000000..ecef21cc12a --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructorAssignability.ts @@ -0,0 +1,14 @@ + +class A {} + +abstract class B extends A {} + +class C extends B {} + +var AA : typeof A = B; +var BB : typeof B = A; +var CC : typeof C = B; + +new AA; +new BB; +new CC; \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractExtends.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractExtends.ts new file mode 100644 index 00000000000..0aa57b75835 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractExtends.ts @@ -0,0 +1,16 @@ + +class A { + foo() {} +} + +abstract class B extends A { + abstract bar(); +} + +class C extends B { } + +abstract class D extends B {} + +class E extends B { + bar() {} +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractFactoryFunction.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractFactoryFunction.ts new file mode 100644 index 00000000000..73d33a34e12 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractFactoryFunction.ts @@ -0,0 +1,17 @@ + +class A {} +abstract class B extends A {} + +function NewA(Factory: typeof A) { + return new A; +} + +function NewB(Factory: typeof B) { + return new B; +} + +NewA(A); +NewA(B); + +NewB(A); +NewB(B); \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts index 4daf27b53e4..c805a993a68 100644 --- a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts @@ -1,4 +1,8 @@ +// +// Calling new with (non)abstract classes. +// + abstract class A {} class B extends A {} diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodInNonAbstractClass.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodInNonAbstractClass.ts new file mode 100644 index 00000000000..98a2091bc0c --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodInNonAbstractClass.ts @@ -0,0 +1,7 @@ +class A { + abstract foo(); +} + +class B { + abstract foo() {} +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverrideWithAbstract.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverrideWithAbstract.ts new file mode 100644 index 00000000000..7e02dbd4d98 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverrideWithAbstract.ts @@ -0,0 +1,23 @@ +class A { + foo() {} +} + +abstract class B extends A { + abstract foo(); +} + +abstract class AA { + foo() {} + abstract bar(); +} + +abstract class BB extends AA { + abstract foo(); + bar () {} +} + +class CC extends BB {} // error + +class DD extends BB { + foo() {} +} \ No newline at end of file diff --git a/tests/cases/conformance/types/tuple/wideningTuples1.ts b/tests/cases/conformance/types/tuple/wideningTuples1.ts new file mode 100644 index 00000000000..f4885435dcf --- /dev/null +++ b/tests/cases/conformance/types/tuple/wideningTuples1.ts @@ -0,0 +1,5 @@ +//@noImplicitAny: true +declare function foo(x: T): T; + +var y = foo([undefined]); +y = [""]; \ No newline at end of file diff --git a/tests/cases/conformance/types/tuple/wideningTuples2.ts b/tests/cases/conformance/types/tuple/wideningTuples2.ts new file mode 100644 index 00000000000..d8bf1248546 --- /dev/null +++ b/tests/cases/conformance/types/tuple/wideningTuples2.ts @@ -0,0 +1,6 @@ +//@noImplicitAny: true +var foo: () => [any] = function bar() { + let intermediate = bar(); + intermediate = [""]; + return [undefined]; +}; \ No newline at end of file diff --git a/tests/cases/conformance/types/tuple/wideningTuples3.ts b/tests/cases/conformance/types/tuple/wideningTuples3.ts new file mode 100644 index 00000000000..a6837be2a0f --- /dev/null +++ b/tests/cases/conformance/types/tuple/wideningTuples3.ts @@ -0,0 +1,4 @@ +//@noImplicitAny: true +var a: [any]; + +var b = a = [undefined, null]; \ No newline at end of file diff --git a/tests/cases/conformance/types/tuple/wideningTuples4.ts b/tests/cases/conformance/types/tuple/wideningTuples4.ts new file mode 100644 index 00000000000..550ba07f600 --- /dev/null +++ b/tests/cases/conformance/types/tuple/wideningTuples4.ts @@ -0,0 +1,4 @@ +var a: [any]; + +var b = a = [undefined, null]; +b = ["", ""]; \ No newline at end of file diff --git a/tests/cases/conformance/types/tuple/wideningTuples5.ts b/tests/cases/conformance/types/tuple/wideningTuples5.ts new file mode 100644 index 00000000000..36434c6eafe --- /dev/null +++ b/tests/cases/conformance/types/tuple/wideningTuples5.ts @@ -0,0 +1,2 @@ +//@noImplicitAny: true +var [a, b] = [undefined, null]; \ No newline at end of file diff --git a/tests/cases/conformance/types/tuple/wideningTuples6.ts b/tests/cases/conformance/types/tuple/wideningTuples6.ts new file mode 100644 index 00000000000..cac228ecb4d --- /dev/null +++ b/tests/cases/conformance/types/tuple/wideningTuples6.ts @@ -0,0 +1,3 @@ +var [a, b] = [undefined, null]; +a = ""; +b = ""; \ No newline at end of file diff --git a/tests/cases/conformance/types/tuple/wideningTuples7.ts b/tests/cases/conformance/types/tuple/wideningTuples7.ts new file mode 100644 index 00000000000..1a4d212d362 --- /dev/null +++ b/tests/cases/conformance/types/tuple/wideningTuples7.ts @@ -0,0 +1,5 @@ +//@noImplicitAny: true +var foo = function bar() { + let intermediate: [string]; + return intermediate = [undefined]; +}; \ No newline at end of file diff --git a/tests/cases/fourslash/consistenceOnIndentionsOfChainedFunctionCalls.ts b/tests/cases/fourslash/consistenceOnIndentionsOfChainedFunctionCalls.ts index 3692974f5fb..ec2ae9b3c22 100644 --- a/tests/cases/fourslash/consistenceOnIndentionsOfChainedFunctionCalls.ts +++ b/tests/cases/fourslash/consistenceOnIndentionsOfChainedFunctionCalls.ts @@ -18,4 +18,4 @@ goTo.marker("1"); edit.insert("\r\n"); goTo.marker("0"); // Won't-fixed: Smart indent during chained function calls -verify.indentationIs(8); \ No newline at end of file +verify.indentationIs(4); \ No newline at end of file diff --git a/tests/cases/fourslash/functionIndentation.ts b/tests/cases/fourslash/functionIndentation.ts index db0379e2068..8fd568629d9 100644 --- a/tests/cases/fourslash/functionIndentation.ts +++ b/tests/cases/fourslash/functionIndentation.ts @@ -46,7 +46,7 @@ verify.currentFileContentIs( " C;\n" + " class C {\n" + " constructor(b\n" + -" ) {\n" + +" ) {\n" + " }\n" + " foo(a\n" + " : string) {\n" + @@ -54,7 +54,7 @@ verify.currentFileContentIs( " || true;\n" + " }\n" + " get bar(\n" + -" ) {\n" + +" ) {\n" + " return 1;\n" + " }\n" + " }\n" + diff --git a/tests/cases/fourslash/getOccurrencesAbstract01.ts b/tests/cases/fourslash/getOccurrencesAbstract01.ts new file mode 100644 index 00000000000..3e48ba4841a --- /dev/null +++ b/tests/cases/fourslash/getOccurrencesAbstract01.ts @@ -0,0 +1,24 @@ +/// + +////[|abstract|] class Animal { +//// [|abstract|] prop1; // Does not compile +//// [|abstract|] abstract(); +//// [|abstract|] walk(): void; +//// [|abstract|] makeSound(): void; +////} +////// Abstract class below should not get highlighted +////abstract class Foo { +//// abstract foo(): void; +//// abstract bar(): void; +////} + +const ranges = test.ranges(); + +for (let r of ranges) { + goTo.position(r.start); + verify.occurrencesAtPositionCount(ranges.length); + + for (let range of ranges) { + verify.occurrencesAtPositionContains(range, false); + } +} diff --git a/tests/cases/fourslash/getOccurrencesAbstract02.ts b/tests/cases/fourslash/getOccurrencesAbstract02.ts new file mode 100644 index 00000000000..8daafdbdc8e --- /dev/null +++ b/tests/cases/fourslash/getOccurrencesAbstract02.ts @@ -0,0 +1,29 @@ +/// + +////// Not valid TS (abstract methods can only appear in abstract classes) +////class Animal { +//// [|abstract|] walk(): void; +//// [|abstract|] makeSound(): void; +////} +////// abstract cannot appear here, won't get highlighted +////let c = /*1*/abstract class Foo { +//// /*2*/abstract foo(): void; +//// abstract bar(): void; +////} + +const ranges = test.ranges(); + +for (let r of ranges) { + goTo.position(r.start); + verify.occurrencesAtPositionCount(ranges.length); + + for (let range of ranges) { + verify.occurrencesAtPositionContains(range, false); + } +} + +goTo.marker("1"); +verify.occurrencesAtPositionCount(0); + +goTo.marker("2"); +verify.occurrencesAtPositionCount(2); diff --git a/tests/cases/fourslash/getOccurrencesClassExpressionConstructor.ts b/tests/cases/fourslash/getOccurrencesClassExpressionConstructor.ts new file mode 100644 index 00000000000..5fa778ef8cd --- /dev/null +++ b/tests/cases/fourslash/getOccurrencesClassExpressionConstructor.ts @@ -0,0 +1,23 @@ +/// + +////let A = class Foo { +//// [|constructor|](); +//// [|constructor|](x: number); +//// [|constructor|](y: string); +//// [|constructor|](a?: any) { +//// } +////} +//// +////let B = class D { +//// constructor(x: number) { +//// } +////} + +const ranges = test.ranges(); +for (let r of ranges) { + goTo.position(r.start); + + for (let range of ranges) { + verify.occurrencesAtPositionContains(range, false); + } +} diff --git a/tests/cases/fourslash/getOccurrencesClassExpressionPrivate.ts b/tests/cases/fourslash/getOccurrencesClassExpressionPrivate.ts new file mode 100644 index 00000000000..b008ec237b8 --- /dev/null +++ b/tests/cases/fourslash/getOccurrencesClassExpressionPrivate.ts @@ -0,0 +1,27 @@ +/// + +////let A = class Foo { +//// [|private|] foo; +//// [|private|] private; +//// constructor([|private|] y: string, public x: string) { +//// } +//// [|private|] method() { } +//// public method2() { } +//// [|private|] static static() { } +////} +//// +////let B = class D { +//// constructor(private x: number) { +//// } +//// private test() {} +//// public test2() {} +////} + +const ranges = test.ranges(); +for (let r of ranges) { + goTo.position(r.start); + + for (let range of ranges) { + verify.occurrencesAtPositionContains(range, false); + } +} diff --git a/tests/cases/fourslash/getOccurrencesClassExpressionPublic.ts b/tests/cases/fourslash/getOccurrencesClassExpressionPublic.ts new file mode 100644 index 00000000000..3070fd4f6ca --- /dev/null +++ b/tests/cases/fourslash/getOccurrencesClassExpressionPublic.ts @@ -0,0 +1,27 @@ +/// + +////let A = class Foo { +//// [|public|] foo; +//// [|public|] public; +//// constructor([|public|] y: string, private x: string) { +//// } +//// [|public|] method() { } +//// private method2() {} +//// [|public|] static static() { } +////} +//// +////let B = class D { +//// constructor(private x: number) { +//// } +//// private test() {} +//// public test2() {} +////} + +const ranges = test.ranges(); +for (let r of ranges) { + goTo.position(r.start); + + for (let range of ranges) { + verify.occurrencesAtPositionContains(range, false); + } +} diff --git a/tests/cases/fourslash/getOccurrencesClassExpressionStatic.ts b/tests/cases/fourslash/getOccurrencesClassExpressionStatic.ts new file mode 100644 index 00000000000..567c0c4eccd --- /dev/null +++ b/tests/cases/fourslash/getOccurrencesClassExpressionStatic.ts @@ -0,0 +1,29 @@ +/// + +////let A = class Foo { +//// public static foo; +//// [|static|] a; +//// constructor(public y: string, private x: string) { +//// } +//// public method() { } +//// private method2() {} +//// public [|static|] static() { } +//// private [|static|] static2() { } +////} +//// +////let B = class D { +//// static a; +//// constructor(private x: number) { +//// } +//// private static test() {} +//// public static test2() {} +////} + +const ranges = test.ranges(); +for (let r of ranges) { + goTo.position(r.start); + + for (let range of ranges) { + verify.occurrencesAtPositionContains(range, false); + } +} diff --git a/tests/cases/fourslash/shims/getSyntacticClassifications.ts b/tests/cases/fourslash/shims/getSyntacticClassifications.ts index 88f655683a3..1dbe2944b8a 100644 --- a/tests/cases/fourslash/shims/getSyntacticClassifications.ts +++ b/tests/cases/fourslash/shims/getSyntacticClassifications.ts @@ -22,8 +22,8 @@ var c = classification; verify.syntacticClassificationsAre( c.comment("// comment"), c.keyword("module"), c.moduleName("M"), c.punctuation("{"), - c.keyword("var"), c.text("v"), c.operator("="), c.numericLiteral("0"), c.operator("+"), c.numericLiteral("1"), c.punctuation(";"), - c.keyword("var"), c.text("s"), c.operator("="), c.stringLiteral('"string"'), c.punctuation(";"), + c.keyword("var"), c.identifier("v"), c.operator("="), c.numericLiteral("0"), c.operator("+"), c.numericLiteral("1"), c.punctuation(";"), + c.keyword("var"), c.identifier("s"), c.operator("="), c.stringLiteral('"string"'), c.punctuation(";"), c.keyword("class"), c.className("C"), c.punctuation("<"), c.typeParameterName("T"), c.punctuation(">"), c.punctuation("{"), c.punctuation("}"), c.keyword("enum"), c.enumName("E"), c.punctuation("{"), diff --git a/tests/cases/fourslash/syntacticClassificationWithErrors.ts b/tests/cases/fourslash/syntacticClassificationWithErrors.ts index b4572d3e620..166a22a1a51 100644 --- a/tests/cases/fourslash/syntacticClassificationWithErrors.ts +++ b/tests/cases/fourslash/syntacticClassificationWithErrors.ts @@ -8,7 +8,7 @@ let c = classification verify.syntacticClassificationsAre( c.keyword("class"), c.className("A"), c.punctuation("{"), - c.text("a"), c.punctuation(":"), + c.identifier("a"), c.punctuation(":"), c.punctuation("}"), - c.text("c"), c.operator("=") + c.identifier("c"), c.operator("=") ); \ No newline at end of file diff --git a/tests/cases/fourslash/syntacticClassifications1.ts b/tests/cases/fourslash/syntacticClassifications1.ts index 88f655683a3..1dbe2944b8a 100644 --- a/tests/cases/fourslash/syntacticClassifications1.ts +++ b/tests/cases/fourslash/syntacticClassifications1.ts @@ -22,8 +22,8 @@ var c = classification; verify.syntacticClassificationsAre( c.comment("// comment"), c.keyword("module"), c.moduleName("M"), c.punctuation("{"), - c.keyword("var"), c.text("v"), c.operator("="), c.numericLiteral("0"), c.operator("+"), c.numericLiteral("1"), c.punctuation(";"), - c.keyword("var"), c.text("s"), c.operator("="), c.stringLiteral('"string"'), c.punctuation(";"), + c.keyword("var"), c.identifier("v"), c.operator("="), c.numericLiteral("0"), c.operator("+"), c.numericLiteral("1"), c.punctuation(";"), + c.keyword("var"), c.identifier("s"), c.operator("="), c.stringLiteral('"string"'), c.punctuation(";"), c.keyword("class"), c.className("C"), c.punctuation("<"), c.typeParameterName("T"), c.punctuation(">"), c.punctuation("{"), c.punctuation("}"), c.keyword("enum"), c.enumName("E"), c.punctuation("{"), diff --git a/tests/cases/fourslash/syntacticClassificationsConflictMarkers1.ts b/tests/cases/fourslash/syntacticClassificationsConflictMarkers1.ts index 7f26038c33e..99db7443a4c 100644 --- a/tests/cases/fourslash/syntacticClassificationsConflictMarkers1.ts +++ b/tests/cases/fourslash/syntacticClassificationsConflictMarkers1.ts @@ -12,8 +12,8 @@ var c = classification; verify.syntacticClassificationsAre( c.keyword("class"), c.className("C"), c.punctuation("{"), c.comment("<<<<<<< HEAD"), - c.text("v"), c.operator("="), c.numericLiteral("1"), c.punctuation(";"), + c.identifier("v"), c.operator("="), c.numericLiteral("1"), c.punctuation(";"), c.comment("======="), - c.text("v"), c.punctuation("="), c.numericLiteral("2"), c.punctuation(";"), + c.identifier("v"), c.punctuation("="), c.numericLiteral("2"), c.punctuation(";"), c.comment(">>>>>>> Branch - a"), c.punctuation("}")); \ No newline at end of file diff --git a/tests/cases/fourslash/syntacticClassificationsConflictMarkers2.ts b/tests/cases/fourslash/syntacticClassificationsConflictMarkers2.ts index 92ede0d104b..18363c0389e 100644 --- a/tests/cases/fourslash/syntacticClassificationsConflictMarkers2.ts +++ b/tests/cases/fourslash/syntacticClassificationsConflictMarkers2.ts @@ -11,5 +11,5 @@ verify.syntacticClassificationsAre( c.comment("<<<<<<< HEAD"), c.keyword("class"), c.className("C"), c.punctuation("{"), c.punctuation("}"), c.comment("======="), - c.keyword("class"), c.text("D"), c.punctuation("{"), c.punctuation("}"), + c.keyword("class"), c.identifier("D"), c.punctuation("{"), c.punctuation("}"), c.comment(">>>>>>> Branch - a")); \ No newline at end of file diff --git a/tests/cases/fourslash/syntacticClassificationsDocComment1.ts b/tests/cases/fourslash/syntacticClassificationsDocComment1.ts index fe812b4c780..1ea3bf9684a 100644 --- a/tests/cases/fourslash/syntacticClassificationsDocComment1.ts +++ b/tests/cases/fourslash/syntacticClassificationsDocComment1.ts @@ -13,5 +13,5 @@ verify.syntacticClassificationsAre( c.punctuation("}"), c.comment(" */"), c.keyword("var"), - c.text("v"), + c.identifier("v"), c.punctuation(";")); diff --git a/tests/cases/fourslash/syntacticClassificationsDocComment2.ts b/tests/cases/fourslash/syntacticClassificationsDocComment2.ts index 201251dde6d..38dca4edcf2 100644 --- a/tests/cases/fourslash/syntacticClassificationsDocComment2.ts +++ b/tests/cases/fourslash/syntacticClassificationsDocComment2.ts @@ -15,12 +15,12 @@ verify.syntacticClassificationsAre( c.punctuation("{"), c.keyword("function"), c.punctuation("("), - c.text("x"), + c.identifier("x"), c.punctuation(")"), c.punctuation(":"), c.keyword("string"), c.punctuation("}"), c.comment(" */"), c.keyword("var"), - c.text("v"), + c.identifier("v"), c.punctuation(";")); diff --git a/tests/cases/fourslash/syntacticClassificationsDocComment3.ts b/tests/cases/fourslash/syntacticClassificationsDocComment3.ts index 6aca8cc415f..d7996fbbc54 100644 --- a/tests/cases/fourslash/syntacticClassificationsDocComment3.ts +++ b/tests/cases/fourslash/syntacticClassificationsDocComment3.ts @@ -15,5 +15,5 @@ verify.syntacticClassificationsAre( c.keyword("number"), c.comment(" /* } */"), c.keyword("var"), - c.text("v"), + c.identifier("v"), c.punctuation(";")); diff --git a/tests/cases/fourslash/syntacticClassificationsForOfKeyword.ts b/tests/cases/fourslash/syntacticClassificationsForOfKeyword.ts index a7a8c704ce6..22d7aa8ba94 100644 --- a/tests/cases/fourslash/syntacticClassificationsForOfKeyword.ts +++ b/tests/cases/fourslash/syntacticClassificationsForOfKeyword.ts @@ -7,9 +7,9 @@ verify.syntacticClassificationsAre( c.keyword("for"), c.punctuation("("), c.keyword("var"), - c.text("of"), + c.identifier("of"), c.keyword("of"), - c.text("of"), + c.identifier("of"), c.punctuation(")"), c.punctuation("{"), c.punctuation("}") diff --git a/tests/cases/fourslash/syntacticClassificationsForOfKeyword2.ts b/tests/cases/fourslash/syntacticClassificationsForOfKeyword2.ts index 30cfaea51e0..190663caa99 100644 --- a/tests/cases/fourslash/syntacticClassificationsForOfKeyword2.ts +++ b/tests/cases/fourslash/syntacticClassificationsForOfKeyword2.ts @@ -7,9 +7,9 @@ verify.syntacticClassificationsAre( c.keyword("for"), c.punctuation("("), c.keyword("var"), - c.text("of"), + c.identifier("of"), c.keyword("in"), - c.text("of"), + c.identifier("of"), c.punctuation(")"), c.punctuation("{"), c.punctuation("}") diff --git a/tests/cases/fourslash/syntacticClassificationsForOfKeyword3.ts b/tests/cases/fourslash/syntacticClassificationsForOfKeyword3.ts index 3af4733f3b2..ef96c99fed4 100644 --- a/tests/cases/fourslash/syntacticClassificationsForOfKeyword3.ts +++ b/tests/cases/fourslash/syntacticClassificationsForOfKeyword3.ts @@ -7,11 +7,11 @@ verify.syntacticClassificationsAre( c.keyword("for"), c.punctuation("("), c.keyword("var"), - c.text("of"), + c.identifier("of"), c.punctuation(";"), - c.text("of"), + c.identifier("of"), c.punctuation(";"), - c.text("of"), + c.identifier("of"), c.punctuation(")"), c.punctuation("{"), c.punctuation("}") diff --git a/tests/cases/fourslash/syntacticClassificationsFunctionWithComments.ts b/tests/cases/fourslash/syntacticClassificationsFunctionWithComments.ts index f7e5b7355a7..05a5aaa173e 100644 --- a/tests/cases/fourslash/syntacticClassificationsFunctionWithComments.ts +++ b/tests/cases/fourslash/syntacticClassificationsFunctionWithComments.ts @@ -19,7 +19,7 @@ var firstCommentText = var c = classification; verify.syntacticClassificationsAre( c.comment(firstCommentText), - c.keyword("function"), c.text("myFunction"), c.punctuation("("), c.comment("/* x */"), c.parameterName("x"), c.punctuation(":"), c.keyword("any"), c.punctuation(")"), c.punctuation("{"), - c.keyword("var"), c.text("y"), c.operator("="), c.text("x"), c.operator("?"), c.text("x"), c.operator("++"), c.operator(":"), c.operator("++"), c.text("x"), c.punctuation(";"), + c.keyword("function"), c.identifier("myFunction"), c.punctuation("("), c.comment("/* x */"), c.parameterName("x"), c.punctuation(":"), c.keyword("any"), c.punctuation(")"), c.punctuation("{"), + c.keyword("var"), c.identifier("y"), c.operator("="), c.identifier("x"), c.operator("?"), c.identifier("x"), c.operator("++"), c.operator(":"), c.operator("++"), c.identifier("x"), c.punctuation(";"), c.punctuation("}"), c.comment("// end of file")); \ No newline at end of file diff --git a/tests/cases/fourslash/syntacticClassificationsObjectLiteral.ts b/tests/cases/fourslash/syntacticClassificationsObjectLiteral.ts index 59642468ce9..c5bab5181a3 100644 --- a/tests/cases/fourslash/syntacticClassificationsObjectLiteral.ts +++ b/tests/cases/fourslash/syntacticClassificationsObjectLiteral.ts @@ -13,13 +13,13 @@ var c = classification; verify.syntacticClassificationsAre( - c.keyword("var"), c.text("v"), c.operator("="), c.numericLiteral("10e0"), c.punctuation(";"), - c.keyword("var"), c.text("x"), c.operator("="), c.punctuation("{"), - c.text("p1"), c.punctuation(":"), c.numericLiteral("1"), c.punctuation(","), - c.text("p2"), c.punctuation(":"), c.numericLiteral("2"), c.punctuation(","), - c.text("any"), c.punctuation(":"), c.numericLiteral("3"), c.punctuation(","), - c.text("function"), c.punctuation(":"), c.numericLiteral("4"), c.punctuation(","), - c.text("var"), c.punctuation(":"), c.numericLiteral("5"), c.punctuation(","), - c.text("void"), c.punctuation(":"), c.keyword("void"), c.numericLiteral("0"), c.punctuation(","), - c.text("v"), c.punctuation(":"), c.text("v"), c.operator("+="), c.text("v"), c.punctuation(","), + c.keyword("var"), c.identifier("v"), c.operator("="), c.numericLiteral("10e0"), c.punctuation(";"), + c.keyword("var"), c.identifier("x"), c.operator("="), c.punctuation("{"), + c.identifier("p1"), c.punctuation(":"), c.numericLiteral("1"), c.punctuation(","), + c.identifier("p2"), c.punctuation(":"), c.numericLiteral("2"), c.punctuation(","), + c.identifier("any"), c.punctuation(":"), c.numericLiteral("3"), c.punctuation(","), + c.identifier("function"), c.punctuation(":"), c.numericLiteral("4"), c.punctuation(","), + c.identifier("var"), c.punctuation(":"), c.numericLiteral("5"), c.punctuation(","), + c.identifier("void"), c.punctuation(":"), c.keyword("void"), c.numericLiteral("0"), c.punctuation(","), + c.identifier("v"), c.punctuation(":"), c.identifier("v"), c.operator("+="), c.identifier("v"), c.punctuation(","), c.punctuation("}"), c.punctuation(";")); \ No newline at end of file diff --git a/tests/cases/fourslash/syntacticClassificationsTemplates1.ts b/tests/cases/fourslash/syntacticClassificationsTemplates1.ts index 8ee48fb8a11..6c27aab3f40 100644 --- a/tests/cases/fourslash/syntacticClassificationsTemplates1.ts +++ b/tests/cases/fourslash/syntacticClassificationsTemplates1.ts @@ -8,8 +8,8 @@ var c = classification; verify.syntacticClassificationsAre( - c.keyword("var"), c.text("v"), c.operator("="), c.numericLiteral("10e0"), c.punctuation(";"), - c.keyword("var"), c.text("x"), c.operator("="), c.punctuation("{"), - c.text("p1"), c.punctuation(":"), c.stringLiteral("`hello world`"), c.punctuation(","), - c.text("p2"), c.punctuation(":"), c.stringLiteral("`goodbye ${"), c.numericLiteral("0"), c.stringLiteral("} cruel ${"), c.numericLiteral("0"), c.stringLiteral("} world`"), c.punctuation(","), + c.keyword("var"), c.identifier("v"), c.operator("="), c.numericLiteral("10e0"), c.punctuation(";"), + c.keyword("var"), c.identifier("x"), c.operator("="), c.punctuation("{"), + c.identifier("p1"), c.punctuation(":"), c.stringLiteral("`hello world`"), c.punctuation(","), + c.identifier("p2"), c.punctuation(":"), c.stringLiteral("`goodbye ${"), c.numericLiteral("0"), c.stringLiteral("} cruel ${"), c.numericLiteral("0"), c.stringLiteral("} world`"), c.punctuation(","), c.punctuation("}"), c.punctuation(";")); \ No newline at end of file diff --git a/tests/cases/fourslash/syntacticClassificationsTemplates2.ts b/tests/cases/fourslash/syntacticClassificationsTemplates2.ts index 913dc039012..25bb64e78ba 100644 --- a/tests/cases/fourslash/syntacticClassificationsTemplates2.ts +++ b/tests/cases/fourslash/syntacticClassificationsTemplates2.ts @@ -6,6 +6,6 @@ var c = classification; verify.syntacticClassificationsAre( - c.keyword("var"), c.text("tiredOfCanonicalExamples"), c.operator("="), + c.keyword("var"), c.identifier("tiredOfCanonicalExamples"), c.operator("="), c.stringLiteral("`goodbye \"${"), c.stringLiteral("`hello world`"), c.stringLiteral("}\" \nand ${"), c.stringLiteral("`good${"), c.stringLiteral("\" \""), c.stringLiteral("}riddance`"), c.stringLiteral("}`"), c.punctuation(";")); \ No newline at end of file